Logo ROOT   6.21/01
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 /*************************************************************************
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 #include "Rtypes.h"
19 
20 #include "RooArgSet.h"
21 #include "RooMsgService.h"
22 #include "TIterator.h"
23 #include "RooRealVar.h"
24 
25 
26 namespace RooStats {
27 
28 /** \class ProposalFunction
29  \ingroup Roostats
30 ProposalFunction is an interface for all proposal functions that would be used
31 with a Markov Chain Monte Carlo algorithm.
32 Given a current point in the parameter space it proposes a new point.
33 Proposal functions may or may not be symmetric, in the sense that the
34 probability to propose X1 given we are at X2
35 need not be the same as the probability to propose X2 given that we are at X1.
36 In this case, the IsSymmetric method
37 should return false, and the Metropolis algorithm will need to take into account
38 the 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
57  virtual Bool_t IsSymmetric(RooArgSet& x1, RooArgSet& x2) = 0;
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
ProposalFunction is an interface for all proposal functions that would be used with a Markov Chain Mo...
#define coutE(a)
Definition: RooMsgService.h:34
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
bool Bool_t
Definition: RtypesCore.h:59
Iterator abstract base class.
Definition: TIterator.h:30
static const double x2[5]
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:326
TIterator * createIterator(Bool_t dir=kIterForward) const R__SUGGEST_ALTERNATIVE("begin()
TIterator-style iteration over contained elements.
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.
Namespace for the RooStats classes.
Definition: Asimov.h:20
static const double x1[5]
double Double_t
Definition: RtypesCore.h:55
Mother of all ROOT objects.
Definition: TObject.h:37
ProposalFunction()
Default constructor.
virtual TObject * Next()=0
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:357