Example to use chi2 test for comparing two histograms One unweighted histogram is compared with a weighted histogram.
The normalized residuals are retrieved and plotted in a simple graph. The QQ plot of the normalized residual using the normal distribution is also plotted.
Processing /mnt/build/workspace/root-makedoc-v614/rootspi/rdoc/src/v6-14-00-patches/tutorials/math/chi2test.C...
Chi2 = 21.085124, Prob = 0.332116, NDF = 19, igood = 1
(TCanvas *) 0x2ce5000
{
TH1D *h1 =
new TH1D(
"h1",
"h1", n, 4, 16);
TH1D *h2 =
new TH1D(
"h2",
"h2", n, 4, 16);
for (
Int_t i=0; i<
n; i++) x[i]= 4.+i*12./20.+12./40.;
resgr->
SetTitle(
"Normalized Residuals");
TF1 *f =
new TF1(
"f",
"TMath::Gaus(x,0,1)",-10,10);
qqplot->
SetTitle(
"Q-Q plot of Normalized Residuals");
}
- Author
- Nikolai Gagunashvili, Daniel Haertl, Lorenzo Moneta
Definition in file chi2test.C.