/usr/include/root/RooStats/MetropolisHastings.h is in libroot-roofit-dev 5.34.30-0ubuntu8.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | // @(#)root/roostats:$Id$
// Authors: Kevin Belasco 17/06/2009
// Authors: Kyle Cranmer 17/06/2009
/*************************************************************************
* Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifndef ROOSTATS_MetropolisHastings
#define ROOSTATS_MetropolisHastings
#ifndef RooStats_RooStatsUtils
#include "RooStats/RooStatsUtils.h"
#endif
#ifndef ROOT_Rtypes
#include "Rtypes.h"
#endif
#ifndef ROOT_TObject
#include "TObject.h"
#endif
#ifndef ROO_ARG_SET
#include "RooArgSet.h"
#endif
#ifndef ROOSTATS_ProposalFunction
#include "RooStats/ProposalFunction.h"
#endif
#ifndef ROOSTATS_MarkovChain
#include "RooStats/MarkovChain.h"
#endif
namespace RooStats {
class MetropolisHastings : public TObject {
public:
enum FunctionSign {kNegative, kPositive, kSignUnset};
enum FunctionType {kRegular, kLog, kTypeUnset};
// default constructor
MetropolisHastings();
// alternate constructor
MetropolisHastings(RooAbsReal& function, const RooArgSet& paramsOfInterest,
ProposalFunction& proposalFunction, Int_t numIters);
virtual ~MetropolisHastings() {}
// main purpose of MetropolisHastings - run Metropolis-Hastings
// algorithm to generate Markov Chain of points in the parameter space
virtual MarkovChain* ConstructChain();
// specify the parameters to store in the chain
// if not specified all of them will be stored
virtual void SetChainParameters(const RooArgSet& set)
{ fChainParams.removeAll(); fChainParams.add(set); RemoveConstantParameters(&fChainParams); }
// specify all the parameters of interest in the interval
virtual void SetParameters(const RooArgSet& set)
{ fParameters.removeAll(); fParameters.add(set); RemoveConstantParameters(&fParameters); }
// set the proposal function for suggesting new points for the MCMC
virtual void SetProposalFunction(ProposalFunction& proposalFunction)
{ fPropFunc = &proposalFunction; }
// set the number of iterations to run the metropolis algorithm
virtual void SetNumIters(Int_t numIters)
{ fNumIters = numIters; }
// set the number of steps in the chain to discard as burn-in,
// starting from the first
virtual void SetNumBurnInSteps(Int_t numBurnInSteps)
{ fNumBurnInSteps = numBurnInSteps; }
// set the (likelihood) function
virtual void SetFunction(RooAbsReal& function) { fFunction = &function; }
// set the sign of the function
virtual void SetSign(enum FunctionSign sign) { fSign = sign; }
// set the type of the function
virtual void SetType(enum FunctionType type) { fType = type; }
protected:
RooAbsReal* fFunction; // function that will generate likelihood values
RooArgSet fParameters; // RooRealVars that define all parameter space
RooArgSet fChainParams; // RooRealVars that are stored in the chain
ProposalFunction* fPropFunc; // Proposal function for MCMC integration
Int_t fNumIters; // number of iterations to run metropolis algorithm
Int_t fNumBurnInSteps; // number of iterations to discard as burn-in, starting from the first
enum FunctionSign fSign; // whether the likelihood is negative (like NLL) or positive
enum FunctionType fType; // whether the likelihood is on a regular, log, (or other) scale
// whether we should take the step, based on the value of d, fSign, fType
virtual Bool_t ShouldTakeStep(Double_t d);
virtual Double_t CalcNLL(Double_t xL);
ClassDef(MetropolisHastings,2) // Markov Chain Monte Carlo calculator for Bayesian credible intervals
};
}
#endif
|