9 decay_rate = GetFromManager<double>(Config[
"General"][
"MCMC"][
"DecayRate"], 0.1, __FILE__, __LINE__);
11 max_rejections = GetFromManager<int>(Config[
"General"][
"MCMC"][
"MaxRejections"], 1, __FILE__, __LINE__);
13 initial_scale = GetFromManager<int>(Config[
"General"][
"MCMC"][
"InitialScale"], 1, __FILE__, __LINE__);
15 delay_on_oob_only = GetFromManager<bool>(Config[
"General"][
"MCMC"][
"DelayOnlyOutBounds"],
false, __FILE__, __LINE__);
17 delay_probability = GetFromManager<double>(Config[
"General"][
"MCMC"][
"DelayProbability"], 1.0, __FILE__, __LINE__);
20 MACH3LOG_WARN(
"Probability of delaying steps > 1, setting to 1");
24 MACH3LOG_CRITICAL(
"Probability of delaying steps <= 0, setting to 0, delay will no longer have an impact!");
37 syst->SetStepScale(scale*syst->GetGlobalStepScale(),
false);
44 for (
int i = 0; i < static_cast<int>(
systematics.size()); ++i)
57 if(
systematics[i]->GetAdaptiveHandler()->GetUseRobbinsMonro()){
58 MACH3LOG_ERROR(
"Right now Robbins-Monro doesn't work with Delayed MCMC");
78 for(
int i=0; i<static_cast<int>(
systematics.size()); ++i){
90 if (denominator <= 0.0)
return 1.0;
93 if(std::isinf(numerator) || std::isinf(denominator) ){
97 return std::min(numerator / denominator, 1.0);
109 bool accepted =
false;
167 for(
int i=0; i<static_cast<int>(
systematics.size()); ++i){
168 for(
int j=0; j<static_cast<int>(
systematics[i]->GetParCurrVec().size()); ++j){
#define MACH3LOG_CRITICAL
bool accepted_delayed
Was the step we just accepted delayed?
void PrepareOutput()
override to add in rejection information to output
int max_rejections
How many rejections allowed?
bool ProbabilisticDelay() const
if delay has a chance of occurring
void StoreCurrentStep()
Store information about the current proposed step.
double delay_probability
Can delay with probability instead.
std::vector< double > start_step_scale
Stores the initial scale for all parameters.
bool delay_on_oob_only
Delay only if we go out of bounds.
void DoStep() final
The MCMC step proposal.
double MinLogLikelihood
Minimum (negative) log-likelihood of proposed steps.
DelayedMR2T2(Manager *const fitMan)
Constructor.
void ResetSystScale()
Reset scale after delay process.
double decay_rate
How much to decrease the step scale each step.
double AcceptanceProbability() final
Step acceptance probability.
void ScaleSystematics(const double scale)
Set parameter scale to be original_scale* scale.
double initial_scale
Scale for (non-delayed) step is initial_scale * start_step_scale.
std::vector< std::vector< double > > current_step_vals
Store information about the current proposed step.
std::unique_ptr< TRandom3 > random
Random number.
double logLProp
proposed likelihood
void PrepareOutput()
Prepare the output file.
double accProb
current acceptance prob
std::string AlgorithmName
Name of fitting algorithm that is being used.
Manager * fitMan
The manager for configuration handling.
double logLCurr
current likelihood
TTree * outTree
Output tree with posteriors.
std::vector< ParameterHandlerBase * > systematics
Systematic holder.
void AcceptStep()
Accept a step.
bool out_of_bounds
Do we reject based on hitting boundaries in systs.
bool IsStepAccepted(const double acc_prob)
Is step accepted?
MCMC algorithm implementing the Metropolis–Rosenbluth–Rosenbluth–Teller–Teller (MR T ) method.
void ProposeStep() final
Propose a step.
double AcceptanceProbability() override
Step acceptance probability.
Custom exception class used throughout MaCh3.
The manager class is responsible for managing configurations and settings.
YAML::Node const & raw() const
Return config.
constexpr static const double _LARGE_LOGL_
Large Likelihood is used it parameter go out of physical boundary, this indicates in MCMC that such s...