ROOT   Reference Guide
ProposalFunction.h
Go to the documentation of this file.
1// @(#)root/roostats:$Id$
2// Authors: Kevin Belasco 17/06/2009
3// Authors: Kyle Cranmer 17/06/2009
4/*************************************************************************
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. * 9 * For the list of contributors see$ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12
13
14
15#ifndef ROOSTATS_ProposalFunction
16#define ROOSTATS_ProposalFunction
17
18#include "Rtypes.h"
19
20#include "RooArgSet.h"
21#include "RooMsgService.h"
22#include "TIterator.h"
23#include "RooRealVar.h"
24
25
26namespace RooStats {
27
28/** \class ProposalFunction
29 \ingroup Roostats
30ProposalFunction is an interface for all proposal functions that would be used
31with a Markov Chain Monte Carlo algorithm.
32Given a current point in the parameter space it proposes a new point.
33Proposal functions may or may not be symmetric, in the sense that the
34probability to propose X1 given we are at X2
35need not be the same as the probability to propose X2 given that we are at X1.
36In this case, the IsSymmetric method
37should return false, and the Metropolis algorithm will need to take into account
38the proposal density to maintain detailed balance.
39*/
40
41
42 class ProposalFunction : public TObject {
43
44 public:
45 ///Default constructor
47
48 virtual ~ProposalFunction() {}
49
50 /// Populate xPrime with the new proposed point,
51 /// possibly based on the current point x
52 virtual void Propose(RooArgSet& xPrime, RooArgSet& x) = 0;
53
54 /// Determine whether or not the proposal density is symmetric for
55 /// points x1 and x2 - that is, whether the probability of reaching x2
56 /// from x1 is equal to the probability of reaching x1 from x2
58
59 /// Return the probability of proposing the point x1 given the starting
60 /// point x2
62
63 /// Check the parameters for which the ProposalFunction will
64 /// propose values to make sure they are all RooRealVars
65 /// Return true if all objects are RooRealVars, false otherwise
66 virtual bool CheckParameters(RooArgSet& params)
67 {
68 TIterator* it = params.createIterator();
69 TObject* obj;
70 while ((obj = it->Next()) != NULL) {
71 if (!dynamic_cast<RooRealVar*>(obj)) {
72 coutE(Eval) << "Error when checking parameters in"
73 << "ProposalFunction: "
74 << "Object \"" << obj->GetName() << "\" not of type "
75 << "RooRealVar" << std::endl;
76 delete it;
77 return false;
78 }
79 }
80 delete it;
81 // Made it here, so all parameters are RooRealVars
82 return true;
83 }
84
85 protected:
86 ClassDef(ProposalFunction,1) /// Interface for the proposal function used with Markov Chain Monte Carlo
87 };
88}
89
90#endif
static const double x2[5]
static const double x1[5]
#define coutE(a)
Definition: RooMsgService.h:33
double Double_t
Definition: RtypesCore.h:57
#define ClassDef(name, id)
Definition: Rtypes.h:322
TIterator * createIterator(Bool_t dir=kIterForward) const
TIterator-style iteration over contained elements.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:35
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.
ProposalFunction()
Default constructor.
virtual Double_t GetProposalDensity(RooArgSet &x1, RooArgSet &x2)=0
Return the probability of proposing the point x1 given the starting point x2.
virtual Bool_t IsSymmetric(RooArgSet &x1, RooArgSet &x2)=0
Determine whether or not the proposal density is symmetric for points x1 and x2 - that is,...
virtual bool CheckParameters(RooArgSet &params)
Check the parameters for which the ProposalFunction will propose values to make sure they are all Roo...
Iterator abstract base class.
Definition: TIterator.h:30
virtual TObject * Next()=0
Mother of all ROOT objects.
Definition: TObject.h:37
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:357
Double_t x[n]
Definition: legend1.C:17
Namespace for the RooStats classes.
Definition: Asimov.h:19