Logo 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 /*************************************************************************
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
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
RooStats::ProposalFunction::IsSymmetric
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,...
RooStats::ProposalFunction::GetProposalDensity
virtual Double_t GetProposalDensity(RooArgSet &x1, RooArgSet &x2)=0
Return the probability of proposing the point x1 given the starting point x2.
RooMsgService.h
RooStats::ProposalFunction::Propose
virtual void Propose(RooArgSet &xPrime, RooArgSet &x)=0
Populate xPrime with the new proposed point, possibly based on the current point x.
RooArgSet.h
coutE
#define coutE(a)
Definition: RooMsgService.h:33
RooStats::ProposalFunction::~ProposalFunction
virtual ~ProposalFunction()
Definition: ProposalFunction.h:48
RooStats::ProposalFunction::ProposalFunction
ProposalFunction()
Default constructor.
Definition: ProposalFunction.h:46
x
Double_t x[n]
Definition: legend1.C:17
bool
TIterator
Iterator abstract base class.
Definition: TIterator.h:30
x1
static const double x1[5]
Definition: RooGaussKronrodIntegrator1D.cxx:346
TObject::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:359
TIterator.h
RooAbsCollection::createIterator
TIterator * createIterator(Bool_t dir=kIterForward) const
TIterator-style iteration over contained elements.
Definition: RooAbsCollection.h:118
RooRealVar.h
TIterator::Next
virtual TObject * Next()=0
Double_t
double Double_t
Definition: RtypesCore.h:59
RooStats
Namespace for the RooStats classes.
Definition: Asimov.h:19
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
RooStats::ProposalFunction
ProposalFunction is an interface for all proposal functions that would be used with a Markov Chain Mo...
Definition: ProposalFunction.h:42
x2
static const double x2[5]
Definition: RooGaussKronrodIntegrator1D.cxx:364
RooRealVar
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:36
RooFit::Eval
@ Eval
Definition: RooGlobalFunc.h:68
Rtypes.h
RooStats::ProposalFunction::CheckParameters
virtual bool CheckParameters(RooArgSet &params)
Check the parameters for which the ProposalFunction will propose values to make sure they are all Roo...
Definition: ProposalFunction.h:66
RooArgSet
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28