ROOT   Reference Guide
Searching...
No Matches
SequentialProposal.cxx
Go to the documentation of this file.
1// @(#)root/roostats:$Id$
2// Authors: Giovanni Petrucciani 4/21/2011
3/*************************************************************************
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. * 8 * For the list of contributors see$ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11/** \class RooStats::SequentialProposal
12 \ingroup Roostats
13
14Class implementing a proposal function that samples the parameter space
15by moving only in one coordinate (chosen randomly) at each step
16*/
17
19#include <RooArgSet.h>
20#include <iostream>
21#include <memory>
22#include <RooRandom.h>
24
25using namespace std;
26
28
29namespace RooStats {
30
31////////////////////////////////////////////////////////////////////////////////
32
35 fDivisor(1./divisor)
36{
37}
38
39////////////////////////////////////////////////////////////////////////////////
40/// Populate xPrime with a new proposed point
41
43{
44 RooStats::SetParameters(&x, &xPrime);
45 int n = xPrime.getSize();
46 int j = int( floor(RooRandom::uniform()*n) );
47 int i = 0;
48 for (auto *var : static_range_cast<RooRealVar *>(xPrime)) {
49 if (i == j) {
50 double val = var->getVal(), max = var->getMax(), min = var->getMin(), len = max - min;
51 val += RooRandom::gaussian() * len * fDivisor;
52 while (val > max) val -= len;
53 while (val < min) val += len;
54 var->setVal(val);
55 //std::cout << "Proposing a step along " << var->GetName() << std::endl;
56 }
57 ++i;
58 }
59}
60
61////////////////////////////////////////////////////////////////////////////////
62/// Return the probability of proposing the point x1 given the starting
63/// point x2
64
66 return true;
67}
68
70 RooArgSet& )
71{
72 return 1.0; // should not be needed
73}
74
75}
#define ClassImp(name)
Definition Rtypes.h:375
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Int_t getSize() const
Return the number of elements in the collection.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:55
static double uniform(TRandom *generator=randomGenerator())
Return a number uniformly distributed from (0,1)
Definition RooRandom.cxx:81
static double gaussian(TRandom *generator=randomGenerator())
Return a Gaussian random variable with mean 0 and variance 1.
ProposalFunction is an interface for all proposal functions that would be used with a Markov Chain Mo...
Class implementing a proposal function that samples the parameter space by moving only in one coordin...
double GetProposalDensity(RooArgSet &x1, RooArgSet &x2) override
Return the probability of proposing the point x1 given the starting point x2.
bool IsSymmetric(RooArgSet &x1, RooArgSet &x2) override
Determine whether or not the proposal density is symmetric for points x1 and x2 - that is,...
void Propose(RooArgSet &xPrime, RooArgSet &x) override
Populate xPrime with a new proposed point.
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
Namespace for the RooStats classes.
Definition Asimov.h:19
void SetParameters(const RooArgSet *desiredVals, RooArgSet *paramsToChange)