ROOT
Version v6.32
master
v6.34
v6.30
v6.28
v6.26
v6.24
v6.22
v6.20
v6.18
v6.16
v6.14
v6.12
v6.10
v6.08
v6.06
Reference Guide
►
ROOT
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
Zbi_Zgamma.py
Go to the documentation of this file.
1
## \file
2
## \ingroup tutorial_roostats
3
## \notebook -js
4
## Demonstrate Z_Bi = Z_Gamma
5
##
6
## \macro_image
7
## \macro_output
8
## \macro_code
9
##
10
## \date July 2022
11
## \authors Artem Busorgin, Kyle Cranmer and Wouter Verkerke (C++ version)
12
13
import
ROOT
14
15
# Make model for prototype on/off problem
16
# Pois(x | s+b) * Pois(y | tau b )
17
# for Z_Gamma, use uniform prior on b.
18
w1 =
ROOT.RooWorkspace
(
"w"
)
19
w1.factory
(
"Poisson::px(x[150,0,500],sum::splusb(s[0,0,100],b[100,0,300]))"
)
20
w1.factory
(
"Poisson::py(y[100,0,500],prod::taub(tau[1.],b))"
)
21
w1.factory
(
"Uniform::prior_b(b)"
)
22
23
# construct the Bayesian-averaged model (eg. a projection pdf)
24
# p'(x|s) = \int db p(x|s+b) * [ p(y|b) * prior(b) ]
25
w1.factory
(
"PROJ::averagedModel(PROD::foo(px|b,py,prior_b),b)"
)
26
27
c =
ROOT.TCanvas
()
28
29
# plot it, blue is averaged model, red is b known exactly
30
frame = w1[
"x"
].frame()
31
w1[
"averagedModel"
].plotOn(frame)
32
w1[
"px"
].plotOn(frame, LineColor=
ROOT.kRed
)
33
frame.Draw
()
34
35
# compare analytic calculation of Z_Bi
36
# with the numerical RooFit implementation of Z_Gamma
37
# for an example with x = 150, y = 100
38
39
# numeric RooFit Z_Gamma
40
w1[
"y"
].setVal(100)
41
w1[
"x"
].setVal(150)
42
cdf = w1[
"averagedModel"
].createCdf(w1[
"x"
])
43
cdf.getVal
()
# get ugly print messages out of the way
44
45
print(
"Hybrid p-value = "
,
cdf.getVal
())
46
print(
"Z_Gamma Significance = "
,
ROOT.RooStats.PValueToSignificance
(1 -
cdf.getVal
()))
47
48
# analytic Z_Bi
49
Z_Bi =
ROOT.RooStats.NumberCountingUtils.BinomialWithTauObsZ
(150, 100, 1)
50
print(
"Z_Bi significance estimation: "
, Z_Bi)
51
52
c.SaveAs
(
"Zbi_Zgamma.png"
)
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
tutorials
roostats
Zbi_Zgamma.py
ROOT v6-32 - Reference Guide Generated on Mon Mar 31 2025 15:38:52 (GVA Time) using Doxygen 1.10.0