# class RooStats::MCMCInterval: public RooStats::ConfInterval




MCMCInterval is a concrete implementation of the RooStats::ConfInterval interface. It takes as input Markov Chain of data points in the parameter space generated by Monte Carlo using the Metropolis algorithm. From the Markov Chain, the confidence interval can be determined in two ways:

Using a Kernel-Estimated PDF: (not the default method)

A RooNDKeysPdf is constructed from the data set using adaptive kernel width. With this RooNDKeysPdf F, we then integrate over the most likely domain in the parameter space (tallest points in the posterior RooNDKeysPdf) until the target confidence level is reached within an acceptable neighborhood as defined by SetEpsilon(). More specifically: we calculate the following for different cutoff values C until we reach the target confidence level: \int_{ F >= C } F d{normset}. Important note: this is not the default method because of a bug in constructing the RooNDKeysPdf from a weighted data set. Configure to use this method by calling SetUseKeys(true), and the data set will be interpreted without weights.

Using a binned data set: (the default method)

This is the binned analog of the continuous integrative method that uses the kernel-estimated PDF. The points in the Markov Chain are put into a binned data set and the interval is then calculated by adding the heights of the bins in decreasing order until the desired level of confidence has been reached. Note that this means the actual confidence level is >= the confidence level prescribed by the client (unless the user calls SetHistStrict(kFALSE)). This method is the default but may not remain as such in future releases, so you may wish to explicitly configure to use this method by calling SetUseKeys(false)

These are not the only ways for the confidence interval to be determined, and other possibilities are being considered being added, especially for the 1-dimensional case.

One can ask an MCMCInterval for the lower and upper limits on a specific parameter of interest in the interval. Note that this works better for some distributions (ones with exactly one local maximum) than others, and sometimes has little value.





## Function Members (Methods)

public:
protected:
 virtual Double_t CalcConfLevel(Double_t cutoff, Double_t full) virtual void CreateDataHist() virtual void CreateHist() virtual void CreateKeysDataHist() virtual void CreateKeysPdf() virtual void CreateSparseHist() virtual void DetermineByDataHist() virtual void DetermineByHist() virtual void DetermineByKeys() virtual void DetermineBySparseHist() virtual void DetermineInterval() virtual void TObject::DoError(int level, const char* location, const char* fmt, va_list va) const void TObject::MakeZombie()
private:
 Bool_t AcceptableConfLevel(Double_t confLevel)

## Data Members

public:
 enum { DEFAULT_NUM_BINS }; enum TObject::EStatusBits { kCanDelete kMustCleanup kObjInCanvas kIsReferenced kHasUUID kCannotPick kNoContextMenu kInvalidObject }; enum TObject::[unnamed] { kIsOnHeap kNotDeleted kZombie kBitMask kSingleKey kOverwrite kWriteDelete };
protected:
 RooRealVar** fAxes array of pointers to RooRealVars representing RooStats::MarkovChain* fChain the markov chain Double_t fConfidenceLevel Requested confidence level (eg. 0.95 for 95% CL) RooRealVar* fCutoffVar cutoff variable to use for integrating keys pdf RooDataHist* fDataHist the binned Markov Chain data Int_t fDimension number of variables Double_t fEpsilon acceptable error for Keys interval determination Double_t fFull Value of intergral of fProduct RooStats::Heavyside* fHeavyside the Heavyside function TH1* fHist the binned Markov Chain data Double_t fHistConfLevel the actual conf level determined by hist Double_t fHistCutoff cutoff bin size to be in interval Double_t fIntervalSum sum of heights of bins in the interval Bool_t fIsHistStrict whether the specified confidence level is a floor Double_t fKeysConfLevel the actual conf level determined by keys Double_t fKeysCutoff cutoff keys pdf value to be in interval RooDataHist* fKeysDataHist data hist representing product RooNDKeysPdf* fKeysPdf the kernel estimation pdf TString TNamed::fName object identifier Int_t fNumBurnInSteps number of steps to discard as burn in, starting from the first RooArgSet fParameters parameters of interest for this interval RooProduct* fProduct the (keysPdf * heavyside) product THnSparse* fSparseHist the binned Markov Chain data TString TNamed::fTitle object title Bool_t fUseKeys whether to use kernel estimation Bool_t fUseSparseHist whether to use sparse hist (vs. RooDataHist)

## Function documentation

MCMCInterval(const char* name)
MCMCInterval(const char* name, const RooArgSet& parameters, RooStats::MarkovChain& chain)

 destructor

Bool_t IsInInterval(const RooArgSet& point) const
void SetConfidenceLevel(Double_t cl)
void SetAxes(RooArgList& axes)
void CreateKeysPdf()
 kbelasco: check here for memory leak.  does RooNDKeysPdf use
the RooArgList passed to it or does it make a clone?
also check for memory leak from chain, does RooNDKeysPdf clone that?

void CreateHist()
void CreateSparseHist()
void CreateDataHist()
void SetParameters(const RooArgSet& parameters)
void DetermineInterval()
void DetermineByKeys()
void DetermineByHist()
void DetermineBySparseHist()
void DetermineByDataHist()
Double_t GetSumOfWeights() const
Double_t LowerLimit(RooRealVar& param)
Double_t UpperLimit(RooRealVar& param)
Double_t LowerLimitByHist(RooRealVar& param)
Double_t UpperLimitByHist(RooRealVar& param)

Double_t LowerLimitByKeys(RooRealVar& param)
Double_t UpperLimitByKeys(RooRealVar& param)
Double_t CalcConfLevel(Double_t cutoff, Double_t full)
RooArgSet* GetParameters() const
 returns list of parameters

Bool_t AcceptableConfLevel(Double_t confLevel)
void CreateKeysDataHist()
Bool_t CheckParameters(const RooArgSet& point) const
 check that the parameters are correct

explicit MCMCInterval(const char* name = 0)
 default constructor

Double_t ConfidenceLevel() const
 get the desired confidence level (see GetActualConfidenceLevel())

{return fConfidenceLevel;}
void SetHistStrict(Bool_t isHistStrict)
 whether the specified confidence level is a floor for the actual
confidence level (strict), or a ceiling (not strict)

{ fIsHistStrict = isHistStrict; }
void SetChain(RooStats::MarkovChain& chain)
 Set the MarkovChain that this interval is based on

{ fChain = &chain; }

 return a list of RooRealVars representing the axes
you own the returned RooArgList

void SetNumBurnInSteps(Int_t numBurnInSteps)
 set the number of steps in the chain to discard as burn-in,
starting from the first

{ fNumBurnInSteps = numBurnInSteps; }
void SetUseKeys(Bool_t useKeys)
 set whether to use kernel estimation to determine the interval

{ fUseKeys = useKeys; }
void SetUseSparseHist(Bool_t useSparseHist)
 set whether to use a sparse histogram.  you MUST also call
SetUseKeys(kFALSE) to use a histogram.

{ fUseSparseHist = useSparseHist; }

 get whether we used kernel estimation to determine the interval

{ return fUseKeys; }

 get the number of steps in the chain to disard as burn-in,
get the number of steps in the chain to disard as burn-in,
starting from the first

{ return fNumBurnInSteps; }
Int_t GetDimension() const
 Get the number of parameters of interest in this interval

{ return fDimension; }
const MarkovChain* GetChain()
 Get the markov chain on which this interval is based
You do not own the returned MarkovChain*

{ return fChain; }
RooDataSet* GetChainAsDataSet(RooArgSet* whichVars = NULL)
 Get a clone of the markov chain on which this interval is based
as a RooDataSet.  You own the returned RooDataSet*

{ return fChain->GetAsDataSet(whichVars); }
const RooDataSet* GetChainAsConstDataSet()
 Get the markov chain on which this interval is based
as a RooDataSet.  You do not own the returned RooDataSet*

{ return fChain->GetAsConstDataSet(); }
RooDataHist* GetChainAsDataHist(RooArgSet* whichVars = NULL)
 Get a clone of the markov chain on which this interval is based
as a RooDataHist.  You own the returned RooDataHist*

{ return fChain->GetAsDataHist(whichVars); }
THnSparse* GetChainAsSparseHist(RooArgSet* whichVars = NULL)
 Get a clone of the markov chain on which this interval is based
as a THnSparse.  You own the returned THnSparse*

{ return fChain->GetAsSparseHist(whichVars); }
RooRealVar* GetNLLVar() const
 Get a clone of the NLL variable from the markov chain

{ return fChain->GetNLLVar(); }
RooRealVar* GetWeightVar() const
 Get a clone of the weight variable from the markov chain

{ return fChain->GetWeightVar(); }
void SetEpsilon(Double_t epsilon)
 set the acceptable level or error for Keys interval determination