BCEngineMCMC Class Referenceabstract

An engine class for Markov Chain Monte Carlo. More...

#include <BCEngineMCMC.h>

Inheritance diagram for BCEngineMCMC:
[legend]
Collaboration diagram for BCEngineMCMC:
[legend]

Classes

struct  ChainState
 A struct for holding a state in a Markov chain. More...
 
struct  Statistics
 A struct for holding statistical information about samples. More...
 

Public Types

Enumerators
enum  Precision {
  kLow, kQuick, kMedium, kHigh,
  kVeryHigh
}
 An enumerator for the status of a test. More...
 
enum  Phase { kPreRun = -1, kUnsetPhase = 0, kMainRun = +1 }
 An enumerator for the phase of the Markov chain. More...
 
enum  InitialPositionScheme { kInitCenter = 0, kInitRandomUniform = 1, kInitUserDefined = 2, kInitRandomPrior = 3 }
 An enumerator for markov-chain position initialization. More...
 

Public Member Functions

Constructors and destructor
 BCEngineMCMC (const std::string &name="model")
 Default constructor. More...
 
 BCEngineMCMC (const BCEngineMCMC &enginemcmc)
 Copy constructor. More...
 
 BCEngineMCMC (const std::string &filename, const std::string &name, bool loadObservables=true)
 Read in MCMC constructor. More...
 
BCEngineMCMCoperator= (const BCEngineMCMC &)
 Copy-assignment operator.
 
virtual ~BCEngineMCMC ()
 Destructor. More...
 
Getters
const std::string & GetName () const
 
const std::string & GetSafeName () const
 
unsigned GetNChains () const
 
unsigned GetNLag () const
 
int GetCurrentIteration () const
 
unsigned GetCurrentChain () const
 
int GetNIterationsConvergenceGlobal () const
 
unsigned GetNIterationsPreRun () const
 
unsigned GetNIterationsPreRunMin () const
 
unsigned GetNIterationsPreRunMax () const
 
unsigned GetNIterationsRun () const
 
unsigned GetNIterationsPreRunCheck () const
 
unsigned GetPreRunCheckClear ()
 
double GetMinimumEfficiency () const
 
double GetMaximumEfficiency () const
 
double GetScaleFactorLowerLimit () const
 
double GetScaleFactorUpperLimit () const
 
const std::vector< std::vector< double > > & GetScaleFactors () const
 
const ChainStateGetChainState (unsigned c) const
 
const std::vector< double > & Getx (unsigned c) const
 
double Getx (unsigned c, unsigned p) const
 
double GetLogProbx (unsigned c) const
 
BCEngineMCMC::Phase GetPhase () const
 
BCEngineMCMC::InitialPositionScheme GetInitialPositionScheme () const
 
unsigned GetInitialPositionAttemptLimit () const
 
bool GetProposeMultivariate () const
 
double GetProposalFunctionDof () const
 
unsigned GetMultivariateCovarianceUpdates () const
 
double GetMultivariateCovarianceUpdateLambda () const
 
double GetMultivariateEpsilon () const
 
double GetMultivariateScaleMultiplier () const
 
double GetRValueParametersCriterion () const
 
const std::vector< double > & GetRValueParameters () const
 
double GetRValueParameters (unsigned index) const
 
bool GetCorrectRValueForSamplingVariability () const
 Flag for correcting convergence checking for initial sampling variability. More...
 
bool GetFlagRun () const
 
TTree * GetMarkovChainTree () const
 Retrieve the tree containing the Markov chain. More...
 
TTree * GetParameterTree () const
 Retrieve the tree containing the parameter information. More...
 
TFile * GetOutputFile () const
 Retrieve output file for MCMC. More...
 
const BCEngineMCMC::StatisticsGetStatistics () const
 Get combined statistics for all chains. More...
 
const BCEngineMCMC::StatisticsGetStatistics (unsigned c) const
 Get MCMC statistics for one chain. More...
 
const std::vector< BCEngineMCMC::Statistics > & GetStatisticsVector () const
 Get vector of MCMC statistics for each chain separately. More...
 
bool GetRescaleHistogramRangesAfterPreRun () const
 
double GetHistogramRescalePadding () const
 
virtual std::vector< unsigned > GetH1DPrintOrder () const
 
virtual std::vector< std::pair< unsigned, unsigned > > GetH2DPrintOrder () const
 
bool MarginalizedHistogramExists (unsigned index) const
 
bool MarginalizedHistogramExists (unsigned index1, unsigned index2) const
 
TH1 * GetMarginalizedHistogram (const std::string &name) const
 Obtain the individual marginalized distributions with respect to one parameter as a ROOT TH1. More...
 
TH1 * GetMarginalizedHistogram (unsigned index) const
 Obtain the individual marginalized distributions with respect to one parameter as a ROOT TH1. More...
 
TH2 * GetMarginalizedHistogram (const std::string &name1, const std::string &name2) const
 Obtain the individual marginalized distributions with respect to two parameters as a ROOT TH2. More...
 
TH2 * GetMarginalizedHistogram (unsigned index1, unsigned index2) const
 Obtain the individual marginalized distributions with respect to two parameters as a ROOT TH2. More...
 
BCH1D GetMarginalized (const std::string &name) const
 Obtain the individual marginalized distributions with respect to one parameter. More...
 
BCH1D GetMarginalized (unsigned index) const
 Obtain the individual marginalized distributions with respect to one parameter. More...
 
BCH2D GetMarginalized (const std::string &name1, const std::string &name2) const
 Obtain the individual marginalized distributions with respect to two parameters. More...
 
BCH2D GetMarginalized (unsigned index1, unsigned index2) const
 Obtain the individual marginalized distributions with respect to two parameters. More...
 
unsigned GetMaximumParameterNameLength (bool observables=true) const
 
BCVariableGetVariable (unsigned index)
 
const BCVariableGetVariable (unsigned index) const
 
unsigned GetNVariables () const
 
BCParameterSetGetParameters ()
 
const BCParameterSetGetParameters () const
 
BCParameterGetParameter (unsigned index)
 
const BCParameterGetParameter (unsigned index) const
 
BCParameterGetParameter (const std::string &name)
 
const BCParameterGetParameter (const std::string &name) const
 
unsigned GetNParameters () const
 
unsigned GetNFixedParameters () const
 
unsigned GetNFreeParameters () const
 
BCObservableSetGetObservables ()
 
const BCObservableSetGetObservables () const
 
BCObservableGetObservable (unsigned index)
 
const BCObservableGetObservable (unsigned index) const
 
BCObservableGetObservable (const std::string &name)
 
const BCObservableGetObservable (const std::string &name) const
 
unsigned GetNObservables () const
 
virtual const std::vector< double > & GetBestFitParameters () const
 
virtual const std::vector< double > & GetBestFitParameterErrors () const
 
const std::vector< double > & GetLocalModes (bool force_recalculation=false)
 
virtual double GetLogMaximum () const
 
bool GetReuseObservables () const
 
BCH1DGetBCH1DdrawingOptions ()
 
BCH2DGetBCH2DdrawingOptions ()
 
Setters
void SetName (const std::string &name)
 Sets the name of the engine. More...
 
void SetScaleFactorLowerLimit (double l)
 Set scale factor lower limit.
 
void SetScaleFactorUpperLimit (double l)
 Set scale factor upper limit.
 
void SetInitialScaleFactors (const std::vector< double > &scale)
 Set the initial scale factors for the factorized proposal function. More...
 
void SetNChains (unsigned n)
 Sets the number of Markov chains which are run in parallel. More...
 
void SetNLag (unsigned n)
 Sets the lag of the Markov chains.
 
void SetNIterationsPreRunMax (unsigned n)
 Sets the maximum number of iterations in the pre-run. More...
 
void SetNIterationsRun (unsigned n)
 Sets the number of iterations. More...
 
void SetNIterationsPreRunMin (unsigned n)
 Sets the minimum number of iterations in the pre-run.
 
void SetNIterationsPreRunCheck (unsigned n)
 Sets the number of iterations between scale adjustments and convergence checks in the pre-run. More...
 
void SetPreRunCheckClear (unsigned n)
 Sets the number of prerun checks to make inbetween statistics clearing. More...
 
void SetMinimumEfficiency (double efficiency)
 Sets the minimum efficiency required for a chain. More...
 
void SetMaximumEfficiency (double efficiency)
 Sets the maximum efficiency required for a chain. More...
 
void SetRandomSeed (unsigned seed)
 Set the random number seed.
 
void SetInitialPositions (const std::vector< double > &x0s)
 Sets the initial positions for all chains. More...
 
void SetInitialPositions (const std::vector< std::vector< double > > &x0s)
 Sets the initial positions for all chains. More...
 
void SetInitialPositionScheme (BCEngineMCMC::InitialPositionScheme scheme)
 Sets flag which defines initial position. More...
 
void SetInitialPositionAttemptLimit (unsigned n)
 Sets maximum number of attempts to find a valid initial position. More...
 
void SetProposeMultivariate (bool flag)
 Set flag to true to turn on the multivariate proposal for MCMC based on (Haario et al., 2001) where the covariance is learned from the prerun. More...
 
void SetProposalFunctionDof (double dof=1)
 Set the degree of freedom of the proposal function for MCMC. More...
 
void SetMultivariateCovarianceUpdateLambda (double l)
 Set weighting for multivariate proposal function covariance update. More...
 
void SetMultivariateEpsilon (double epsilon)
 Sets multivariate-proposal-function cholesky-decomposition nudge. More...
 
void SetMultivariateScaleMultiplier (double s)
 Sets multivariate-proposal-function scale multiplier. More...
 
void SetFlagFillHistograms (bool flag)
 Sets whether to fill histograms. More...
 
void SetFlagFillHistograms (bool flag_1d, bool flag_2d)
 Sets the whether to fill histograms. More...
 
void SetFillHistogramParPar (unsigned x, unsigned y, bool flag=true)
 Sets whether to fill particular H2 histogram: par(y) vs. More...
 
void SetFillHistogramParPar (const std::string &x, const std::string &y, bool flag=true)
 Sets whether to fill particular H2 histogram: par(y) vs. More...
 
void SetFillHistogramParObs (unsigned x, unsigned y, bool flag=true)
 Sets whether to fill particular H2 histogram: obs(y) vs. More...
 
void SetFillHistogramParObs (const std::string &x, const std::string &y, bool flag=true)
 Sets whether to fill particular H2 histogram: obs(y) vs. More...
 
void SetFillHistogramObsObs (unsigned x, unsigned y, bool flag=true)
 Sets whether to fill particular H2 histogram: obs(y) vs. More...
 
void SetFillHistogramObsObs (const std::string &x, const std::string &y, bool flag=true)
 Sets whether to fill particular H2 histogram: obs(y) vs. More...
 
void SetFillHistogramObsPar (unsigned x, unsigned y, bool flag=true)
 Sets whether to fill particular H2 histogram: par(y) vs. More...
 
void SetFillHistogramObsPar (const std::string &x, const std::string &y, bool flag=true)
 Sets whether to fill particular H2 histogram: par(y) vs. More...
 
void SetFlagPreRun (bool flag)
 Set if a (new) prerun should be performed. More...
 
void SetRValueParametersCriterion (double r)
 Sets the parameter R-value criterion for convergence of all chains.
 
void SetCorrectRValueForSamplingVariability (bool flag=true)
 Set flag to correct convergence checking for initial sampling variability. More...
 
void SetPrecision (BCEngineMCMC::Precision precision)
 Set the precision for the MCMC run. More...
 
void SetPrecision (const BCEngineMCMC *other)
 Copy precision for the MCMC run from other model. More...
 
void SetPrecision (const BCEngineMCMC &other)
 Copy precision for the MCMC run from other model. More...
 
void SetNbins (unsigned int nbins)
 Set the number of bins for the marginalized distribution of all parameters. More...
 
void SetReuseObservables (bool flag)
 
void SetRescaleHistogramRangesAfterPreRun (bool flag=true)
 Set flag for rescaling histogram ranges after pre-run. More...
 
void SetHistogramRescalingPadding (double factor)
 Set enlargement factor of range for when rescaling. More...
 
void WriteMarkovChain (bool flag)
 Turn on/off writing of Markov chain to root file. More...
 
void WriteMarkovChainRun (bool flag)
 Turn on/off writing of Markov chain to root file during run. More...
 
void WriteMarkovChainPreRun (bool flag)
 Turn on/off writing of Markov chain to root file during prerun. More...
 
void WriteMarkovChain (const std::string &filename, const std::string &option, bool flag_run=true, bool flag_prerun=true)
 Turn on writing of Markov chain to root file. More...
 
Prior setting functions (all deprecated).

The priors are not used for the likelihood calculation by BCEngineMCMC, but are used for initializing the positions of the chains.

void SetPriorConstant (unsigned index)
 
void SetPriorConstant (const std::string &name)
 
void SetPrior (unsigned index, TF1 &f, bool logL=true)
 
void SetPrior (const std::string &name, TF1 &f, bool logL=true)
 
void SetPriorDelta (unsigned index, double value)
 
void SetPriorDelta (const std::string &name, double value)
 
void SetPriorGauss (unsigned index, double mean, double sigma)
 
void SetPriorGauss (const std::string &name, double mean, double sigma)
 
void SetPriorGauss (unsigned index, double mode, double sigma_below, double sigma_above)
 
void SetPriorGauss (const std::string &name, double mode, double sigma_below, double sigma_above)
 
void SetPrior (unsigned index, TH1 &h, bool interpolate=false)
 
void SetPrior (const std::string &name, TH1 &h, bool interpolate=false)
 
void SetPriorConstantAll ()
 
Output functions
void WriteMarginalizedDistributions (const std::string &filename, const std::string &option, bool closeExistingFile=false)
 Write marginalization histograms to file. More...
 
virtual void PrintSummary () const
 Prints a summary to the logs. More...
 
void PrintParameters (const std::vector< double > &P, void(*output)(const std::string &)=BCLog::OutSummary) const
 Print parameters. More...
 
unsigned PrintAllMarginalized (const std::string &filename, unsigned hdiv=1, unsigned vdiv=1) const
 Print all marginalizations. More...
 
unsigned PrintParameterPlot (const std::string &filename, int npar=10, double interval_content=68e-2, std::vector< double > quantile_values=std::vector< double >(0), bool rescale_ranges=true) const
 Print a summary plot for the parameters and user-defined observables. More...
 
bool DrawParameterPlot (unsigned i0, unsigned npar=0, double interval_content=68e-2, std::vector< double > quantile_values=std::vector< double >(0), bool rescale_ranges=true) const
 Draw a summary plot for the parameters in the range provided to current pad. More...
 
bool PrintCorrelationMatrix (const std::string &filename="matrix.pdf") const
 Print a correlation matrix for the parameters. More...
 
bool PrintCorrelationPlot (const std::string &filename="correlation.pdf", bool include_observables=true) const
 Print a correlation plot for the parameters. More...
 
bool PrintParameterLatex (const std::string &filename) const
 Print a LaTeX table of the parameters. More...
 

Protected Member Functions

virtual std::string GetBestFitSummary (unsigned i) const
 Get string summarizing best fit for single variable. More...
 
virtual void PrintBestFitSummary () const
 Print best fit to log. More...
 
virtual void PrintMarginalizationSummary () const
 Print marginalization to log. More...
 
virtual void PrintModelSummary () const
 Print model summary to log. More...
 
void SetFillHistogram (int x, int y, bool flag)
 Set whether to fill 2D histogram y vs x: positive indices for parameters; negative for observables, starting at -1 and going more negative—observable index = -(index+1). More...
 
unsigned UpdateFrequency (unsigned N) const
 return appropriate update interval More...
 
void UpdateParameterTree ()
 Update Paramater TTree with scales and efficiencies. More...
 

Protected Attributes

BCH1D fBCH1DdrawingOptions
 A BCH1D (with no histogram) for storing BCH1D drawing options. More...
 
BCH2D fBCH2DdrawingOptions
 A BCH2D (with no histogram) for storing BCH2D drawing options. More...
 
bool fCorrectRValueForSamplingVariability
 flag for correcting R value for initial sampling variability. More...
 
std::vector< TH1 * > fH1Marginalized
 Vector of 1D marginalized distributions.
 
std::vector< std::vector< TH2 * > > fH2Marginalized
 Vector of 2D marginalized distributions. More...
 
double fHistogramRescalePadding
 factor for enlarging range of histograms when rescaling. More...
 
unsigned fInitialPositionAttemptLimit
 Maximum number of attempts to make to set the initial position. More...
 
BCEngineMCMC::InitialPositionScheme fInitialPositionScheme
 Variable which defines the initial position. More...
 
std::vector< double > fLocalModes
 Vector of local modes. More...
 
int fMCMCCurrentIteration
 The current iteration number. More...
 
double fMCMCEfficiencyMax
 The maximum allowed efficiency for MCMC.
 
double fMCMCEfficiencyMin
 The minimum required efficiency for MCMC.
 
bool fMCMCFlagWriteChainToFile
 Flag to write Markov chains to file.
 
bool fMCMCFlagWritePreRunToFile
 Flag to write pre run to file.
 
std::vector< std::vector< double > > fMCMCInitialPosition
 The intial position of each Markov chain. More...
 
std::vector< double > fMCMCInitialScaleFactors
 User-provided initial values of the scale factors of the factorized proposal function. More...
 
unsigned fMCMCNChains
 Number of Markov chains ran in parallel.
 
int fMCMCNIterationsConvergenceGlobal
 Number of iterations needed for all chains to convergence simultaneously.
 
unsigned fMCMCNIterationsPreRunCheck
 Number of iterations between scale adjustments and convergence checks in pre-run. More...
 
unsigned fMCMCNIterationsPreRunMax
 Maximum number of iterations for a Markov chain prerun.
 
unsigned fMCMCNIterationsPreRunMin
 Minimum number of iterations for the pre-run.
 
unsigned fMCMCNIterationsRun
 Number of iterations for a Markov chain run.
 
unsigned fMCMCNLag
 The lag for the Markov Chain.
 
TFile * fMCMCOutputFile
 Output file for for writing MCMC Tree. More...
 
std::string fMCMCOutputFilename
 Output filename for for writing MCMC Tree. More...
 
std::string fMCMCOutputFileOption
 Output file open option for for writing MCMC Tree. More...
 
BCEngineMCMC::Phase fMCMCPhase
 The phase of the run. More...
 
unsigned fMCMCPreRunCheckClear
 Number of iterations between clearing of convergence stats in pre-run. More...
 
double fMCMCProposalFunctionDof
 Degree of freedom of Student's t proposal. More...
 
std::vector< std::vector< double > > fMCMCProposalFunctionScaleFactor
 Scale factors for proposal functions. More...
 
bool fMCMCProposeMultivariate
 Flag for using multivariate proposal function. More...
 
std::vector< double > fMCMCRValueParameters
 The R-values for each parameter.
 
double fMCMCRValueParametersCriterion
 The R-value criterion for convergence of parameters.
 
double fMCMCScaleFactorLowerLimit
 Lower limit for scale factors.
 
double fMCMCScaleFactorUpperLimit
 Upper limit for scale factors.
 
std::vector< ChainStatefMCMCStates
 The current states of each Markov chain. More...
 
std::vector< BCEngineMCMC::StatisticsfMCMCStatistics
 Statistics for each Markov chain. More...
 
BCEngineMCMC::Statistics fMCMCStatistics_AllChains
 Statistics across all Markov chains. More...
 
TTree * fMCMCTree
 The tree containing the Markov chains. More...
 
unsigned int fMCMCTree_Chain
 Chain number for storing into tree.
 
ChainState fMCMCTree_State
 MC state object for storing into tree.
 
bool fMCMCTreeLoaded
 flag for whether MCMC Tree successfully loaded. More...
 
bool fMCMCTreeReuseObservables
 flag for whether to reuse MCMC Tree's observables. More...
 
double fMultivariateCovarianceUpdateLambda
 weighting parameter for multivariate-proposal-function covariance update. More...
 
unsigned fMultivariateCovarianceUpdates
 Number of multivariate-proposal-function covariance updates performed. More...
 
double fMultivariateEpsilon
 multivariate-proposal-function cholesky-decomposition nudge. More...
 
std::vector< TMatrixD > fMultivariateProposalFunctionCholeskyDecomposition
 Cholesky decompositions for multivariate proposal function. More...
 
std::vector< TMatrixDSym > fMultivariateProposalFunctionCovariance
 Covariance matrices used in multivariate proposal functions. More...
 
double fMultivariateScaleMultiplier
 factor to multiply or divide scale factors by in adjusting multivariate-proposal-function scales. More...
 
std::string fName
 Name of the engine. More...
 
BCAux::BCTrash< TObject > fObjectTrash
 Storage for plot objects with proper clean-up.
 
BCObservableSet fObservables
 User-calculated Observables Set.
 
BCParameterSet fParameters
 Parameter settings.
 
TTree * fParameterTree
 The tree containing the parameter information. More...
 
TRandom3 fRandom
 Random number generator.
 
std::vector< std::pair< int, int > > fRequestedH2
 Vector of pairs of indices for which 2D histograms should be stored. More...
 
bool fRescaleHistogramRangesAfterPreRun
 flag for rescaling of histograms after pre-run. More...
 
std::string fSafeName
 Safe name of the engine for use in naming ROOT objects. More...
 

Friends

Structs
class BCModel
 

Miscellaneous methods

virtual void CreateHistograms (bool rescale_ranges=false)
 Create histograms from parameter and observable sets. More...
 
virtual void InitializeMarkovChainTree (bool replacetree=false, bool replacefile=false)
 Initialize the trees containing the Markov chains and parameter info. More...
 
virtual bool AddParameter (const std::string &name, double min, double max, const std::string &latexname="", const std::string &unitstring="")
 
virtual bool AddParameter (BCParameter &parameter)
 
virtual bool AddObservable (const std::string &name, double min, double max, const std::string &latexname="", const std::string &unitstring="")
 
virtual bool AddObservable (BCObservable &obs)
 
virtual void EvaluateObservables ()
 Evaluates user-defined observables at current state of all chains and stores results in fMCMCState.
 
virtual void EvaluateObservables (unsigned chain)
 Evaluates user-defined observables at current state of chain and stores results in fMCMCState. More...
 
virtual void CalculateObservables (const std::vector< double > &pars)
 Evaluates user-defined observables. More...
 
virtual double ProposalFunction (unsigned ichain, unsigned ipar)
 The default proposal function is a Breit-Wigner random walk. More...
 
bool GetProposalPointMetropolis (unsigned chain, std::vector< double > &x)
 Return a proposal point for the Metropolis algorithm. More...
 
bool GetProposalPointMetropolis (unsigned chain, unsigned parameter, std::vector< double > &x)
 Return a proposal point for the Metropolis algorithm. More...
 
bool GetNewPointMetropolis ()
 Generate a new point using the Metropolis algorithm for all chains. More...
 
bool GetNewPointMetropolis (unsigned chain)
 Generate a new point using the Metropolis algorithm for one chain. More...
 
bool GetNewPointMetropolis (unsigned chain, unsigned parameter)
 Generate a new point using the Metropolis algorithm for one chain, varying only one parameter's value. More...
 
bool AcceptOrRejectPoint (unsigned chain, unsigned parameter)
 Accept or rejects a point for a chain and updates efficiency. More...
 
void InChainFillHistograms (const ChainState &cs)
 Fill marginalized distributions from a chain state.
 
void InChainFillHistograms ()
 Fill marginalized distributions from all chain states.
 
void InChainFillTree (const ChainState &cs, unsigned chain_number)
 Write a chain state to the tree.
 
void InChainFillTree ()
 Write all chain states to the tree.
 
virtual double LogEval (const std::vector< double > &parameters)=0
 Needs to be overloaded in the derived class. More...
 
bool Metropolis ()
 Runs Metropolis algorithm. More...
 
bool MetropolisPreRun ()
 Runs a pre run for the Metropolis algorithm. More...
 
void MCMCInitialize ()
 Resets all containers used in MCMC and initializes starting points. More...
 
virtual void MCMCUserInitialize ()
 User hook called from MCMCInitialize(). More...
 
virtual void ResetResults ()
 Reset the MCMC variables. More...
 
virtual void MCMCUserIterationInterface ()
 Interface allowing to execute arbitrary code for each iteration of the MCMC while running the chains after applying the lag but before filling histograms or the output tree. More...
 
virtual void MCMCCurrentPointInterface (const std::vector< double > &point, int ichain, bool accepted)
 Interface allowing to execute arbitrary code for each new point of the MCMC whether it is accepted or not. More...
 
void LoadParametersFromTree (TTree *partree, bool loadObservables=true)
 Load parameters and observables from tree. More...
 
void LoadMCMCParameters (TTree &partree)
 Load MCMC parameters from parameter tree: nchains, proposal function type, scales. More...
 
virtual bool ParameterTreeMatchesModel (TTree *partree, bool checkObservables=true)
 Check parameter tree against model. More...
 
void LoadMCMC (const std::string &filename, std::string mcmcTreeName="", std::string parameterTreeName="", bool loadObservables=true)
 Load previous MCMC run. More...
 
void LoadMCMC (TTree *mcmcTree, TTree *parTree, bool loadObservables=true)
 Load previous MCMC run. More...
 
bool ValidMCMCTree (TTree *tree, bool checkObservables=true) const
 Check tree structure for MCMC tree. More...
 
bool ValidParameterTree (TTree *tree) const
 Check tree structure for parameter tree. More...
 
void CloseOutputFile ()
 Close the root output file. More...
 
virtual void Remarginalize (bool autorange=true)
 Marginalize from TTree. More...
 
void PrepareToContinueMarginalization (const std::string &filename, const std::string &mcmcTreeName="", const std::string &parameterTreeName="", bool loadObservables=true, bool autorange=true)
 Continue the marginalization already stored in another file. More...
 
virtual bool UpdateMultivariateProposalFunctionCovariances (double a)
 Update multivariate proposal function covariances. More...
 
virtual bool UpdateMultivariateProposalFunctionCovariances ()
 Update multivariate proposal function covariances. More...
 
void CalculateCholeskyDecompositions ()
 Calculate Cholesky decompositions needed for multivariate proposal function. More...
 
void UpdateChainIndex (int chain)
 Keep track of which chain is currently computed (within a thread). More...
 
static double RValue (const std::vector< double > &means, const std::vector< double > &variances, unsigned n, bool correctForSamplingVariability=true)
 Calculate R value of set of batches of samples—represented by their means and variances, all batches containing the same number of samples—according to Brooks & Gelman, "General Methods for Monitoring Convergence of Iterative Simulations," (1988) More...
 

Detailed Description

An engine class for Markov Chain Monte Carlo.

Author
Daniel Kollar
Kevin Kröninger
Version
1.0
Date
08.2008

This class represents an engine class for Markov Chain Monte Carlo (MCMC). One or more chains can be defined simultaneously.

Definition at line 55 of file BCEngineMCMC.h.

Member Enumeration Documentation

An enumerator for markov-chain position initialization.

Enumerator
kInitCenter 

select centers of parameter ranges

kInitRandomUniform 

randomly distribute uniformly over parameter ranges

kInitUserDefined 

initialize to user-provided points

kInitRandomPrior 

randomly distribute according to factorized priors

Definition at line 82 of file BCEngineMCMC.h.

An enumerator for the phase of the Markov chain.

Negative values are in pre-run, 0 is unset, positive is main run.

Enumerator
kPreRun 

In pre-run.

kUnsetPhase 

Unset.

kMainRun 

In main run.

Definition at line 75 of file BCEngineMCMC.h.

An enumerator for the status of a test.

See BCEngineMCMC::SetPrecision for full details

Definition at line 65 of file BCEngineMCMC.h.

Constructor & Destructor Documentation

BCEngineMCMC::BCEngineMCMC ( const std::string &  name = "model")

Default constructor.

Definition at line 55 of file BCEngineMCMC.cxx.

BCEngineMCMC::BCEngineMCMC ( const BCEngineMCMC enginemcmc)

Copy constructor.

Definition at line 126 of file BCEngineMCMC.cxx.

BCEngineMCMC::BCEngineMCMC ( const std::string &  filename,
const std::string &  name,
bool  loadObservables = true 
)

Read in MCMC constructor.

Parameters
filenamePath of file holding model.
nameName of model (file should contain TTree's [name]_mcmc and [name]_parameters.
if empty string is given, properly matching TTrees are searched for in the file.
loadObservablesFlag for whether to load observables for file (true; default) or to let user respecify observables.

Definition at line 90 of file BCEngineMCMC.cxx.

BCEngineMCMC::~BCEngineMCMC ( )
virtual

Destructor.

Definition at line 301 of file BCEngineMCMC.cxx.

Member Function Documentation

bool BCEngineMCMC::AcceptOrRejectPoint ( unsigned  chain,
unsigned  parameter 
)

Accept or rejects a point for a chain and updates efficiency.

Parameters
chainchain index
parameterindex of parameter to update efficiency for
Returns
Whether proposed point was accepted (true) or previous point was kept (false).

Definition at line 1580 of file BCEngineMCMC.cxx.

virtual bool BCEngineMCMC::AddObservable ( const std::string &  name,
double  min,
double  max,
const std::string &  latexname = "",
const std::string &  unitstring = "" 
)
inlinevirtual
Deprecated:
Instead use GetObservables().Add(...) Adds a user-calculated observable.
Parameters
namename of observable
minminimum value of the observable
maxmaximum value of the observable
latexnameOptional latexname used for plotting
unitstringUnit string to be printed for observable.
Returns
Success of action.

Definition at line 1266 of file BCEngineMCMC.h.

virtual bool BCEngineMCMC::AddObservable ( BCObservable obs)
inlinevirtual
Deprecated:
Instead use GetObservables().Add(obs) Adds a user-calculated observable to the model.
Parameters
obsA user-calculated observable
Returns
Success of action.

Definition at line 1274 of file BCEngineMCMC.h.

virtual bool BCEngineMCMC::AddParameter ( const std::string &  name,
double  min,
double  max,
const std::string &  latexname = "",
const std::string &  unitstring = "" 
)
inlinevirtual
Deprecated:
Instead use GetParameters().Add(...) Adds a parameter.
Parameters
nameName of parameter
minminimum value of the parameter
maxmaximum value of the parameter
latexnameOptional latexname used for plotting
unitstringUnit string to be printed for parameter.
Returns
Success of action.

Definition at line 1246 of file BCEngineMCMC.h.

virtual bool BCEngineMCMC::AddParameter ( BCParameter parameter)
inlinevirtual
Deprecated:
Instead use GetParameters().Add(parameter) Adds a parameter to the model.
Parameters
parameterA model parameter
Returns
Success of action.

Definition at line 1254 of file BCEngineMCMC.h.

void BCEngineMCMC::CalculateCholeskyDecompositions ( )

Calculate Cholesky decompositions needed for multivariate proposal function.

Definition at line 1471 of file BCEngineMCMC.cxx.

virtual void BCEngineMCMC::CalculateObservables ( const std::vector< double > &  pars)
inlinevirtual

Evaluates user-defined observables.

To be overloaded by user to calculate user observables.

Parameters
parsParameter set to evaluate observables for.

Reimplemented in BCPriorModel.

Definition at line 1292 of file BCEngineMCMC.h.

void BCEngineMCMC::CloseOutputFile ( )

Close the root output file.

Definition at line 1744 of file BCEngineMCMC.cxx.

void BCEngineMCMC::CreateHistograms ( bool  rescale_ranges = false)
virtual

Create histograms from parameter and observable sets.

Parameters
rescale_rangesRescale axis ranges to range reached by MCMC tree if true

Definition at line 2596 of file BCEngineMCMC.cxx.

bool BCEngineMCMC::DrawParameterPlot ( unsigned  i0,
unsigned  npar = 0,
double  interval_content = 68e-2,
std::vector< double >  quantile_values = std::vector<double>(0),
bool  rescale_ranges = true 
) const

Draw a summary plot for the parameters in the range provided to current pad.

Parameters
i0Index of first parameter to print.
nparNumber of parameters to print, set to 0 to print all.
interval_contentProbability mass to display in smallest X interval band
quantile_valuesVector of quantile values to draw
rescale_rangesFlag for rescaling to range surveyed by MCMC chains
Returns
Success of action.

Definition at line 3026 of file BCEngineMCMC.cxx.

void BCEngineMCMC::EvaluateObservables ( unsigned  chain)
virtual

Evaluates user-defined observables at current state of chain and stores results in fMCMCState.

Parameters
chainChain to evaluate observables for.

Definition at line 2352 of file BCEngineMCMC.cxx.

BCH1D& BCEngineMCMC::GetBCH1DdrawingOptions ( )
inline
Returns
BCH1D object that stores drawing options for all BCH1D's.

Definition at line 739 of file BCEngineMCMC.h.

BCH2D& BCEngineMCMC::GetBCH2DdrawingOptions ( )
inline
Returns
BCH2D object that stores drawing options for all BCH2D's.

Definition at line 744 of file BCEngineMCMC.h.

const std::vector< double > & BCEngineMCMC::GetBestFitParameterErrors ( ) const
virtual
Returns
vector of standard errors (sqrt(variance)) of 1D marginals

Reimplemented in BCIntegrate.

Definition at line 639 of file BCEngineMCMC.cxx.

const std::vector< double > & BCEngineMCMC::GetBestFitParameters ( ) const
virtual
Returns
vector of parameter values at global mode.

Reimplemented in BCIntegrate.

Definition at line 633 of file BCEngineMCMC.cxx.

std::string BCEngineMCMC::GetBestFitSummary ( unsigned  i) const
protectedvirtual

Get string summarizing best fit for single variable.

Parameters
iIndex of variable to summarize.

Reimplemented in BCIntegrate.

Definition at line 2792 of file BCEngineMCMC.cxx.

const ChainState& BCEngineMCMC::GetChainState ( unsigned  c) const
inline
Parameters
cindex of the Markov chain
Returns
state of chains

Definition at line 364 of file BCEngineMCMC.h.

bool BCEngineMCMC::GetCorrectRValueForSamplingVariability ( ) const
inline

Flag for correcting convergence checking for initial sampling variability.

Definition at line 451 of file BCEngineMCMC.h.

unsigned BCEngineMCMC::GetCurrentChain ( ) const
Returns
current chain index. If no chain is currently selected (for example, not within mcmc), return 0.

Definition at line 606 of file BCEngineMCMC.cxx.

int BCEngineMCMC::GetCurrentIteration ( ) const
inline
Returns
current iterations

Definition at line 289 of file BCEngineMCMC.h.

bool BCEngineMCMC::GetFlagRun ( ) const
inline
Returns
if MCMC has been performed or not

Definition at line 456 of file BCEngineMCMC.h.

std::vector< unsigned > BCEngineMCMC::GetH1DPrintOrder ( ) const
virtual
Returns
vector indices for order of printing 1D histograms.

Definition at line 2891 of file BCEngineMCMC.cxx.

std::vector< std::pair< unsigned, unsigned > > BCEngineMCMC::GetH2DPrintOrder ( ) const
virtual
Returns
vector of index pairs for order of printing 2D histograms.

Definition at line 2902 of file BCEngineMCMC.cxx.

double BCEngineMCMC::GetHistogramRescalePadding ( ) const
inline
Returns
Factor by which to enlarge histogram ranges when rescaling to add padding beyond range.

Definition at line 497 of file BCEngineMCMC.h.

unsigned BCEngineMCMC::GetInitialPositionAttemptLimit ( ) const
inline
Returns
maximum number of allowed attempts to set the initial position

Definition at line 398 of file BCEngineMCMC.h.

BCEngineMCMC::InitialPositionScheme BCEngineMCMC::GetInitialPositionScheme ( ) const
inline
Returns
flag which defined initial position

Definition at line 393 of file BCEngineMCMC.h.

const std::vector< double > & BCEngineMCMC::GetLocalModes ( bool  force_recalculation = false)
Returns
vector of the local modes of parameters and observables
Parameters
force_recalculationflag for forcing recalculation of local modes from histograms.

Definition at line 648 of file BCEngineMCMC.cxx.

virtual double BCEngineMCMC::GetLogMaximum ( ) const
inlinevirtual
Returns
The log of the value at the mode.

Reimplemented in BCIntegrate.

Definition at line 729 of file BCEngineMCMC.h.

double BCEngineMCMC::GetLogProbx ( unsigned  c) const
inline
Returns
log of the probability of the current points of the Markov chain.
Parameters
cchain index

Definition at line 383 of file BCEngineMCMC.h.

BCH1D BCEngineMCMC::GetMarginalized ( const std::string &  name) const
inline

Obtain the individual marginalized distributions with respect to one parameter.

Note
The most efficient method is to access by index.
Parameters
nameThe parameter's name
Returns
1D marginalized probability

Definition at line 561 of file BCEngineMCMC.h.

BCH1D BCEngineMCMC::GetMarginalized ( unsigned  index) const

Obtain the individual marginalized distributions with respect to one parameter.

Parameters
indexThe parameter index
Returns
1D marginalized probability

Definition at line 573 of file BCEngineMCMC.cxx.

BCH2D BCEngineMCMC::GetMarginalized ( const std::string &  name1,
const std::string &  name2 
) const
inline

Obtain the individual marginalized distributions with respect to two parameters.

Note
The most efficient method is to access by indices.
Parameters
name1Name of first parameter
name2Name of second parameter
Returns
2D marginalized probability

Definition at line 578 of file BCEngineMCMC.h.

BCH2D BCEngineMCMC::GetMarginalized ( unsigned  index1,
unsigned  index2 
) const

Obtain the individual marginalized distributions with respect to two parameters.

Parameters
index1Index of first parameter
index2Index of second parameter
Returns
2D marginalized probability

Definition at line 587 of file BCEngineMCMC.cxx.

TH1* BCEngineMCMC::GetMarginalizedHistogram ( const std::string &  name) const
inline

Obtain the individual marginalized distributions with respect to one parameter as a ROOT TH1.

Note
The most efficient method is to access by index.
Parameters
nameThe parameter's name
Returns
1D marginalized probability

Definition at line 527 of file BCEngineMCMC.h.

TH1 * BCEngineMCMC::GetMarginalizedHistogram ( unsigned  index) const

Obtain the individual marginalized distributions with respect to one parameter as a ROOT TH1.

Parameters
indexThe parameter index
Returns
1D marginalized probability

Definition at line 528 of file BCEngineMCMC.cxx.

TH2* BCEngineMCMC::GetMarginalizedHistogram ( const std::string &  name1,
const std::string &  name2 
) const
inline

Obtain the individual marginalized distributions with respect to two parameters as a ROOT TH2.

Note
The most efficient method is to access by indices.
Parameters
name1Name of first parameter
name2Name of second parameter
Returns
2D marginalized probability

Definition at line 544 of file BCEngineMCMC.h.

TH2 * BCEngineMCMC::GetMarginalizedHistogram ( unsigned  index1,
unsigned  index2 
) const

Obtain the individual marginalized distributions with respect to two parameters as a ROOT TH2.

Parameters
index1Index of first parameter
index2Index of second parameter
Returns
2D marginalized probability

Definition at line 546 of file BCEngineMCMC.cxx.

TTree* BCEngineMCMC::GetMarkovChainTree ( ) const
inline

Retrieve the tree containing the Markov chain.

Definition at line 461 of file BCEngineMCMC.h.

double BCEngineMCMC::GetMaximumEfficiency ( ) const
inline
Returns
maximum efficiency required for a chain.

Definition at line 343 of file BCEngineMCMC.h.

unsigned BCEngineMCMC::GetMaximumParameterNameLength ( bool  observables = true) const
inline
Parameters
observablesWhether to check max length of user-defined observable names.
Returns
length of longest parameter name.

Definition at line 592 of file BCEngineMCMC.h.

double BCEngineMCMC::GetMinimumEfficiency ( ) const
inline
Returns
minimum efficiency required for a chain.

Definition at line 338 of file BCEngineMCMC.h.

unsigned BCEngineMCMC::GetMultivariateCovarianceUpdates ( ) const
inline
Returns
number of updates to multivariate-proposal-function covariance performed.

Definition at line 416 of file BCEngineMCMC.h.

double BCEngineMCMC::GetMultivariateEpsilon ( ) const
inline
Returns
multivariate-proposal-function Cholesky decomposition nudge size.

Definition at line 426 of file BCEngineMCMC.h.

double BCEngineMCMC::GetMultivariateScaleMultiplier ( ) const
inline
Returns
multivariate-proposal-function scale multiplier.

Definition at line 431 of file BCEngineMCMC.h.

const std::string& BCEngineMCMC::GetName ( ) const
inline
Returns
The name of the engine.

Definition at line 269 of file BCEngineMCMC.h.

unsigned BCEngineMCMC::GetNChains ( ) const
inline
Returns
number of Markov chains

Definition at line 279 of file BCEngineMCMC.h.

bool BCEngineMCMC::GetNewPointMetropolis ( )

Generate a new point using the Metropolis algorithm for all chains.

Returns
Whether proposed point was accepted (true) or previous point was kept (false).

Definition at line 1647 of file BCEngineMCMC.cxx.

bool BCEngineMCMC::GetNewPointMetropolis ( unsigned  chain)

Generate a new point using the Metropolis algorithm for one chain.

Parameters
chainchain index
Returns
Whether proposed point was accepted (true) or previous point was kept (false).

Definition at line 1632 of file BCEngineMCMC.cxx.

bool BCEngineMCMC::GetNewPointMetropolis ( unsigned  chain,
unsigned  parameter 
)

Generate a new point using the Metropolis algorithm for one chain, varying only one parameter's value.

Parameters
chainChain index
parameterIndex of single parameter to update.
Returns
Whether proposed point was accepted (true) or previous point was kept (false).

Definition at line 1617 of file BCEngineMCMC.cxx.

unsigned BCEngineMCMC::GetNFixedParameters ( ) const
inline
Deprecated:
Instead call GetParameters().GetNFixedParameters()
Returns
The number of fixed parameters.

Definition at line 662 of file BCEngineMCMC.h.

unsigned BCEngineMCMC::GetNFreeParameters ( ) const
inline
Deprecated:
Instead call GetParameters().GetNFreeParameters()
Returns
The number of free parameters.

Definition at line 668 of file BCEngineMCMC.h.

int BCEngineMCMC::GetNIterationsConvergenceGlobal ( ) const
inline
Returns
number of iterations needed for all chains to converge simultaneously. A value of -1 indicates that the chains did not converge during a prerun. A value of 0 indicates that chain criteria were set by hand and convergence was not checked.

Definition at line 301 of file BCEngineMCMC.h.

unsigned BCEngineMCMC::GetNIterationsPreRun ( ) const
Returns
the number of iterations the prerun actually took. If the prerun wasn't run, that's 0. Else it is bounded by GetNIterationsPreRunMin() and GetNIterationsPreRunMax().

Definition at line 622 of file BCEngineMCMC.cxx.

unsigned BCEngineMCMC::GetNIterationsPreRunCheck ( ) const
inline
Returns
number of iterations between scale adjustments and convergence checking during pre-run.

Definition at line 328 of file BCEngineMCMC.h.

unsigned BCEngineMCMC::GetNIterationsPreRunMax ( ) const
inline
Returns
maximum number of pre-run iterations for a Markov chain

Definition at line 318 of file BCEngineMCMC.h.

unsigned BCEngineMCMC::GetNIterationsPreRunMin ( ) const
inline
Returns
minimum number of pre-run iterations for a Markov chain

Definition at line 313 of file BCEngineMCMC.h.

unsigned BCEngineMCMC::GetNIterationsRun ( ) const
inline
Returns
number of iterations for a Markov chain

Definition at line 323 of file BCEngineMCMC.h.

unsigned BCEngineMCMC::GetNLag ( ) const
inline
Returns
lag of the Markov chains

Definition at line 284 of file BCEngineMCMC.h.

unsigned BCEngineMCMC::GetNObservables ( ) const
inline
Returns
The number of user-defined observables.

Definition at line 711 of file BCEngineMCMC.h.

unsigned BCEngineMCMC::GetNParameters ( ) const
inline
Returns
The number of parameters of the model.

Definition at line 656 of file BCEngineMCMC.h.

unsigned BCEngineMCMC::GetNVariables ( ) const
inline
Returns
The number of parameters of the model.

Definition at line 613 of file BCEngineMCMC.h.

BCObservable& BCEngineMCMC::GetObservable ( unsigned  index)
inline
Deprecated:
Instead call GetObservables().At(index)
Parameters
indexThe index of the observable in the observable set.
Returns
The user-defined observable.

Definition at line 685 of file BCEngineMCMC.h.

const BCObservable& BCEngineMCMC::GetObservable ( unsigned  index) const
inline
Deprecated:
Instead call GetObservbles().At(index)
Parameters
indexThe index of the observable in the observable set.
Returns
The user-defined observable.

Definition at line 692 of file BCEngineMCMC.h.

BCObservable& BCEngineMCMC::GetObservable ( const std::string &  name)
inline
Deprecated:
Instead call GetObservables().Get(name)
Parameters
nameThe name of the observable in the observable set.
Returns
The user-defined observable.

Definition at line 699 of file BCEngineMCMC.h.

const BCObservable& BCEngineMCMC::GetObservable ( const std::string &  name) const
inline
Deprecated:
Instead call GetObservables().Get(name)
Parameters
nameThe name of the observable in the observable set.
Returns
The user-defined observable.

Definition at line 706 of file BCEngineMCMC.h.

BCObservableSet& BCEngineMCMC::GetObservables ( )
inline
Returns
Observable set.

Definition at line 673 of file BCEngineMCMC.h.

const BCObservableSet& BCEngineMCMC::GetObservables ( ) const
inline
Returns
Observable set.

Definition at line 678 of file BCEngineMCMC.h.

TFile* BCEngineMCMC::GetOutputFile ( ) const
inline

Retrieve output file for MCMC.

Definition at line 471 of file BCEngineMCMC.h.

BCParameter& BCEngineMCMC::GetParameter ( unsigned  index)
inline
Deprecated:
Instead call GetParameters().At(index)
Parameters
indexThe index of the parameter in the parameter set.
Returns
The parameter.

Definition at line 630 of file BCEngineMCMC.h.

const BCParameter& BCEngineMCMC::GetParameter ( unsigned  index) const
inline
Deprecated:
Instead call GetParameters().At(index)
Parameters
indexThe index of the parameter in the parameter set.
Returns
The parameter.

Definition at line 637 of file BCEngineMCMC.h.

BCParameter& BCEngineMCMC::GetParameter ( const std::string &  name)
inline
Deprecated:
Instead call GetParameters().Get(name)
Parameters
nameThe name of the parameter in the parameter set.
Returns
The parameter.

Definition at line 644 of file BCEngineMCMC.h.

const BCParameter& BCEngineMCMC::GetParameter ( const std::string &  name) const
inline
Deprecated:
Instead call GetParameters().Get(name)
Parameters
nameThe name of the parameter in the parameter set.
Returns
The parameter.

Definition at line 651 of file BCEngineMCMC.h.

BCParameterSet& BCEngineMCMC::GetParameters ( )
inline
Returns
Parameter set.

Definition at line 618 of file BCEngineMCMC.h.

const BCParameterSet& BCEngineMCMC::GetParameters ( ) const
inline
Returns
Parameter set.

Definition at line 623 of file BCEngineMCMC.h.

TTree* BCEngineMCMC::GetParameterTree ( ) const
inline

Retrieve the tree containing the parameter information.

Definition at line 466 of file BCEngineMCMC.h.

BCEngineMCMC::Phase BCEngineMCMC::GetPhase ( ) const
inline
Returns
pointer to the phase of a run.

Definition at line 388 of file BCEngineMCMC.h.

unsigned BCEngineMCMC::GetPreRunCheckClear ( )
inline
Returns
number of iterations between clearings of statistics for convergence checking.

Definition at line 333 of file BCEngineMCMC.h.

double BCEngineMCMC::GetProposalFunctionDof ( ) const
inline
Returns
Degree of freedom of multivariate proposal function. Anything >0 is the degree of freedom of a multivariate Student's t distribution, <= 0 is a multivariate Gaussian

Definition at line 411 of file BCEngineMCMC.h.

bool BCEngineMCMC::GetProposalPointMetropolis ( unsigned  chain,
std::vector< double > &  x 
)

Return a proposal point for the Metropolis algorithm.

Parameters
chainchain index
xproposal point
Returns
flag indicating whether the new point lies within the allowed range

Definition at line 1528 of file BCEngineMCMC.cxx.

bool BCEngineMCMC::GetProposalPointMetropolis ( unsigned  chain,
unsigned  parameter,
std::vector< double > &  x 
)

Return a proposal point for the Metropolis algorithm.

Parameters
chainchain index
parameterIndex of single parameter to update.
xproposal point
Returns
flag indicating whether the new point lies within the allowed range

Definition at line 1557 of file BCEngineMCMC.cxx.

bool BCEngineMCMC::GetProposeMultivariate ( ) const
inline
Returns
whether to use a multivariate proposal function.

Definition at line 403 of file BCEngineMCMC.h.

bool BCEngineMCMC::GetRescaleHistogramRangesAfterPreRun ( ) const
inline
Returns
Flag for whether to rescale histogram ranges to fit MCMC reach after pre-run.

Definition at line 492 of file BCEngineMCMC.h.

bool BCEngineMCMC::GetReuseObservables ( ) const
inline
Returns
Flag whether to reuse user-defined observables from MCMC tree when looping through it.

Definition at line 734 of file BCEngineMCMC.h.

const std::vector<double>& BCEngineMCMC::GetRValueParameters ( ) const
inline
Returns
vector of R values for parameters

Definition at line 441 of file BCEngineMCMC.h.

double BCEngineMCMC::GetRValueParameters ( unsigned  index) const
inline
Returns
R-value for a parameter
Parameters
indexparameter index

Definition at line 447 of file BCEngineMCMC.h.

double BCEngineMCMC::GetRValueParametersCriterion ( ) const
inline
Returns
R-value criterion for parameters

Definition at line 436 of file BCEngineMCMC.h.

const std::string& BCEngineMCMC::GetSafeName ( ) const
inline
Returns
The name of the engine with spaces removed.

Definition at line 274 of file BCEngineMCMC.h.

double BCEngineMCMC::GetScaleFactorLowerLimit ( ) const
inline
Returns
proposal function scale factor lower limit

Definition at line 348 of file BCEngineMCMC.h.

const std::vector<std::vector<double> >& BCEngineMCMC::GetScaleFactors ( ) const
inline
Returns
scale factor for all parameters and chains

Definition at line 358 of file BCEngineMCMC.h.

double BCEngineMCMC::GetScaleFactorUpperLimit ( ) const
inline
Returns
proposal function scale factor upper limit

Definition at line 353 of file BCEngineMCMC.h.

const BCEngineMCMC::Statistics& BCEngineMCMC::GetStatistics ( ) const
inline

Get combined statistics for all chains.

Definition at line 476 of file BCEngineMCMC.h.

const BCEngineMCMC::Statistics& BCEngineMCMC::GetStatistics ( unsigned  c) const
inline

Get MCMC statistics for one chain.

Parameters
cChain to get statistics of.

Definition at line 482 of file BCEngineMCMC.h.

const std::vector<BCEngineMCMC::Statistics>& BCEngineMCMC::GetStatisticsVector ( ) const
inline

Get vector of MCMC statistics for each chain separately.

Definition at line 487 of file BCEngineMCMC.h.

BCVariable& BCEngineMCMC::GetVariable ( unsigned  index)
inline
Parameters
indexThe index of the variable running first over 0,...,N_parameters in the ParameterSet, and then over N_parameters,...,N_parameters+N_observables in the ObservableSet
Returns
The variable.

Definition at line 600 of file BCEngineMCMC.h.

const BCVariable& BCEngineMCMC::GetVariable ( unsigned  index) const
inline
Parameters
indexThe index of the observable running first over 0,...,N_parameters in the ParameterSet, and then over N_parameters,...,N_parameters+N_observables in the ObservableSet
Returns
The observable.

Definition at line 608 of file BCEngineMCMC.h.

const std::vector<double>& BCEngineMCMC::Getx ( unsigned  c) const
inline
Parameters
cindex of the Markov chain
Returns
current point of the Markov chain

Definition at line 370 of file BCEngineMCMC.h.

double BCEngineMCMC::Getx ( unsigned  c,
unsigned  p 
) const
inline
Parameters
cchain index
pparameter index
Returns
parameter of the Markov chain

Definition at line 377 of file BCEngineMCMC.h.

void BCEngineMCMC::InitializeMarkovChainTree ( bool  replacetree = false,
bool  replacefile = false 
)
virtual

Initialize the trees containing the Markov chains and parameter info.

Parameters
replacetreeFlag to delete and recreate tree object if already existing.
replacefileFlag to delete and recreate file object if already existing.

Reimplemented in BCModel.

Definition at line 703 of file BCEngineMCMC.cxx.

void BCEngineMCMC::LoadMCMC ( const std::string &  filename,
std::string  mcmcTreeName = "",
std::string  parameterTreeName = "",
bool  loadObservables = true 
)

Load previous MCMC run.

Parameters
filenamePathname of file containing model trees.
mcmcTreeNameName of tree inside file containing MCMC, empty string (default) loads [modelname]_mcmc.
parameterTreeNameName of tree inside file containing parameter list, empty string (default) loads [modelname]_parameters.
loadObservablesFlag for whether to load observables from parameter list and MCMC trees.

Definition at line 1138 of file BCEngineMCMC.cxx.

void BCEngineMCMC::LoadMCMC ( TTree *  mcmcTree,
TTree *  parTree,
bool  loadObservables = true 
)

Load previous MCMC run.

Parameters
mcmcTreeTree containing MCMC samples.
parTreeTree containing definition of parameters.
loadObservablesFlag for whether to load observables.

Definition at line 1218 of file BCEngineMCMC.cxx.

void BCEngineMCMC::LoadMCMCParameters ( TTree &  partree)

Load MCMC parameters from parameter tree: nchains, proposal function type, scales.

Parameters
partreeTree holding parameter information.

Definition at line 999 of file BCEngineMCMC.cxx.

void BCEngineMCMC::LoadParametersFromTree ( TTree *  partree,
bool  loadObservables = true 
)

Load parameters and observables from tree.

Parameters
partreeTree holding parameter information.
loadObservablesFlag for whether to also load observables.

Definition at line 918 of file BCEngineMCMC.cxx.

virtual double BCEngineMCMC::LogEval ( const std::vector< double > &  parameters)
pure virtual

Needs to be overloaded in the derived class.

Parameters
parametersParameter set to evaluate at.
Returns
natural logarithm of the function to map with MCMC

Implemented in BCIntegrate, and BCModel.

bool BCEngineMCMC::MarginalizedHistogramExists ( unsigned  index) const
inline
Parameters
indexIndex of histogram of which to check existence
Returns
Whether the marginalized histogram exists.

Definition at line 511 of file BCEngineMCMC.h.

bool BCEngineMCMC::MarginalizedHistogramExists ( unsigned  index1,
unsigned  index2 
) const
inline
Parameters
index1X Index of histogram of which to check existence.
index2Y Index of histogram of which to check existence.
Returns
Whether the marginalized histogram exists.

Definition at line 518 of file BCEngineMCMC.h.

virtual void BCEngineMCMC::MCMCCurrentPointInterface ( const std::vector< double > &  point,
int  ichain,
bool  accepted 
)
inlinevirtual

Interface allowing to execute arbitrary code for each new point of the MCMC whether it is accepted or not.

This method needs to be overloaded in the derived class

Note
This method is called for every call to the likelihood.
Parameters
pointpoint that was generated and checked
ichainindex of the chain
acceptedflag whether or not the point was accepted for the chain

Definition at line 1441 of file BCEngineMCMC.h.

void BCEngineMCMC::MCMCInitialize ( )

Resets all containers used in MCMC and initializes starting points.

Definition at line 2393 of file BCEngineMCMC.cxx.

virtual void BCEngineMCMC::MCMCUserInitialize ( )
inlinevirtual

User hook called from MCMCInitialize().

MCMCUserInitialize() is called after all settings for the upcoming MCMC run are fixed but before the initial point is chosen and before any call to user methods such as LogLikelihood() or LogAPrioriProbability() are issued. MCMCUserInitialize() is useful for example to allocate separate copies of objects within the user model, one per chain, for thread safety.

Note
Any error inside MCMCUserInitialize() should be signaled via an exception.

Reimplemented in BCFitter.

Definition at line 1404 of file BCEngineMCMC.h.

virtual void BCEngineMCMC::MCMCUserIterationInterface ( )
inlinevirtual

Interface allowing to execute arbitrary code for each iteration of the MCMC while running the chains after applying the lag but before filling histograms or the output tree.

With Remarginalize(), there is no lag, and MCMCUserIterationInterface() is called on every iteration before filling histograms.

In both instances of use, CalculateObservables() has already been called.

This function is not necessarily called for each call to the likelihood. Its frequency is affected by the lag; and for the factorized proposal function, it is called only after all parameters have been updated.

This method needs to be overloaded by the user to do anything.

Note
For uncertainty propagation, it is much more convenient BCObservable and CalculateObservables()

Reimplemented in BCMTF, and BCFitter.

Definition at line 1428 of file BCEngineMCMC.h.

bool BCEngineMCMC::Metropolis ( )

Runs Metropolis algorithm.

Returns
Success of action.

Definition at line 2183 of file BCEngineMCMC.cxx.

bool BCEngineMCMC::MetropolisPreRun ( )

Runs a pre run for the Metropolis algorithm.

Returns
Success of action.

Definition at line 1762 of file BCEngineMCMC.cxx.

bool BCEngineMCMC::ParameterTreeMatchesModel ( TTree *  partree,
bool  checkObservables = true 
)
virtual

Check parameter tree against model.

Parameters
partreeTree of parameters to check against model.
checkObservablesFlag for whether to check observables.
Returns
Whether tree's parameters match those of model.

Definition at line 1065 of file BCEngineMCMC.cxx.

void BCEngineMCMC::PrepareToContinueMarginalization ( const std::string &  filename,
const std::string &  mcmcTreeName = "",
const std::string &  parameterTreeName = "",
bool  loadObservables = true,
bool  autorange = true 
)

Continue the marginalization already stored in another file.

Definition at line 1419 of file BCEngineMCMC.cxx.

unsigned BCEngineMCMC::PrintAllMarginalized ( const std::string &  filename,
unsigned  hdiv = 1,
unsigned  vdiv = 1 
) const

Print all marginalizations.

Parameters
filenamePath to file to print to
hdivNumber of columns of plots per page
vdivNumber of rows of plots per page
Returns
Number of plots printed

Definition at line 2932 of file BCEngineMCMC.cxx.

void BCEngineMCMC::PrintBestFitSummary ( ) const
protectedvirtual

Print best fit to log.

Reimplemented in BCIntegrate.

Definition at line 2774 of file BCEngineMCMC.cxx.

bool BCEngineMCMC::PrintCorrelationMatrix ( const std::string &  filename = "matrix.pdf") const

Print a correlation matrix for the parameters.

Parameters
filenamePath to file to print correlation matrix to.
Returns
Success of action.

Definition at line 3278 of file BCEngineMCMC.cxx.

bool BCEngineMCMC::PrintCorrelationPlot ( const std::string &  filename = "correlation.pdf",
bool  include_observables = true 
) const

Print a correlation plot for the parameters.

Parameters
filenamePath to file to print correlation plot to.
include_observablesFlag for including observables (default: true)
Returns
Success of action.

Definition at line 3397 of file BCEngineMCMC.cxx.

void BCEngineMCMC::PrintMarginalizationSummary ( ) const
protectedvirtual

Print marginalization to log.

Reimplemented in BCIntegrate.

Definition at line 2809 of file BCEngineMCMC.cxx.

void BCEngineMCMC::PrintModelSummary ( ) const
protectedvirtual

Print model summary to log.

Definition at line 2746 of file BCEngineMCMC.cxx.

bool BCEngineMCMC::PrintParameterLatex ( const std::string &  filename) const

Print a LaTeX table of the parameters.

Parameters
filenamePath to file tp print LaTeX table of parameters to.
Returns
Success of action.

Definition at line 3533 of file BCEngineMCMC.cxx.

unsigned BCEngineMCMC::PrintParameterPlot ( const std::string &  filename,
int  npar = 10,
double  interval_content = 68e-2,
std::vector< double >  quantile_values = std::vector<double>(0),
bool  rescale_ranges = true 
) const

Print a summary plot for the parameters and user-defined observables.

Parameters
filenamePath to filename to print to.
nparNumber of parameters per page, print all on one page if set to zero or negative
interval_contentProbability mass to display in smallest X interval band
quantile_valuesVector of quantile values to draw
rescale_rangesFlag for rescaling to range surveyed by MCMC chains
Returns
Number of pages printed.

Definition at line 2986 of file BCEngineMCMC.cxx.

void BCEngineMCMC::PrintParameters ( const std::vector< double > &  P,
void(*)(const std::string &)  output = BCLog::OutSummary 
) const

Print parameters.

Parameters
Pvector of the parameter values to be printed
outputpointer to the output function to be used, which defaults to BCLog::OutSummary

Definition at line 2881 of file BCEngineMCMC.cxx.

void BCEngineMCMC::PrintSummary ( ) const
virtual

Prints a summary to the logs.

Definition at line 2736 of file BCEngineMCMC.cxx.

double BCEngineMCMC::ProposalFunction ( unsigned  ichain,
unsigned  ipar 
)
virtual

The default proposal function is a Breit-Wigner random walk.

It can be overloaded by the user to set the proposal function.

Parameters
ichainthe chain index
iparthe parameter index
Returns
the unscaled proposal point

Definition at line 1519 of file BCEngineMCMC.cxx.

void BCEngineMCMC::Remarginalize ( bool  autorange = true)
virtual

Marginalize from TTree.

Parameters
autorangeFlag for automatically choosing variable ranges to.

Definition at line 1253 of file BCEngineMCMC.cxx.

void BCEngineMCMC::ResetResults ( )
virtual

Reset the MCMC variables.

Reimplemented in BCIntegrate.

Definition at line 2364 of file BCEngineMCMC.cxx.

double BCEngineMCMC::RValue ( const std::vector< double > &  means,
const std::vector< double > &  variances,
unsigned  n,
bool  correctForSamplingVariability = true 
)
static

Calculate R value of set of batches of samples—represented by their means and variances, all batches containing the same number of samples—according to Brooks & Gelman, "General Methods for Monitoring Convergence of Iterative Simulations," (1988)

Parameters
meansVector of means of sample batches.
variancesVector of variances of samples batches.
nNumber of samples in each batch.
correctForSamplingVariabilityFlag to control correcting R value for initial sampling variability.
Returns
R value for set of batches of samples.

Definition at line 2106 of file BCEngineMCMC.cxx.

void BCEngineMCMC::SetCorrectRValueForSamplingVariability ( bool  flag = true)
inline

Set flag to correct convergence checking for initial sampling variability.

Definition at line 975 of file BCEngineMCMC.h.

void BCEngineMCMC::SetFillHistogram ( int  x,
int  y,
bool  flag 
)
protected

Set whether to fill 2D histogram y vs x: positive indices for parameters; negative for observables, starting at -1 and going more negative—observable index = -(index+1).

Parameters
xIndex of variable for horizontal axis.
yIndex of variable for vertical axis.
flagWhether to fill 2D histogram.

Definition at line 2574 of file BCEngineMCMC.cxx.

void BCEngineMCMC::SetFillHistogramObsObs ( unsigned  x,
unsigned  y,
bool  flag = true 
)
inline

Sets whether to fill particular H2 histogram: obs(y) vs.

obs(x)

Parameters
xIndex of observable for horizontal axis.
yIndex of observable for vertical axis.
flagWhether to fill histogram.

Definition at line 941 of file BCEngineMCMC.h.

void BCEngineMCMC::SetFillHistogramObsObs ( const std::string &  x,
const std::string &  y,
bool  flag = true 
)
inline

Sets whether to fill particular H2 histogram: obs(y) vs.

obs(x)

Parameters
xName of observable for horizontal axis.
yName of observable for vertical axis.
flagWhether to fill histogram.

Definition at line 948 of file BCEngineMCMC.h.

void BCEngineMCMC::SetFillHistogramObsPar ( unsigned  x,
unsigned  y,
bool  flag = true 
)
inline

Sets whether to fill particular H2 histogram: par(y) vs.

obs(x)

Parameters
xIndex of observable for horizontal axis.
yIndex of parameter for vertical axis.
flagWhether to fill histogram.

Definition at line 955 of file BCEngineMCMC.h.

void BCEngineMCMC::SetFillHistogramObsPar ( const std::string &  x,
const std::string &  y,
bool  flag = true 
)
inline

Sets whether to fill particular H2 histogram: par(y) vs.

obs(x)

Parameters
xName of observable for horizontal axis.
yName of parameter for vertical axis.
flagWhether to fill histogram.

Definition at line 962 of file BCEngineMCMC.h.

void BCEngineMCMC::SetFillHistogramParObs ( unsigned  x,
unsigned  y,
bool  flag = true 
)
inline

Sets whether to fill particular H2 histogram: obs(y) vs.

par(x)

Parameters
xIndex of parameter for horizontal axis.
yIndex of observable for vertical axis.
flagWhether to fill histogram.

Definition at line 927 of file BCEngineMCMC.h.

void BCEngineMCMC::SetFillHistogramParObs ( const std::string &  x,
const std::string &  y,
bool  flag = true 
)
inline

Sets whether to fill particular H2 histogram: obs(y) vs.

par(x)

Parameters
xName of parameter for horizontal axis.
yName of observable for vertical axis.
flagWhether to fill histogram.

Definition at line 934 of file BCEngineMCMC.h.

void BCEngineMCMC::SetFillHistogramParPar ( unsigned  x,
unsigned  y,
bool  flag = true 
)
inline

Sets whether to fill particular H2 histogram: par(y) vs.

par(x)

Parameters
xIndex of parameter for horizontal axis.
yIndex of parameter for vertical axis.
flagWhether to fill histogram.

Definition at line 913 of file BCEngineMCMC.h.

void BCEngineMCMC::SetFillHistogramParPar ( const std::string &  x,
const std::string &  y,
bool  flag = true 
)
inline

Sets whether to fill particular H2 histogram: par(y) vs.

par(x)

Parameters
xName of parameter for horizontal axis.
yName of parameter for vertical axis.
flagWhether to fill histogram.

Definition at line 920 of file BCEngineMCMC.h.

void BCEngineMCMC::SetFlagFillHistograms ( bool  flag)
inline

Sets whether to fill histograms.

Applies to 1D and 2D histogams of all parameters and observables so far added.

Definition at line 901 of file BCEngineMCMC.h.

void BCEngineMCMC::SetFlagFillHistograms ( bool  flag_1d,
bool  flag_2d 
)
inline

Sets the whether to fill histograms.

Applies to all parameters and observables so far added.

Definition at line 906 of file BCEngineMCMC.h.

void BCEngineMCMC::SetFlagPreRun ( bool  flag)
inline

Set if a (new) prerun should be performed.

Definition at line 966 of file BCEngineMCMC.h.

void BCEngineMCMC::SetHistogramRescalingPadding ( double  factor)
inline

Set enlargement factor of range for when rescaling.

Definition at line 1009 of file BCEngineMCMC.h.

void BCEngineMCMC::SetInitialPositionAttemptLimit ( unsigned  n)
inline

Sets maximum number of attempts to find a valid initial position.

Definition at line 840 of file BCEngineMCMC.h.

void BCEngineMCMC::SetInitialPositions ( const std::vector< double > &  x0s)

Sets the initial positions for all chains.

Parameters
x0sinitial positions for all chains.

Definition at line 673 of file BCEngineMCMC.cxx.

void BCEngineMCMC::SetInitialPositions ( const std::vector< std::vector< double > > &  x0s)
inline

Sets the initial positions for all chains.

Parameters
x0sinitial positions for all chains.

Definition at line 830 of file BCEngineMCMC.h.

void BCEngineMCMC::SetInitialPositionScheme ( BCEngineMCMC::InitialPositionScheme  scheme)
inline

Sets flag which defines initial position.

Definition at line 835 of file BCEngineMCMC.h.

void BCEngineMCMC::SetInitialScaleFactors ( const std::vector< double > &  scale)
inline

Set the initial scale factors for the factorized proposal function.

The same factors are used for every chain and get updated during the pre-run.

Parameters
scalea vector of doubles containing the scale factors for each parameter.

Definition at line 770 of file BCEngineMCMC.h.

void BCEngineMCMC::SetMaximumEfficiency ( double  efficiency)
inline

Sets the maximum efficiency required for a chain.

Definition at line 815 of file BCEngineMCMC.h.

void BCEngineMCMC::SetMinimumEfficiency ( double  efficiency)
inline

Sets the minimum efficiency required for a chain.

Definition at line 810 of file BCEngineMCMC.h.

void BCEngineMCMC::SetMultivariateCovarianceUpdateLambda ( double  l)
inline

Set weighting for multivariate proposal function covariance update.

value forced into [0, 1]

Definition at line 886 of file BCEngineMCMC.h.

void BCEngineMCMC::SetMultivariateEpsilon ( double  epsilon)
inline

Sets multivariate-proposal-function cholesky-decomposition nudge.

Definition at line 891 of file BCEngineMCMC.h.

void BCEngineMCMC::SetMultivariateScaleMultiplier ( double  s)
inline

Sets multivariate-proposal-function scale multiplier.

Definition at line 896 of file BCEngineMCMC.h.

void BCEngineMCMC::SetName ( const std::string &  name)

Sets the name of the engine.

Parameters
nameName of the engine

Definition at line 308 of file BCEngineMCMC.cxx.

void BCEngineMCMC::SetNbins ( unsigned int  nbins)
inline

Set the number of bins for the marginalized distribution of all parameters.

Parameters
nbinsNumber of bins

Definition at line 994 of file BCEngineMCMC.h.

void BCEngineMCMC::SetNChains ( unsigned  n)
inline

Sets the number of Markov chains which are run in parallel.

Definition at line 775 of file BCEngineMCMC.h.

void BCEngineMCMC::SetNIterationsPreRunCheck ( unsigned  n)
inline

Sets the number of iterations between scale adjustments and convergence checks in the pre-run.

Definition at line 800 of file BCEngineMCMC.h.

void BCEngineMCMC::SetNIterationsPreRunMax ( unsigned  n)
inline

Sets the maximum number of iterations in the pre-run.

Definition at line 784 of file BCEngineMCMC.h.

void BCEngineMCMC::SetNIterationsRun ( unsigned  n)
inline

Sets the number of iterations.

Definition at line 789 of file BCEngineMCMC.h.

void BCEngineMCMC::SetPrecision ( BCEngineMCMC::Precision  precision)

Set the precision for the MCMC run.

Definition at line 353 of file BCEngineMCMC.cxx.

void BCEngineMCMC::SetPrecision ( const BCEngineMCMC other)
inline

Copy precision for the MCMC run from other model.

Definition at line 984 of file BCEngineMCMC.h.

void BCEngineMCMC::SetPrecision ( const BCEngineMCMC other)

Copy precision for the MCMC run from other model.

Definition at line 410 of file BCEngineMCMC.cxx.

void BCEngineMCMC::SetPreRunCheckClear ( unsigned  n)
inline

Sets the number of prerun checks to make inbetween statistics clearing.

Definition at line 805 of file BCEngineMCMC.h.

void BCEngineMCMC::SetPrior ( unsigned  index,
TF1 &  f,
bool  logL = true 
)
Deprecated:
Instead call: GetPrarameter(index)->SetPrior(new BCTF1Prior(f)) Set prior for a parameter.
Parameters
indexThe parameter index
fA function describing the prior
logLWhether function is of log of prior (true) or just prior (false)

Definition at line 315 of file BCEngineMCMC.cxx.

void BCEngineMCMC::SetPrior ( const std::string &  name,
TF1 &  f,
bool  logL = true 
)
inline
Deprecated:
Instead call: GetParameter(name)->SetPrior(new BCTF1Prior(f)) Set prior for a parameter.
Parameters
nameThe parameter name
fA function describing the prior
logLWhether function is of log of prior (true) or just prior (false)

Definition at line 1075 of file BCEngineMCMC.h.

void BCEngineMCMC::SetPrior ( unsigned  index,
TH1 &  h,
bool  interpolate = false 
)
Deprecated:
Instead call: GetParameter(index)->SetPrior(new BCTH1Prior(h,interpolate)) Set prior for a parameter.
Parameters
indexparameter index
hhistogram describing the prior
interpolatewhether or not to use linear interpolation

Definition at line 324 of file BCEngineMCMC.cxx.

void BCEngineMCMC::SetPrior ( const std::string &  name,
TH1 &  h,
bool  interpolate = false 
)
inline
Deprecated:
Instead call: GetParameter(name)->SetPrior(new BCTH1Prior(h,interpolate)) Set prior for a parameter.
Parameters
nameparameter name
hhistogram describing the prior
interpolatewhether or not to use linear interpolation
Returns
success of action.

Definition at line 1145 of file BCEngineMCMC.h.

void BCEngineMCMC::SetPriorConstant ( unsigned  index)
inline
Deprecated:
Instead call: GetParameter(index)->SetPriorConstant() Set constant prior for this parameter
Parameters
indexthe index of the parameter

Definition at line 1051 of file BCEngineMCMC.h.

void BCEngineMCMC::SetPriorConstant ( const std::string &  name)
inline
Deprecated:
Instead call: GetParameter(name)->SetPriorConstant() Set constant prior for this parameter
Parameters
namethe name of the parameter

Definition at line 1058 of file BCEngineMCMC.h.

void BCEngineMCMC::SetPriorConstantAll ( )
inline
Deprecated:
Instead call: GetParameters().SetPriorConstantAll()

Definition at line 1150 of file BCEngineMCMC.h.

void BCEngineMCMC::SetPriorDelta ( unsigned  index,
double  value 
)
inline
Deprecated:
Instead call: GetParameter(index)->Fix(value) Fixes parameter to value.
Parameters
indexThe parameter index
valueThe position of the delta function.

Definition at line 1083 of file BCEngineMCMC.h.

void BCEngineMCMC::SetPriorDelta ( const std::string &  name,
double  value 
)
inline
Deprecated:
Instead call: GetParameter(name)->Fix(value) Fixes parameter to value.
Parameters
nameThe parameter name
valueThe position of the delta function.

Definition at line 1091 of file BCEngineMCMC.h.

void BCEngineMCMC::SetPriorGauss ( unsigned  index,
double  mean,
double  sigma 
)
Deprecated:
Instead call: GetParameter(index)->SetPrior(new BCGaussianPrior(mean,sigma)) Set Gaussian prior for a parameter.
Parameters
indexThe parameter index
meanThe mean of the Gaussian
sigmaThe sigma of the Gaussian

Definition at line 330 of file BCEngineMCMC.cxx.

void BCEngineMCMC::SetPriorGauss ( const std::string &  name,
double  mean,
double  sigma 
)
inline
Deprecated:
Instead call: GetParameter(name)->SetPrior(new BCGaussianPrior(mean,sigma)) Set Gaussian prior for a parameter.
Parameters
nameThe parameter name
meanThe mean of the Gaussian
sigmaThe sigma of the Gaussian

Definition at line 1108 of file BCEngineMCMC.h.

void BCEngineMCMC::SetPriorGauss ( unsigned  index,
double  mode,
double  sigma_below,
double  sigma_above 
)
Deprecated:
Instead call: GetParameter(index)->SetPrior(new BCSplitGaussianPrior(mode,sigma_below,sigma_above)) Set Gaussian prior for a parameter with two different widths.
Parameters
indexThe parameter index
modeThe mode of the Gaussian
sigma_belowStandard deviation below mode.
sigma_aboveStandard deviation above mode.

Definition at line 336 of file BCEngineMCMC.cxx.

void BCEngineMCMC::SetPriorGauss ( const std::string &  name,
double  mode,
double  sigma_below,
double  sigma_above 
)
inline
Deprecated:
Instead call: GetParameter(name)->SetPrior(new BCSplitGaussianPrior(mode,sigma_below,sigma_above)) Set Gaussian prior for a parameter with two different widths.
Parameters
nameThe parameter name
modeThe mode of the Gaussian
sigma_belowStandard deviation below mode.
sigma_aboveStandard deviation above mode.

Definition at line 1127 of file BCEngineMCMC.h.

void BCEngineMCMC::SetProposalFunctionDof ( double  dof = 1)
inline

Set the degree of freedom of the proposal function for MCMC.

The default dof == 1 represents a Cauchy distribution. For any positive value of dof, a Student's t distribution with the corresponding degree of freedom is used. For dof <= 0, a Gaussian is used.

A small positive degree of freedom leads to fat tails in the proposal. This makes it easier to make a large jump in a single iteration but generally leads to a lower acceptance rate being optimal.

Definition at line 878 of file BCEngineMCMC.h.

void BCEngineMCMC::SetProposeMultivariate ( bool  flag)
inline

Set flag to true to turn on the multivariate proposal for MCMC based on (Haario et al., 2001) where the covariance is learned from the prerun.

If flag == false, use a factorized proposal in which every parameter is varied individually, one after the other. This means for N parameters, N calls to the target density occur until every parameter has been (attempted to be) varied exactly once. In contrast, with the multivariate proposal all parameters are varied simultaneously and a move can occur for a single call to the target density.

For both multivariate and factorized proposal, the acceptance rate of the Markov chain is tuned to lie within the limits given by SetMinimumEfficiency() and SetMaximumEfficiency().

Definition at line 859 of file BCEngineMCMC.h.

void BCEngineMCMC::SetRescaleHistogramRangesAfterPreRun ( bool  flag = true)
inline

Set flag for rescaling histogram ranges after pre-run.

Definition at line 1004 of file BCEngineMCMC.h.

void BCEngineMCMC::SetReuseObservables ( bool  flag)
inline
Parameters
flagFlag whether to reuse user-defined observables from MCMC tree when looping through it.

Definition at line 999 of file BCEngineMCMC.h.

void BCEngineMCMC::UpdateChainIndex ( int  chain)

Keep track of which chain is currently computed (within a thread).

Warning
Call this method only if you know what you are doing!

Definition at line 3750 of file BCEngineMCMC.cxx.

unsigned BCEngineMCMC::UpdateFrequency ( unsigned  N) const
protected

return appropriate update interval

Parameters
Ntotal number of iterations to be accomplished.
Returns
Appropriate interval to output after.

Definition at line 3639 of file BCEngineMCMC.cxx.

bool BCEngineMCMC::UpdateMultivariateProposalFunctionCovariances ( double  a)
virtual

Update multivariate proposal function covariances.

Parameters
aupdate control factor.

Definition at line 1431 of file BCEngineMCMC.cxx.

bool BCEngineMCMC::UpdateMultivariateProposalFunctionCovariances ( )
virtual

Update multivariate proposal function covariances.

Definition at line 1459 of file BCEngineMCMC.cxx.

void BCEngineMCMC::UpdateParameterTree ( )
protected

Update Paramater TTree with scales and efficiencies.

Definition at line 817 of file BCEngineMCMC.cxx.

bool BCEngineMCMC::ValidMCMCTree ( TTree *  tree,
bool  checkObservables = true 
) const

Check tree structure for MCMC tree.

Parameters
treeMCMC Tree to check validity of.
checkObservablesFlag for whether to check observables.
Returns
Validity of tree.

Definition at line 874 of file BCEngineMCMC.cxx.

bool BCEngineMCMC::ValidParameterTree ( TTree *  tree) const

Check tree structure for parameter tree.

Parameters
treeParameter tree to check validity of.
Returns
Validty of tree.

Definition at line 894 of file BCEngineMCMC.cxx.

void BCEngineMCMC::WriteMarginalizedDistributions ( const std::string &  filename,
const std::string &  option,
bool  closeExistingFile = false 
)

Write marginalization histograms to file.

Parameters
filenamePath to write file to.
optionOptions passed to ROOT's TFile::Open.
closeExistingFileif file is already open, whether to close it after writing.

Definition at line 464 of file BCEngineMCMC.cxx.

void BCEngineMCMC::WriteMarkovChain ( bool  flag)
inline

Turn on/off writing of Markov chain to root file.

If setting true, you must first set filename with function with filename arguments.

Parameters
flagFlag for writing Markov chain (run and prerun) to ROOT file.

Definition at line 1016 of file BCEngineMCMC.h.

void BCEngineMCMC::WriteMarkovChain ( const std::string &  filename,
const std::string &  option,
bool  flag_run = true,
bool  flag_prerun = true 
)

Turn on writing of Markov chain to root file.

Parameters
filenameName of file to write chain to.
optionfile-open options (TFile), must be "NEW", "CREATE", "RECREATE", or "UPDATE" (i.e. writeable).
flag_runFlag for writing run Markov chain to ROOT file (true) or not (false).
flag_prerunFlag for writing prerun Markov chain to ROOT file (true) or not (false).

Definition at line 446 of file BCEngineMCMC.cxx.

void BCEngineMCMC::WriteMarkovChainPreRun ( bool  flag)

Turn on/off writing of Markov chain to root file during prerun.

If setting either true, you must first set filename with function with filename arguments.

Parameters
flagFlag for writing prerun Markov chain to ROOT file (true) or not (false).

Definition at line 438 of file BCEngineMCMC.cxx.

void BCEngineMCMC::WriteMarkovChainRun ( bool  flag)

Turn on/off writing of Markov chain to root file during run.

If setting either true, you must first set filename with function with filename arguments.

Parameters
flagFlag for writing run Markov chain to ROOT file (true) or not (false).

Definition at line 430 of file BCEngineMCMC.cxx.

Member Data Documentation

BCH1D BCEngineMCMC::fBCH1DdrawingOptions
protected

A BCH1D (with no histogram) for storing BCH1D drawing options.

Definition at line 1817 of file BCEngineMCMC.h.

BCH2D BCEngineMCMC::fBCH2DdrawingOptions
protected

A BCH2D (with no histogram) for storing BCH2D drawing options.

Definition at line 1821 of file BCEngineMCMC.h.

bool BCEngineMCMC::fCorrectRValueForSamplingVariability
protected

flag for correcting R value for initial sampling variability.

Definition at line 1760 of file BCEngineMCMC.h.

std::vector<std::vector<TH2*> > BCEngineMCMC::fH2Marginalized
protected

Vector of 2D marginalized distributions.

Definition at line 1779 of file BCEngineMCMC.h.

double BCEngineMCMC::fHistogramRescalePadding
protected

factor for enlarging range of histograms when rescaling.

Definition at line 1829 of file BCEngineMCMC.h.

unsigned BCEngineMCMC::fInitialPositionAttemptLimit
protected

Maximum number of attempts to make to set the initial position.

Definition at line 1731 of file BCEngineMCMC.h.

BCEngineMCMC::InitialPositionScheme BCEngineMCMC::fInitialPositionScheme
protected

Variable which defines the initial position.

See enum MCMCInitialPosition for possible values.

Definition at line 1727 of file BCEngineMCMC.h.

std::vector<double> BCEngineMCMC::fLocalModes
protected

Vector of local modes.

Definition at line 1813 of file BCEngineMCMC.h.

int BCEngineMCMC::fMCMCCurrentIteration
protected

The current iteration number.

If not called within the running of the algorithm, return -1.

Definition at line 1618 of file BCEngineMCMC.h.

std::vector<std::vector<double> > BCEngineMCMC::fMCMCInitialPosition
protected

The intial position of each Markov chain.

The length of the vectors is equal to fMCMCNChains * fMCMCNParameters. First, the values of the first Markov chain are saved, then those of the second and so on

Definition at line 1714 of file BCEngineMCMC.h.

std::vector<double> BCEngineMCMC::fMCMCInitialScaleFactors
protected

User-provided initial values of the scale factors of the factorized proposal function.

Definition at line 1682 of file BCEngineMCMC.h.

unsigned BCEngineMCMC::fMCMCNIterationsPreRunCheck
protected

Number of iterations between scale adjustments and convergence checks in pre-run.

Definition at line 1623 of file BCEngineMCMC.h.

TFile* BCEngineMCMC::fMCMCOutputFile
protected

Output file for for writing MCMC Tree.

Definition at line 1656 of file BCEngineMCMC.h.

std::string BCEngineMCMC::fMCMCOutputFilename
protected

Output filename for for writing MCMC Tree.

Definition at line 1660 of file BCEngineMCMC.h.

std::string BCEngineMCMC::fMCMCOutputFileOption
protected

Output file open option for for writing MCMC Tree.

Definition at line 1664 of file BCEngineMCMC.h.

BCEngineMCMC::Phase BCEngineMCMC::fMCMCPhase
protected

The phase of the run.

Definition at line 1744 of file BCEngineMCMC.h.

unsigned BCEngineMCMC::fMCMCPreRunCheckClear
protected

Number of iterations between clearing of convergence stats in pre-run.

Definition at line 1627 of file BCEngineMCMC.h.

double BCEngineMCMC::fMCMCProposalFunctionDof
protected

Degree of freedom of Student's t proposal.

If <= 0, use Gaussian proposal.

Definition at line 1740 of file BCEngineMCMC.h.

std::vector<std::vector<double> > BCEngineMCMC::fMCMCProposalFunctionScaleFactor
protected

Scale factors for proposal functions.

First index is for the chain, second index is for the parameters (if not using Multivariate proposal function).

Definition at line 1678 of file BCEngineMCMC.h.

bool BCEngineMCMC::fMCMCProposeMultivariate
protected

Flag for using multivariate proposal function.

Definition at line 1735 of file BCEngineMCMC.h.

std::vector<ChainState> BCEngineMCMC::fMCMCStates
protected

The current states of each Markov chain.

Definition at line 1748 of file BCEngineMCMC.h.

std::vector<BCEngineMCMC::Statistics> BCEngineMCMC::fMCMCStatistics
protected

Statistics for each Markov chain.

Definition at line 1752 of file BCEngineMCMC.h.

BCEngineMCMC::Statistics BCEngineMCMC::fMCMCStatistics_AllChains
protected

Statistics across all Markov chains.

Definition at line 1756 of file BCEngineMCMC.h.

TTree* BCEngineMCMC::fMCMCTree
protected

The tree containing the Markov chains.

Definition at line 1789 of file BCEngineMCMC.h.

bool BCEngineMCMC::fMCMCTreeLoaded
protected

flag for whether MCMC Tree successfully loaded.

Definition at line 1793 of file BCEngineMCMC.h.

bool BCEngineMCMC::fMCMCTreeReuseObservables
protected

flag for whether to reuse MCMC Tree's observables.

Definition at line 1797 of file BCEngineMCMC.h.

double BCEngineMCMC::fMultivariateCovarianceUpdateLambda
protected

weighting parameter for multivariate-proposal-function covariance update.

Definition at line 1699 of file BCEngineMCMC.h.

unsigned BCEngineMCMC::fMultivariateCovarianceUpdates
protected

Number of multivariate-proposal-function covariance updates performed.

Definition at line 1695 of file BCEngineMCMC.h.

double BCEngineMCMC::fMultivariateEpsilon
protected

multivariate-proposal-function cholesky-decomposition nudge.

Definition at line 1703 of file BCEngineMCMC.h.

std::vector<TMatrixD> BCEngineMCMC::fMultivariateProposalFunctionCholeskyDecomposition
protected

Cholesky decompositions for multivariate proposal function.

Index is over chain.

Definition at line 1691 of file BCEngineMCMC.h.

std::vector<TMatrixDSym> BCEngineMCMC::fMultivariateProposalFunctionCovariance
protected

Covariance matrices used in multivariate proposal functions.

Definition at line 1686 of file BCEngineMCMC.h.

double BCEngineMCMC::fMultivariateScaleMultiplier
protected

factor to multiply or divide scale factors by in adjusting multivariate-proposal-function scales.

Definition at line 1707 of file BCEngineMCMC.h.

std::string BCEngineMCMC::fName
protected

Name of the engine.

Definition at line 1593 of file BCEngineMCMC.h.

TTree* BCEngineMCMC::fParameterTree
protected

The tree containing the parameter information.

Definition at line 1809 of file BCEngineMCMC.h.

std::vector<std::pair<int, int> > BCEngineMCMC::fRequestedH2
protected

Vector of pairs of indices for which 2D histograms should be stored.

a negative index indicates an observable, with observable zero as -1, observable one as -2, etc.

Definition at line 1785 of file BCEngineMCMC.h.

bool BCEngineMCMC::fRescaleHistogramRangesAfterPreRun
protected

flag for rescaling of histograms after pre-run.

Definition at line 1825 of file BCEngineMCMC.h.

std::string BCEngineMCMC::fSafeName
protected

Safe name of the engine for use in naming ROOT objects.

Definition at line 1597 of file BCEngineMCMC.h.


The documentation for this class was generated from the following files: