Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
NumberCountingUtils.cxx
Go to the documentation of this file.
1// @(#)root/roostats:$Id$
2// Author: Kyle Cranmer 28/07/2008
3
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
14
16
17#include <TMath.h>
18
19// // Without this macro the THtml doc can not be generated
20// #if !defined(R__ALPHA) && !defined(R__SOLARIS) && !defined(R__ACC) && !defined(R__FBSD)
21// NamespaceImp(RooStats)
22// //NamespaceImp(NumberCountingUtils)
23// #endif
24
25//using namespace RooStats;
26
27double RooStats::NumberCountingUtils::BinomialExpP(double signalExp, double backgroundExp, double relativeBkgUncert){
28 // Expected P-value for s=0 in a ratio of Poisson means.
29 // Here the background and its uncertainty are provided directly and
30 // assumed to be from the double Poisson counting setup described in the
31 // BinomialWithTau functions.
32 // Normally one would know tau directly, but here it is determiend from
33 // the background uncertainty. This is not strictly correct, but a useful
34 // approximation.
35
36
37 //SIDE BAND EXAMPLE
38 //See Eqn. (19) of Cranmer and pp. 36-37 of Linnemann.
39 //150 total events in signalExp region, 100 in sideband of equal size
40 double mainInf = signalExp+backgroundExp; //Given
41 double tau = 1./backgroundExp/(relativeBkgUncert*relativeBkgUncert);
42 double auxiliaryInf = backgroundExp*tau; //Given
43
44 double P_Bi = TMath::BetaIncomplete(1./(1.+tau),mainInf,auxiliaryInf+1);
45 return P_Bi;
46
47/*
48Now, if instead the mean background level b in the signal region is
49specified, along with Gaussian rms sigb, then one can fake a Poisson
50sideband (see Linnemann, p. 35, converted to Cranmer's notation) by
51letting tau = b/(sigb*sigb) and y = b*tau. Thus, for example, if one
52has x=150 and b = 100 +/- 10, one then derives tau and y. Then one
53has the same two lines of ROOT calling BetaIncomplete and ErfInverse.
54Since I chose these numbers to revert to the previous example, we get
55the same answer:
56*/
57/*
58//GAUSSIAN FAKED AS POISSON EXAMPLE
59x = 150. //Given
60b = 100. //Given
61sigb = 10. //Given
62tau = b/(sigb*sigb)
63y = tau*b
64Z_Bi = TMath::BetaIncomplete(1./(1.+tau),x,y+1)
65S = sqrt(2)*TMath::ErfInverse(1 - 2*Z_Bi)
66
67*/
68
69}
70
71
72double RooStats::NumberCountingUtils::BinomialWithTauExpP(double signalExp, double backgroundExp, double tau){
73 // Expected P-value for s=0 in a ratio of Poisson means.
74 // Based on two expectations, a main measurement that might have signal
75 // and an auxiliarly measurement for the background that is signal free.
76 // The expected background in the auxiliary measurement is a factor
77 // tau larger than in the main measurement.
78
79 double mainInf = signalExp+backgroundExp; //Given
80 double auxiliaryInf = backgroundExp*tau; //Given
81
82 double P_Bi = TMath::BetaIncomplete(1./(1.+tau),mainInf,auxiliaryInf+1);
83
84 return P_Bi;
85
86}
87
88double RooStats::NumberCountingUtils::BinomialObsP(double mainObs, double backgroundObs, double relativeBkgUncert){
89 // P-value for s=0 in a ratio of Poisson means.
90 // Here the background and its uncertainty are provided directly and
91 // assumed to be from the double Poisson counting setup.
92 // Normally one would know tau directly, but here it is determiend from
93 // the background uncertainty. This is not strictly correct, but a useful
94 // approximation.
95
96 double tau = 1./backgroundObs/(relativeBkgUncert*relativeBkgUncert);
97 double auxiliaryInf = backgroundObs*tau; //Given
98
99
100 //SIDE BAND EXAMPLE
101 //See Eqn. (19) of Cranmer and pp. 36-37 of Linnemann.
102 double P_Bi = TMath::BetaIncomplete(1./(1.+tau),mainObs,auxiliaryInf+1);
103
104 return P_Bi;
105
106}
107
108
109double RooStats::NumberCountingUtils::BinomialWithTauObsP(double mainObs, double auxiliaryObs, double tau){
110 // P-value for s=0 in a ratio of Poisson means.
111 // Based on two observations, a main measurement that might have signal
112 // and an auxiliarly measurement for the background that is signal free.
113 // The expected background in the auxiliary measurement is a factor
114 // tau larger than in the main measurement.
115
116 //SIDE BAND EXAMPLE
117 //See Eqn. (19) of Cranmer and pp. 36-37 of Linnemann.
118 double P_Bi = TMath::BetaIncomplete(1./(1.+tau),mainObs,auxiliaryObs+1);
119
120 return P_Bi;
121
122}
123
124double RooStats::NumberCountingUtils::BinomialExpZ(double signalExp, double backgroundExp, double relativeBkgUncert) {
125 // See BinomialExpP
126 return RooStats::PValueToSignificance( BinomialExpP(signalExp,backgroundExp,relativeBkgUncert) ) ;
127 }
128
129double RooStats::NumberCountingUtils::BinomialWithTauExpZ(double signalExp, double backgroundExp, double tau){
130 // See BinomialWithTauExpP
131 return RooStats::PValueToSignificance( BinomialWithTauExpP(signalExp,backgroundExp,tau) ) ;
132}
133
134
135double RooStats::NumberCountingUtils::BinomialObsZ(double mainObs, double backgroundObs, double relativeBkgUncert){
136 // See BinomialObsP
137 return RooStats::PValueToSignificance( BinomialObsP(mainObs,backgroundObs,relativeBkgUncert) ) ;
138}
139
140double RooStats::NumberCountingUtils::BinomialWithTauObsZ(double mainObs, double auxiliaryObs, double tau){
141 // See BinomialWithTauObsP
142 return RooStats::PValueToSignificance( BinomialWithTauObsP(mainObs,auxiliaryObs,tau) ) ;
143}
double BinomialWithTauExpZ(double sExp, double bExp, double tau)
See BinomialWithTauExpP.
double BinomialExpZ(double sExp, double bExp, double fractionalBUncertainty)
Expected P-value for s=nullptr in a ratio of Poisson means.
double BinomialExpP(double sExp, double bExp, double fractionalBUncertainty)
See BinomialExpP.
double BinomialWithTauObsZ(double nObs, double bExp, double tau)
See BinomialWithTauObsP.
double BinomialObsP(double nObs, double, double fractionalBUncertainty)
P-value for s=nullptr in a ratio of Poisson means.
double BinomialWithTauExpP(double sExp, double bExp, double tau)
Expected P-value for s=nullptr in a ratio of Poisson means.
double BinomialWithTauObsP(double nObs, double bExp, double tau)
P-value for s=nullptr in a ratio of Poisson means.
double BinomialObsZ(double nObs, double bExp, double fractionalBUncertainty)
See BinomialObsP.
double PValueToSignificance(double pvalue)
returns one-sided significance corresponding to a p-value
Double_t BetaIncomplete(Double_t x, Double_t a, Double_t b)
Calculates the incomplete Beta-function.
Definition TMath.cxx:2103