16 #ifndef ROOSTATS_MarkovChain    19 #ifndef RooStats_MCMCInterval    22 #ifndef RooStats_RooStatsUtils    36 #ifndef ROO_GLOBAL_FUNC    48 #ifndef ROO_MSG_SERVICE    70 MetropolisHastings::MetropolisHastings()
    84    fFunction = &
function;
    86    SetProposalFunction(proposalFunction);
    95    if (fParameters.getSize() == 0 || !fPropFunc || !fFunction) {
    96       coutE(
Eval) << 
"Critical members unintialized: parameters, proposal " <<
    97                      " function, or (log) likelihood function" << endl;
   100    if (fSign == kSignUnset || 
fType == kTypeUnset) {
   101       coutE(
Eval) << 
"Please set type and sign of your function using "   102          << 
"MetropolisHastings::SetType() and MetropolisHastings::SetSign()" <<
   107    if (fChainParams.getSize() == 0) fChainParams.add(fParameters);
   121    Double_t xL = 0.0, xPrimeL = 0.0, 
a = 0.0;
   138    bool hadEvalError = 
true;
   148    while (i < 1000 && hadEvalError) {
   151       xL = fFunction->getVal();
   158             hadEvalError = 
false;
   159       } 
else if (
fType == kRegular) {
   163             hadEvalError = 
false;
   166          hadEvalError = 
false;
   170       coutE(
Eval) << 
"Problem finding a good starting point in " <<
   171                      "MetropolisHastings::ConstructChain() " << endl;
   178    for (i = 0; i < fNumIters; i++) {
   180       hadEvalError = 
false;
   185       fPropFunc->Propose(xPrime, x);
   188       xPrimeL = fFunction->getVal();
   191       if (fFunction->numEvalErrors() > 0 && 
fType == kLog) {
   193          fFunction->clearEvalErrorLog();
   203          if (fSign == kPositive)
   212       if (!hadEvalError && !fPropFunc->IsSymmetric(xPrime, x)) {
   213          Double_t xPrimePD = fPropFunc->GetProposalDensity(xPrime, x);
   214          Double_t xPD      = fPropFunc->GetProposalDensity(x, xPrime);
   215          if (
fType == kRegular)
   221       if (!hadEvalError && ShouldTakeStep(
a)) {
   246    coutI(
Eval) << 
"Proposal acceptance rate: " <<
   247                    numAccepted/(
Float_t)fNumIters * 100 << 
"%" << endl;
   248    coutI(
Eval) << 
"Number of steps in chain: " << numAccepted << endl;
   259    if ((
fType == kLog && a <= 0.0) || (
fType == kRegular && a >= 1.0)) {
   273          if (-1.0 * rand >= a)
   293       if (fSign == kNegative)
   298       if (fSign == kPositive)
 
ProposalFunction is an interface for all proposal functions that would be used with a Markov Chain Mo...
 
void SetParameters(const RooArgSet *desiredVals, RooArgSet *paramsToChange)
 
RooFit::MsgLevel globalKillBelow() const
 
static void clearEvalErrorLog()
Clear the stack of evaluation error messages. 
 
virtual Int_t Size() const
get the number of steps in the chain 
 
static RooMsgService & instance()
Return reference to singleton instance. 
 
This class uses the Metropolis-Hastings algorithm to construct a Markov Chain of data points using Mo...
 
static void setEvalErrorLoggingMode(ErrorLoggingMode m)
Set evaluation error logging mode. 
 
void SetParameters(TFitEditor::FuncParams_t &pars, TF1 *func)
Restore the parameters from pars into the function. 
 
virtual void Add(RooArgSet &entry, Double_t nllValue, Double_t weight=1.0)
safely add an entry to the chain 
 
virtual void addClone(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling addOwned() for each element in the source...
 
static Int_t numEvalErrors()
Return the number of logged evaluation errors since the last clearing. 
 
static Double_t infinity()
Return internal infinity representation. 
 
void setGlobalKillBelow(RooFit::MsgLevel level)
 
void RandomizeCollection(RooAbsCollection &set, Bool_t randomizeConstants=kTRUE)
 
Stores the steps in a Markov Chain of points. 
 
Namespace for the RooStats classes. 
 
static Double_t uniform(TRandom *generator=randomGenerator())
Return a number uniformly distributed from (0,1) 
 
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
 
virtual void SetParameters(RooArgSet ¶meters)
set which of your parameters this chain should store 
 
Mother of all ROOT objects.