Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TestNonCentral.py
Go to the documentation of this file.
1# \file
2# \ingroup tutorial_roostats
3# \notebook -js
4#
5# \macro_image
6# \macro_output
7# \macro_code
8#
9# \author Lorenzo Moneta
10
11import ROOT
12
13ws = ROOT.RooWorkspace("w")
14# k <2, must use sum
15ws.factory("NonCentralChiSquare::nc(x[0,50],k[1.99,0,5],lambda[5])")
16# kk > 2 can use bessel
17ws.factory("NonCentralChiSquare::ncc(x,kk[2.01,0,5],lambda)")
18# kk > 2, force sum
19ws.factory("NonCentralChiSquare::nccc(x,kk,lambda)")
20ws["nccc"].SetForceSum(True)
21
22# a normal "central" chi-square for comparison when lambda->0
23ws.factory("ChiSquarePdf::cs(x,k)")
24
25# w.var("kk").setVal(4.) # test a large kk
26
27ncdata = ws["nc"].generate(ws["x"], 100)
28csdata = ws["cs"].generate(ws["x"], 100)
29plot = ws["x"].frame()
30ncdata.plotOn(plot, MarkerColor="r")
31csdata.plotOn(plot, MarkerColor="b")
32ws["nc"].plotOn(plot, LineColor="r")
33ws["ncc"].plotOn(plot, LineColor="g")
34ws["nccc"].plotOn(plot, LineColor="y", LineStyle="--")
35ws["cs"].plotOn(plot, LineColor="b", LineStyle=":")
36plot.Draw()