# Test Non Central¶

Author: Lorenzo Moneta
This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Saturday, April 17, 2021 at 10:33 AM.

In :
%%cpp -d
// This is a workaround to make sure the namespace is used inside functions
using namespace RooFit;

In :
RooWorkspace w("w");

RooFit v3.60 -- Developed by Wouter Verkerke and David Kirkby
Copyright (C) 2000-2013 NIKHEF, University of California & Stanford University
All rights reserved, please read http://roofit.sourceforge.net/license.txt



K <2, must use sum

In :
w.factory("NonCentralChiSquare::nc(x[0,50],k[1.99,0,5],lambda)");


Kk > 2 can use bessel

In :
w.factory("NonCentralChiSquare::ncc(x,kk[2.01,0,5],lambda)");


Kk > 2, force sum

In :
w.factory("NonCentralChiSquare::nccc(x,kk,lambda)");
((RooNonCentralChiSquare *)w.pdf("nccc"))->SetForceSum(true);


A normal "central" chi-square for comparison when lambda->0

In :
w.factory("ChiSquarePdf::cs(x,k)");


W.var("kk")->setval(4.); // test a large kk

In :
RooDataSet *ncdata = w.pdf("nc")->generate(*w.var("x"), 100);
RooDataSet *csdata = w.pdf("cs")->generate(*w.var("x"), 100);
RooPlot *plot = w.var("x")->frame();
ncdata->plotOn(plot, MarkerColor(kRed));
csdata->plotOn(plot, MarkerColor(kBlue));
w.pdf("nc")->plotOn(plot, LineColor(kRed));
w.pdf("ncc")->plotOn(plot, LineColor(kGreen));
w.pdf("nccc")->plotOn(plot, LineColor(kYellow), LineStyle(kDashed));
w.pdf("cs")->plotOn(plot, LineColor(kBlue), LineStyle(kDotted));
plot->Draw();

[#0] WARNING:Plotting -- Cannot apply a bin width correction and use Poisson errors. Not correcting for bin width.
[#0] WARNING:Plotting -- Cannot apply a bin width correction and use Poisson errors. Not correcting for bin width.
[#1] INFO:InputArguments -- RooNonCentralChiSquare sum being forced
[#0] WARNING:Eval -- RooNonCentralChiSquare did not converge: for x=36 k=2.01, lambda=5 fractional error = 0.00108172
either adjust tolerance with SetErrorTolerance(tol) or max_iter with SetMaxIter(max_it)

Info in <TCanvas::MakeDefCanvas>:  created default TCanvas with name c1


Draw all canvases

In :
%jsroot on
gROOT->GetListOfCanvases()->Draw()