Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TestNonCentral.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_roostats
3/// \notebook -js
4/// Demonstrates non central chi-square.
5///
6/// \macro_image
7/// \macro_output
8/// \macro_code
9///
10/// \author Lorenzo Moneta
11
12using namespace RooFit;
13void TestNonCentral()
14{
15
16 RooWorkspace w("w");
17 // k <2, must use sum
18 w.factory("NonCentralChiSquare::nc(x[0,50],k[1.99,0,5],lambda[5])");
19 // kk > 2 can use bessel
20 w.factory("NonCentralChiSquare::ncc(x,kk[2.01,0,5],lambda)");
21 // kk > 2, force sum
22 w.factory("NonCentralChiSquare::nccc(x,kk,lambda)");
23 ((RooNonCentralChiSquare *)w.pdf("nccc"))->SetForceSum(true);
24
25 // a normal "central" chi-square for comparison when lambda->0
26 w.factory("ChiSquarePdf::cs(x,k)");
27
28 // w.var("kk")->setVal(4.); // test a large kk
29
30 std::unique_ptr<RooDataSet> ncdata{w.pdf("nc")->generate(*w.var("x"), 100)};
31 std::unique_ptr<RooDataSet> csdata{w.pdf("cs")->generate(*w.var("x"), 100)};
32 RooPlot *plot = w.var("x")->frame();
33 ncdata->plotOn(plot, MarkerColor(kRed));
34 csdata->plotOn(plot, MarkerColor(kBlue));
35 w.pdf("nc")->plotOn(plot, LineColor(kRed));
36 w.pdf("ncc")->plotOn(plot, LineColor(kGreen));
37 w.pdf("nccc")->plotOn(plot, LineColor(kYellow), LineStyle(kDashed));
38 w.pdf("cs")->plotOn(plot, LineColor(kBlue), LineStyle(kDotted));
39 plot->Draw();
40}
@ kRed
Definition Rtypes.h:66
@ kGreen
Definition Rtypes.h:66
@ kBlue
Definition Rtypes.h:66
@ kYellow
Definition Rtypes.h:66
@ kDashed
Definition TAttLine.h:48
@ kDotted
Definition TAttLine.h:48
winID h TVirtualViewer3D TVirtualGLPainter char TVirtualGLPainter plot
The PDF of the Non-Central Chi Square distribution for n degrees of freedom.
Plot frame and a container for graphics objects within that frame.
Definition RooPlot.h:43
Persistable container for RooFit projects.
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition TObject.cxx:292
RooCmdArg MarkerColor(Color_t color)
RooCmdArg LineColor(Color_t color)
RooCmdArg LineStyle(Style_t style)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition CodegenImpl.h:64