39 w = ROOT.RooWorkspace(
"w")
40 w.factory(
"Uniform::u(x[0,1])")
41 w.factory(
"mu[100,1,200]")
42 w.factory(
"ExtendPdf::p(u,mu)")
44 asimov = w.pdf(
"p").generateBinned(w[
"x"], ExpectedData=
True)
46 res = w.pdf(
"p").fitTo(asimov, Save=
True, SumW2Error=
True)
50 cov = res.covarianceMatrix()
51 print(
"variance = ", (cov.Determinant()))
52 print(
"stdev = ", cov.Determinant() ** 0.5)
54 print(
"jeffreys = ", cov.Determinant() ** 0.5)
56 w.defineSet(
"poi",
"mu")
57 w.defineSet(
"obs",
"x")
59 pi = ROOT.RooJeffreysPrior(
"jeffreys",
"jeffreys", w.pdf(
"p"), w.set(
"poi"), w.set(
"obs"))
61 test = ROOT.RooGenericPdf(
"Expected",
"Expected = 1/#sqrt#mu",
"1./sqrt(mu)", w.set(
"poi"))
64 plot = w[
"mu"].frame()
66 test.plotOn(plot, LineColor=
"r", LineStyle=ROOT.kDashDotted)
69 legend = plot.BuildLegend()
74 c1.SaveAs(
"rs302_JeffreysPriorDemo.1.png")
78def TestJeffreysGaussMean():
80 w = ROOT.RooWorkspace(
"w")
81 w.factory(
"Gaussian.g(x[0,-20,20],mu[0,-5.,5],sigma[1,0,10])")
82 w.factory(
"n[10,.1,200]")
83 w.factory(
"ExtendPdf.p(g,n)")
84 w.var(
"sigma").setConstant()
85 w.var(
"n").setConstant()
87 asimov = w.pdf(
"p").generateBinned(w.var(
"x"), ExpectedData())
89 resw.pdf(
"p").fitTo(asimov, Save(), SumW2Error(
True))
93 cov = res.covarianceMatrix()
94 print(
"variance = ", (cov.Determinant()))
95 print(
"stdev = ", sqrt(cov.Determinant()))
97 print(
"jeffreys = ", sqrt(cov.Determinant()))
99 w.defineSet(
"poi",
"mu")
100 w.defineSet(
"obs",
"x")
102 pi =
RooJeffreysPrior(
"jeffreys",
"jeffreys", w.pdf(
"p"), w.set(
"poi"), w.set(
"obs"))
105 pi.getParameters(temp).
Print()
108 test =
RooGenericPdf(
"constant",
"Expected = constant",
"1", w.set(
"poi"))
111 plot = w.var(
"mu").frame()
113 test.plotOn(plot, LineColor(kRed), LineStyle(kDashDotted))
116 legend = plot.BuildLegend()
120 c2.SaveAs(
"rs302_JeffreysPriorDemo.2.png")
124def TestJeffreysGaussSigma():
132 w.factory(
"Gaussian.g(x[0,-20,20],mu[0,-5,5],sigma[1,1,5])")
133 w.factory(
"n[100,.1,2000]")
134 w.factory(
"ExtendPdf.p(g,n)")
136 w.var(
"mu").setConstant()
137 w.var(
"n").setConstant()
138 w.var(
"x").setBins(301)
140 asimov = w.pdf(
"p").generateBinned(w.var(
"x"), ExpectedData())
142 resw.pdf(
"p").fitTo(asimov, Save(), SumW2Error(
True))
146 cov = res.covarianceMatrix()
147 print(
"variance = ", (cov.Determinant()))
148 print(
"stdev = ", sqrt(cov.Determinant()))
150 print(
"jeffreys = ", sqrt(cov.Determinant()))
152 w.defineSet(
"poi",
"sigma")
153 w.defineSet(
"obs",
"x")
155 pi =
RooJeffreysPrior(
"jeffreys",
"jeffreys", w.pdf(
"p"), w.set(
"poi"), w.set(
"obs"))
158 pi.getParameters(temp).
Print()
160 test =
RooGenericPdf(
"test",
"Expected = #sqrt2/#sigma",
"sqrt(2.)/sigma", w.set(
"poi"))
163 plot = w.var(
"sigma").frame()
165 test.plotOn(plot, LineColor(kRed), LineStyle(kDashDotted))
168 legend = plot.BuildLegend()
172 c3.SaveAs(
"rs302_JeffreysPriorDemo.3.png")
176def TestJeffreysGaussMeanAndSigma():
184 w.factory(
"Gaussian.g(x[0,-20,20],mu[0,-5,5],sigma[1,1.,5.])")
185 w.factory(
"n[100,.1,2000]")
186 w.factory(
"ExtendPdf.p(g,n)")
188 w.var(
"n").setConstant()
189 w.var(
"x").setBins(301)
191 asimov = w.pdf(
"p").generateBinned(w.var(
"x"), ExpectedData())
193 resw.pdf(
"p").fitTo(asimov, Save(), SumW2Error(
True))
197 cov = res.covarianceMatrix()
198 print(
"variance = ", (cov.Determinant()))
199 print(
"stdev = ", sqrt(cov.Determinant()))
201 print(
"jeffreys = ", sqrt(cov.Determinant()))
203 w.defineSet(
"poi",
"mu,sigma")
204 w.defineSet(
"obs",
"x")
206 pi =
RooJeffreysPrior(
"jeffreys",
"jeffreys", w.pdf(
"p"), w.set(
"poi"), w.set(
"obs"))
209 pi.getParameters(temp).
Print()
213 Jeff2d = pi.createHistogram(
214 "2dJeffreys", w.var(
"mu"), Binning(10, -5.0, 5), YVar(w.var(
"sigma"), Binning(10, 1.0, 5.0))
219 c4.SaveAs(
"rs302_JeffreysPriorDemo.4.png")
void Print(GNN_Data &d, std::string txt="")
Implementation of a probability density function that takes a RooArgList of servers and a C++ express...
Implementation of Jeffrey's prior.
Persistable container for RooFit projects.