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 "RooRealVar.h"
23
24
25namespace RooStats {
26
27/** \class ProposalFunction
28 \ingroup Roostats
29ProposalFunction is an interface for all proposal functions that would be used
30with a Markov Chain Monte Carlo algorithm.
31Given a current point in the parameter space it proposes a new point.
32Proposal functions may or may not be symmetric, in the sense that the
33probability to propose X1 given we are at X2
34need not be the same as the probability to propose X2 given that we are at X1.
35In this case, the IsSymmetric method
36should return false, and the Metropolis algorithm will need to take into account
37the proposal density to maintain detailed balance.
38*/
39
40
41 class ProposalFunction : public TObject {
42
43 public:
44 ///Default constructor
46
47 ~ProposalFunction() override {}
48
49 /// Populate xPrime with the new proposed point,
50 /// possibly based on the current point x
51 virtual void Propose(RooArgSet& xPrime, RooArgSet& x) = 0;
52
53 /// Determine whether or not the proposal density is symmetric for
54 /// points x1 and x2 - that is, whether the probability of reaching x2
55 /// from x1 is equal to the probability of reaching x1 from x2
56 virtual bool IsSymmetric(RooArgSet& x1, RooArgSet& x2) = 0;
57
58 /// Return the probability of proposing the point x1 given the starting
59 /// point x2
60 virtual double GetProposalDensity(RooArgSet& x1, RooArgSet& x2) = 0;
61
62 /// Check the parameters for which the ProposalFunction will
63 /// propose values to make sure they are all RooRealVars
64 /// Return true if all objects are RooRealVars, false otherwise
65 virtual bool CheckParameters(RooArgSet& params)
66 {
67 for (auto *obj : params){
68 if (!dynamic_cast<RooRealVar*>(obj)) {
69 coutE(Eval) << "Error when checking parameters in"
70 << "ProposalFunction: "
71 << "Object \"" << obj->GetName() << "\" not of type "
72 << "RooRealVar" << std::endl;
73 return false;
74 }
75 }
76 // Made it here, so all parameters are RooRealVars
77 return true;
78 }
79
80 protected:
81 ClassDefOverride(ProposalFunction,1) /// Interface for the proposal function used with Markov Chain Monte Carlo
82 };
83}
84
85#endif
#define coutE(a)
Definition: RooMsgService.h:37
#define ClassDefOverride(name, id)
Definition: Rtypes.h:339
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:56
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:40
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.
virtual double GetProposalDensity(RooArgSet &x1, RooArgSet &x2)=0
Return the probability of proposing the point x1 given the starting point x2.
ProposalFunction()
Default constructor.
virtual bool 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...
Mother of all ROOT objects.
Definition: TObject.h:41
Double_t x[n]
Definition: legend1.C:17
Namespace for the RooStats classes.
Definition: Asimov.h:19