ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 /*************************************************************************
5  * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
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 #ifndef ROOT_Rtypes
19 #include "Rtypes.h"
20 #endif
21 
22 #ifndef ROO_ARG_SET
23 #include "RooArgSet.h"
24 #endif
25 #ifndef ROO_MSG_SERVICE
26 #include "RooMsgService.h"
27 #endif
28 #ifndef ROOT_TIterator
29 #include "TIterator.h"
30 #endif
31 #ifndef ROO_REAL_VAR
32 #include "RooRealVar.h"
33 #endif
34 
35 
36 namespace RooStats {
37 
38  /**
39 
40  ProposalFunction is an interface for all proposal functions that would be used with a Markov Chain Monte Carlo algorithm.
41  Given a current point in the parameter space it proposes a new point.
42  Proposal functions may or may not be symmetric, in the sense that the probability to propose X1 given we are at X2
43  need not be the same as the probability to propose X2 given that we are at X1. In this case, the IsSymmetric method
44  should return false, and the Metropolis algorithm will need to take into account the proposal density to maintain detailed balance.
45 
46  \ingroup Roostats
47 
48  */
49 
50 
51  class ProposalFunction : public TObject {
52 
53  public:
54  ///Default constructor
56 
57  virtual ~ProposalFunction() {}
58 
59  /// Populate xPrime with the new proposed point,
60  /// possibly based on the current point x
61  virtual void Propose(RooArgSet& xPrime, RooArgSet& x) = 0;
62 
63  /// Determine whether or not the proposal density is symmetric for
64  /// points x1 and x2 - that is, whether the probabilty of reaching x2
65  /// from x1 is equal to the probability of reaching x1 from x2
66  virtual Bool_t IsSymmetric(RooArgSet& x1, RooArgSet& x2) = 0;
67 
68  /// Return the probability of proposing the point x1 given the starting
69  /// point x2
71 
72  /// Check the parameters for which the ProposalFunction will
73  /// propose values to make sure they are all RooRealVars
74  /// Return true if all objects are RooRealVars, false otherwise
75  virtual bool CheckParameters(RooArgSet& params)
76  {
77  TIterator* it = params.createIterator();
78  TObject* obj;
79  while ((obj = it->Next()) != NULL) {
80  if (!dynamic_cast<RooRealVar*>(obj)) {
81  coutE(Eval) << "Error when checking parameters in"
82  << "ProposalFunction: "
83  << "Object \"" << obj->GetName() << "\" not of type "
84  << "RooRealVar" << std::endl;
85  delete it;
86  return false;
87  }
88  }
89  delete it;
90  // Made it here, so all parameters are RooRealVars
91  return true;
92  }
93 
94  protected:
95  ClassDef(ProposalFunction,1) /// Interface for the proposal function used with Markov Chain Monte Carlo
96  };
97 }
98 
99 #endif
ProposalFunction is an interface for all proposal functions that would be used with a Markov Chain Mo...
#define coutE(a)
Definition: RooMsgService.h:35
bool Bool_t
Definition: RtypesCore.h:59
Iterator abstract base class.
Definition: TIterator.h:32
static const double x2[5]
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:254
TIterator * createIterator(Bool_t dir=kIterForward) const
virtual bool CheckParameters(RooArgSet &params)
Check the parameters for which the ProposalFunction will propose values to make sure they are all Roo...
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 Double_t GetProposalDensity(RooArgSet &x1, RooArgSet &x2)=0
Return the probability of proposing the point x1 given the starting point x2.
virtual void Propose(RooArgSet &xPrime, RooArgSet &x)=0
Populate xPrime with the new proposed point, possibly based on the current point x.
static const double x1[5]
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:415
double Double_t
Definition: RtypesCore.h:55
Mother of all ROOT objects.
Definition: TObject.h:58
ProposalFunction()
Default constructor.
virtual TObject * Next()=0
#define NULL
Definition: Rtypes.h:82
TObject * obj