70 : fFunction(&function), fNumIters(numIters)
81 coutE(
Eval) <<
"Critical members uninitialized: parameters, proposal " <<
82 " function, or (log) likelihood function" << endl;
86 coutE(
Eval) <<
"Please set type and sign of your function using "
87 <<
"MetropolisHastings::SetType() and MetropolisHastings::SetSign()" <<
107 double xPrimeL = 0.0;
125 bool hadEvalError =
true;
135 while (i < 1000 && hadEvalError) {
145 hadEvalError =
false;
150 hadEvalError =
false;
154 hadEvalError =
false;
160 coutE(
Eval) <<
"Problem finding a good starting point in " <<
161 "MetropolisHastings::ConstructChain() " << endl;
170 hadEvalError =
false;
238 coutI(
Eval) <<
"Proposal acceptance rate: " <<
240 coutI(
Eval) <<
"Number of steps in chain: " << numAccepted << endl;
264 rand = std::log(rand);
267 if (-1.0 * rand >=
a) {
298 return -1.0 * std::log(xL);
300 return -1.0 * std::log(-xL);
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
virtual RooAbsArg * addClone(const RooAbsArg &var, bool silent=false)
Add a clone of the specified argument to list.
Abstract base class for objects that represent a real value and implements functionality common to al...
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
static Int_t numEvalErrors()
Return the number of logged evaluation errors since the last clearing.
static void setEvalErrorLoggingMode(ErrorLoggingMode m)
Set evaluation error logging mode.
static void clearEvalErrorLog()
Clear the stack of evaluation error messages.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
static RooMsgService & instance()
Return reference to singleton instance.
void setGlobalKillBelow(RooFit::MsgLevel level)
RooFit::MsgLevel globalKillBelow() const
static constexpr double infinity()
Return internal infinity representation.
static double uniform(TRandom *generator=randomGenerator())
Return a number uniformly distributed from (0,1)
Stores the steps in a Markov Chain of points.
virtual void Add(RooArgSet &entry, double nllValue, double weight=1.0)
safely add an entry to the chain
virtual void SetParameters(RooArgSet ¶meters)
set which of your parameters this chain should store
virtual Int_t Size() const
get the number of steps in the chain
This class uses the Metropolis-Hastings algorithm to construct a Markov Chain of data points using Mo...
RooArgSet fParameters
RooRealVars that define all parameter space.
virtual void SetProposalFunction(ProposalFunction &proposalFunction)
set the proposal function for suggesting new points for the MCMC
Int_t fNumIters
number of iterations to run metropolis algorithm
MetropolisHastings()=default
default constructor
RooAbsReal * fFunction
function that will generate likelihood values
virtual void SetParameters(const RooArgSet &set)
specify all the parameters of interest in the interval
virtual MarkovChain * ConstructChain()
main purpose of MetropolisHastings - run Metropolis-Hastings algorithm to generate Markov Chain of po...
enum FunctionType fType
whether the likelihood is on a regular, log, (or other) scale
enum FunctionSign fSign
whether the likelihood is negative (like NLL) or positive
RooArgSet fChainParams
RooRealVars that are stored in the chain.
virtual bool ShouldTakeStep(double d)
virtual double CalcNLL(double xL)
ProposalFunction * fPropFunc
Proposal function for MCMC integration.
ProposalFunction is an interface for all proposal functions that would be used with a Markov Chain Mo...
virtual void Propose(RooArgSet &xPrime, RooArgSet &x)=0
Populate xPrime with the new proposed point, possibly based on the current point x.
virtual double GetProposalDensity(RooArgSet &x1, RooArgSet &x2)=0
Return the probability of proposing the point x1 given the starting point x2.
virtual bool IsSymmetric(RooArgSet &x1, RooArgSet &x2)=0
Determine whether or not the proposal density is symmetric for points x1 and x2 - that is,...
Mother of all ROOT objects.
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
MsgLevel
Verbosity level for RooMsgService::StreamConfig in RooMsgService.
Namespace for the RooStats classes.
void SetParameters(const RooArgSet *desiredVals, RooArgSet *paramsToChange)
void RandomizeCollection(RooAbsCollection &set, bool randomizeConstants=true)
assuming all values in set are RooRealVars, randomize their values
Double_t Log(Double_t x)
Returns the natural logarithm of x.