Logo ROOT  
Reference Guide
DebuggingSampler.h
Go to the documentation of this file.
1// @(#)root/roostats:$Id$
2// Author: Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke
3/*************************************************************************
4 * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11#ifndef ROOSTATS_DebuggingSampler
12#define ROOSTATS_DebuggingSampler
13
14/** \class DebuggingSampler
15 \ingroup Roostats
16
17DebuggingSampler is a simple implementation of the DistributionCreator interface used for debugging.
18The sampling distribution is uniformly random between [0,1] and is INDEPENDENT of the data. So it is not useful
19for true statistical tests, but it is useful for debugging.
20
21*/
22
23#include "Rtypes.h"
24
25#include <vector>
26
29
30#include "RooRealVar.h"
31#include "TRandom.h"
32
33namespace RooStats {
34
36
37 public:
39 fTestStatistic = new RooRealVar("UniformTestStatistic","UniformTestStatistic",0,0,1);
40 fRand = new TRandom();
41 }
42 ~DebuggingSampler() override {
43 delete fRand;
44 delete fTestStatistic;
45 }
46
47 /// Main interface to get a ConfInterval, pure virtual
49 (void)paramsOfInterest; // avoid warning
50 // normally this method would be complex, but here it is simple for debugging
51 std::vector<double> testStatVec;
52 for(Int_t i=0; i<1000; ++i){
53 testStatVec.push_back( fRand->Uniform() );
54 }
55 return new SamplingDistribution("UniformSamplingDist", "for debugging", testStatVec );
56 }
57
58 /// Main interface to evaluate the test statistic on a dataset
59 double EvaluateTestStatistic(RooAbsData& /*data*/, RooArgSet& /*paramsOfInterest*/) override {
60 // data = data; // avoid warning
61 // paramsOfInterest = paramsOfInterest; // avoid warning
62 return fRand->Uniform();
63 }
64
65 /// Get the TestStatistic
66 TestStatistic* GetTestStatistic() const override {
67 std::cout << "GetTestStatistic() IS NOT IMPLEMENTED FOR THIS SAMPLER. Returning nullptr." << std::endl;
68 return nullptr; /*fTestStatistic;*/
69 }
70
71 /// Get the Confidence level for the test
72 double ConfidenceLevel() const override {return 1.-fSize;}
73
74 /// Common Initialization
75 void Initialize(RooAbsArg& /* testStatistic */, RooArgSet& /* paramsOfInterest */, RooArgSet& /* nuisanceParameters */ ) override {
76 }
77
78 /// Set the Pdf, add to the workspace if not already there
79 void SetPdf(RooAbsPdf&) override {}
80
81 /// specify the parameters of interest in the interval
82 virtual void SetParameters(RooArgSet&) {}
83 /// specify the nuisance parameters (eg. the rest of the parameters)
84 void SetNuisanceParameters(const RooArgSet&) override {}
85 /// specify the values of parameters used when evaluating test statistic
86 void SetParametersForTestStat(const RooArgSet& ) override {}
87 /// specify the conditional observables
88 void SetGlobalObservables(const RooArgSet& ) override {}
89
90
91 /// set the size of the test (rate of Type I error) ( Eg. 0.05 for a 95% Confidence Interval)
92 void SetTestSize(double size) override {fSize = size;}
93 /// set the confidence level for the interval (eg. 0.95 for a 95% Confidence Interval)
94 void SetConfidenceLevel(double cl) override {fSize = 1.-cl;}
95
96 /// Set the TestStatistic (want the argument to be a function of the data & parameter points
97 void SetTestStatistic(TestStatistic* /*testStatistic*/) override {
98 std::cout << "SetTestStatistic(...) IS NOT IMPLEMENTED FOR THIS SAMPLER" << std::endl;
99 }
100
101 private:
102 double fSize;
105
106 protected:
107 ClassDefOverride(DebuggingSampler,1) // A simple implementation of the DistributionCreator interface
108 };
109}
110
111
112#endif
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
#define ClassDefOverride(name, id)
Definition: Rtypes.h:339
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition: RooAbsArg.h:71
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition: RooAbsData.h:62
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
void SetTestSize(double size) override
set the size of the test (rate of Type I error) ( Eg. 0.05 for a 95% Confidence Interval)
void Initialize(RooAbsArg &, RooArgSet &, RooArgSet &) override
Common Initialization.
void SetParametersForTestStat(const RooArgSet &) override
specify the values of parameters used when evaluating test statistic
TestStatistic * GetTestStatistic() const override
Get the TestStatistic.
virtual void SetParameters(RooArgSet &)
specify the parameters of interest in the interval
double ConfidenceLevel() const override
Get the Confidence level for the test.
void SetPdf(RooAbsPdf &) override
Set the Pdf, add to the workspace if not already there.
void SetConfidenceLevel(double cl) override
set the confidence level for the interval (eg. 0.95 for a 95% Confidence Interval)
SamplingDistribution * GetSamplingDistribution(RooArgSet &paramsOfInterest) override
Main interface to get a ConfInterval, pure virtual.
void SetTestStatistic(TestStatistic *) override
Set the TestStatistic (want the argument to be a function of the data & parameter points.
void SetGlobalObservables(const RooArgSet &) override
specify the conditional observables
double EvaluateTestStatistic(RooAbsData &, RooArgSet &) override
Main interface to evaluate the test statistic on a dataset.
void SetNuisanceParameters(const RooArgSet &) override
specify the nuisance parameters (eg. the rest of the parameters)
This class simply holds a sampling distribution of some test statistic.
TestStatSampler is an interface class for a tools which produce RooStats SamplingDistributions.
TestStatistic is an interface class to provide a facility for construction test statistics distributi...
Definition: TestStatistic.h:31
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:27
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).
Definition: TRandom.cxx:672
void(off) SmallVectorTemplateBase< T
Namespace for the RooStats classes.
Definition: Asimov.h:19