Logo ROOT   6.08/07
Reference Guide
HypoTestResult.h
Go to the documentation of this file.
1 // @(#)root/roostats:$Id$
2 // Author: Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke, Sven Kreiss
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 
12 
13 
14 #ifndef ROOSTATS_HypoTestResult
15 #define ROOSTATS_HypoTestResult
16 
17 #ifndef ROOT_TNamed
18 #include "TNamed.h"
19 #endif
20 
21 #ifndef ROOSTATS_RooStatsUtils
22 #include "RooStats/RooStatsUtils.h"
23 #endif
24 
25 #ifndef ROOSTATS_SamplingDistribution
27 #endif
28 
29 namespace RooStats {
30 
31 
32 /**
33 
34  \ingroup Roostats
35 
36  HypoTestResult is a base class for results from hypothesis tests.
37  Any tool inheriting from HypoTestCalculator can return a HypoTestResult.
38  As such, it stores a p-value for the null-hypothesis (eg. background-only)
39  and an alternate hypothesis (eg. signal+background).
40  The p-values can also be transformed into confidence levels
41  (\f$CL_{b}\f$, \f$CL_{s+b}\f$) in a trivial way.
42  The ratio of the \f$CL_{s+b}\f$ to \f$CL_{b}\f$ is often called
43  \f$CL_{s}\f$, and is considered useful, though it is not a probability.
44  Finally, the p-value of the null can be transformed into a number of
45  equivalent Gaussian sigma using the Significance method.
46 
47  The p-value of the null for a given test statistic is rigorously defined and
48  this is the starting point for the following conventions.
49 
50 ### Conventions used in this class
51 
52 The p-value for the null and alternate are on the **same side** of the
53 observed value of the test statistic. This is the more standard
54 convention and avoids confusion when doing inverted tests.
55 
56 For exclusion, we also want the formula \f$CL_{s} = CL_{s+b} / CL_{b}\f$
57 to hold which therefore defines our conventions for \f$CL_{s+b}\f$ and
58 \f$CL_{b}\f$. \f$CL_{s}\f$ was specifically invented for exclusion
59 and therefore all quantities need be related through the assignments
60 as they are for exclusion: \f$CL_{s+b} = p_{s+b}\f$; \f$CL_{b} = p_{b}\f$. This
61 is derived by considering the scenarios of a powerful and not powerful
62 inverted test, where for the not so powerful test, \f$CL_{s}\f$ must be
63 close to one.
64 
65 For results of Hypothesis tests,
66 \f$CL_{s}\f$ has no similar direct interpretation as for exclusion and can
67 be larger than one.
68 
69 */
70 
71  class HypoTestResult : public TNamed {
72 
73  public:
74 
75  /// default constructor
76  explicit HypoTestResult(const char* name = 0);
77 
78  /// copy constructor
79  HypoTestResult(const HypoTestResult& other);
80 
81  /// constructor from name, null and alternate p values
82  HypoTestResult(const char* name, Double_t nullp, Double_t altp);
83 
84  /// destructor
85  virtual ~HypoTestResult();
86 
87  /// assignment operator
88  HypoTestResult & operator=(const HypoTestResult& other);
89 
90  /// add values from another HypoTestResult
91  virtual void Append(const HypoTestResult *other);
92 
93  /// Return p-value for null hypothesis
94  virtual Double_t NullPValue() const { return fNullPValue; }
95 
96  /// Return p-value for alternate hypothesis
97  virtual Double_t AlternatePValue() const { return fAlternatePValue; }
98 
99  /// Convert NullPValue into a "confidence level"
100  virtual Double_t CLb() const { return !fBackgroundIsAlt ? NullPValue() : AlternatePValue(); }
101 
102  /// Convert AlternatePValue into a "confidence level"
103  virtual Double_t CLsplusb() const { return !fBackgroundIsAlt ? AlternatePValue() : NullPValue(); }
104 
105  /// \f$CL_{s}\f$ is simply \f$CL_{s+b}/CL_{b}\f$ (not a method, but a quantity)
106  virtual Double_t CLs() const {
107  double thisCLb = CLb();
108  if (thisCLb == 0) {
109  std::cout << "Error: Cannot compute CLs because CLb = 0. Returning CLs = -1\n";
110  return -1;
111  }
112  double thisCLsb = CLsplusb();
113  return thisCLsb / thisCLb;
114  }
115 
116  /// familiar name for the Null p-value in terms of 1-sided Gaussian significance
118 
123  RooDataSet* GetFitInfo(void) const { return fFitInfo; }
126  Bool_t HasTestStatisticData(void) const;
127 
132  void SetFitInfo(RooDataSet* d) { fFitInfo = d; }
133  void SetTestStatisticData(const Double_t tsd);
134  void SetAllTestStatisticsData(const RooArgList* tsd);
135 
136  void SetPValueIsRightTail(Bool_t pr);
138 
141 
142  /// The error on the "confidence level" of the null hypothesis
143  Double_t CLbError() const;
144 
145  /// The error on the "confidence level" of the alternative hypothesis
146  Double_t CLsplusbError() const;
147 
148  /// The error on the ratio \f$CL_{s+b}/CL_{b}\f$
149  Double_t CLsError() const;
150 
151  /// The error on the Null p-value
152  Double_t NullPValueError() const;
153 
154  /// The error on the significance, computed from NullPValueError via error propagation
155  Double_t SignificanceError() const;
156 
157 
158  void Print(const Option_t* = "") const;
159 
160  private:
161  void UpdatePValue(const SamplingDistribution* distr, Double_t &pvalue, Double_t &perror, Bool_t pIsRightTail);
162 
163 
164  protected:
165 
166  mutable Double_t fNullPValue; // p-value for the null hypothesis (small number means disfavoured)
167  mutable Double_t fAlternatePValue; // p-value for the alternate hypothesis (small number means disfavoured)
168  mutable Double_t fNullPValueError; // error of p-value for the null hypothesis (small number means disfavoured)
169  mutable Double_t fAlternatePValueError; // error of p-value for the alternate hypothesis (small number means disfavoured)
170  Double_t fTestStatisticData; // result of the test statistic evaluated on data
171  const RooArgList* fAllTestStatisticsData; // for the case of multiple test statistics, holds all the results
179 
180  ClassDef(HypoTestResult,3) // Base class to represent results of a hypothesis test
181 
182  };
183 }
184 
185 
186 #endif
Bool_t HasTestStatisticData(void) const
void SetBackgroundAsAlt(Bool_t l=kTRUE)
void SetAltDistribution(SamplingDistribution *alt)
void SetFitInfo(RooDataSet *d)
virtual Double_t CLb() const
Convert NullPValue into a "confidence level".
const char Option_t
Definition: RtypesCore.h:62
void Print(const Option_t *="") const
Print out some information about the results Note: use Alt/Null labels for the hypotheses here as the...
RooDataSet * GetAltDetailedOutput(void) const
const RooArgList * fAllTestStatisticsData
RooDataSet * GetFitInfo(void) const
Double_t PValueToSignificance(Double_t pvalue)
Definition: RooStatsUtils.h:59
HypoTestResult is a base class for results from hypothesis tests.
Double_t NullPValueError() const
The error on the Null p-value.
HypoTestResult & operator=(const HypoTestResult &other)
assignment operator
RooDataSet * fNullDetailedOutput
void UpdatePValue(const SamplingDistribution *distr, Double_t &pvalue, Double_t &perror, Bool_t pIsRightTail)
updates the pvalue if sufficient data is available
bool Bool_t
Definition: RtypesCore.h:59
SamplingDistribution * GetAltDistribution(void) const
Double_t CLbError() const
The error on the "confidence level" of the null hypothesis.
virtual Double_t Significance() const
familiar name for the Null p-value in terms of 1-sided Gaussian significance
null_t< F > null()
#define ClassDef(name, id)
Definition: Rtypes.h:254
Double_t CLsError() const
The error on the ratio .
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
Bool_t GetPValueIsRightTail(void) const
const RooArgList * GetAllTestStatisticsData(void) const
void SetAllTestStatisticsData(const RooArgList *tsd)
virtual ~HypoTestResult()
destructor
virtual Double_t NullPValue() const
Return p-value for null hypothesis.
Double_t GetTestStatisticData(void) const
SamplingDistribution * fAltDistr
void SetAltDetailedOutput(RooDataSet *d)
SamplingDistribution * GetNullDistribution(void) const
TLine * l
Definition: textangle.C:4
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:29
void SetTestStatisticData(const Double_t tsd)
This class simply holds a sampling distribution of some test statistic.
HypoTestResult(const char *name=0)
default constructor
virtual void Append(const HypoTestResult *other)
add values from another HypoTestResult
virtual Double_t CLs() const
is simply (not a method, but a quantity)
virtual Double_t AlternatePValue() const
Return p-value for alternate hypothesis.
void SetPValueIsRightTail(Bool_t pr)
virtual Double_t CLsplusb() const
Convert AlternatePValue into a "confidence level".
RooDataSet * GetNullDetailedOutput(void) const
Namespace for the RooStats classes.
Definition: Asimov.h:20
SamplingDistribution * fNullDistr
double Double_t
Definition: RtypesCore.h:55
Double_t CLsplusbError() const
The error on the "confidence level" of the alternative hypothesis.
void SetNullDetailedOutput(RooDataSet *d)
Double_t SignificanceError() const
The error on the significance, computed from NullPValueError via error propagation.
RooDataSet * fAltDetailedOutput
Bool_t GetBackGroundIsAlt(void) const
const Bool_t kTRUE
Definition: Rtypes.h:91
char name[80]
Definition: TGX11.cxx:109
void SetNullDistribution(SamplingDistribution *null)