Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
PdfProposal.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#ifndef ROOSTATS_PdfProposal
13#define ROOSTATS_PdfProposal
14
15#include "Rtypes.h"
16
18
19#include "RooArgSet.h"
20#include "RooMsgService.h"
21#include "RooRealVar.h"
22#include "RooDataSet.h"
23#include "RooAbsPdf.h"
24
25#include <map>
26
27
28namespace RooStats {
29
31
32 public:
35
36 /// Populate xPrime with a new proposed point
37 void Propose(RooArgSet& xPrime, RooArgSet& x) override;
38
39 /// Determine whether or not the proposal density is symmetric for
40 /// points x1 and x2 - that is, whether the probability of reaching x2
41 /// from x1 is equal to the probability of reaching x1 from x2
42 bool IsSymmetric(RooArgSet& x1, RooArgSet& x2) override;
43
44 /// Return the probability of proposing the point x1 given the starting
45 /// point x2
46 double GetProposalDensity(RooArgSet& x1, RooArgSet& x2) override;
47
48 /// Set the PDF to be the proposal density function
49 virtual void SetPdf(RooAbsPdf& pdf) { fPdf = &pdf; }
50
51 /// Get the PDF is the proposal density function
52 virtual const RooAbsPdf* GetPdf() const { return fPdf; }
53
54 /// specify a mapping between a parameter of the proposal function and
55 /// a parameter of interest. this mapping is used to set the value of
56 /// proposalParam equal to the value of update to determine the
57 /// proposal function.
58 /// proposalParam is a parameter of the proposal function that must
59 /// be set to the value of update (from the current point) in order to
60 /// propose a new point.
61 virtual void AddMapping(RooRealVar& proposalParam, RooAbsReal& update);
62
63 virtual void Reset()
64 {
65 fCache.reset();
68 }
69
70 virtual void printMappings()
71 {
72 std::map<RooRealVar*, RooAbsReal*>::iterator it;
73 for (it = fMap.begin(); it != fMap.end(); it++)
74 std::cout << it->first->GetName() << " => " << it->second->GetName() << std::endl;
75 }
76
77 /// Set how many points to generate each time we propose from a new point
78 /// Default (and minimum) is 1
79 virtual void SetCacheSize(Int_t size)
80 {
81 if (size > 0) {
83 } else {
84 coutE(Eval) << "Warning: Requested non-positive cache size: " << size << ". Cache size unchanged."
85 << std::endl;
86 }
87 }
88
89 /// set whether we own the PDF that serves as the proposal density function
90 /// By default, when constructed, PdfProposal does NOT own the PDF.
91 virtual void SetOwnsPdf(bool ownsPdf) { fOwnsPdf = ownsPdf; }
92
93 //virtual void SetIsAlwaysSymmetric(bool isAlwaysSymmetric)
94 //{ fIsAlwaysSymmetric = isAlwaysSymmetric; }
95
96 ~PdfProposal() override
97 {
98 if (fOwnsPdf)
99 delete fPdf;
100 }
101
102 protected:
103 RooAbsPdf *fPdf = nullptr; /// the proposal density function
104 std::map<RooRealVar*, RooAbsReal*> fMap; /// map of values in pdf to update
105 std::map<RooRealVar*, RooAbsReal*>::iterator fIt; /// pdf iterator
106 RooArgSet fLastX; /// the last point we were at
107 Int_t fCacheSize = 1; /// how many points to generate each time
108 Int_t fCachePosition = 0; /// our position in the cached proposal data set
109 std::unique_ptr<RooDataSet> fCache; /// the cached proposal data set
110 RooArgSet fMaster; /// pointers to master variables needed for updates
111 bool fOwnsPdf = false; /// whether we own the proposal density function
112 // bool fIsAlwaysSymmetric; // does Q(x1 | x2) == Q(x2 | x1) for all x1, x2
113
114 /// determine whether these two RooArgSets represent the same point
115 virtual bool Equals(RooArgSet& x1, RooArgSet& x2);
116
117 /// Interface for tools setting limits (producing confidence intervals)
119 };
120}
121
122#endif
static void update(gsl_integration_workspace *workspace, double a1, double b1, double area1, double error1, double a2, double b2, double area2, double error2)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
#define coutE(a)
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
Abstract interface for all probability density functions.
Definition RooAbsPdf.h:40
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:55
Variable that can be changed from the outside.
Definition RooRealVar.h:37
PdfProposal is a concrete implementation of the ProposalFunction interface.
Definition PdfProposal.h:30
std::map< RooRealVar *, RooAbsReal * >::iterator fIt
map of values in pdf to update
RooArgSet fMaster
the cached proposal data set
bool IsSymmetric(RooArgSet &x1, RooArgSet &x2) override
Determine whether or not the proposal density is symmetric for points x1 and x2 - that is,...
virtual void AddMapping(RooRealVar &proposalParam, RooAbsReal &update)
specify a mapping between a parameter of the proposal function and a parameter of interest.
virtual void SetCacheSize(Int_t size)
Set how many points to generate each time we propose from a new point Default (and minimum) is 1.
Definition PdfProposal.h:79
virtual const RooAbsPdf * GetPdf() const
Get the PDF is the proposal density function.
Definition PdfProposal.h:52
bool fOwnsPdf
pointers to master variables needed for updates
virtual bool Equals(RooArgSet &x1, RooArgSet &x2)
whether we own the proposal density function
RooArgSet fLastX
pdf iterator
void Propose(RooArgSet &xPrime, RooArgSet &x) override
Populate xPrime with a new proposed point.
virtual void SetOwnsPdf(bool ownsPdf)
set whether we own the PDF that serves as the proposal density function By default,...
Definition PdfProposal.h:91
Int_t fCacheSize
the last point we were at
virtual void SetPdf(RooAbsPdf &pdf)
Set the PDF to be the proposal density function.
Definition PdfProposal.h:49
virtual void Reset()
Definition PdfProposal.h:63
Int_t fCachePosition
how many points to generate each time
std::map< RooRealVar *, RooAbsReal * > fMap
the proposal density function
virtual void printMappings()
Definition PdfProposal.h:70
~PdfProposal() override
Definition PdfProposal.h:96
PdfProposal()
By default, PdfProposal does NOT own the PDF that serves as the proposal density function.
std::unique_ptr< RooDataSet > fCache
our position in the cached proposal data set
double GetProposalDensity(RooArgSet &x1, RooArgSet &x2) override
Return the probability of proposing the point x1 given the starting point x2.
ProposalFunction is an interface for all proposal functions that would be used with a Markov Chain Mo...
Double_t x[n]
Definition legend1.C:17
Namespace for the RooStats classes.
Definition Asimov.h:19