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.
Chi2 = 21.085124, Prob = 0.332116, NDF = 19, igood = 1
(TCanvas *) 0x26d7040
{
for (
Int_t i=0; i<
n; i++)
x[i]= 4.+i*12./20.+12./40.;
resgr->GetXaxis()->SetRangeUser(4,16);
resgr->GetYaxis()->SetRangeUser(-3.5,3.5);
resgr->GetYaxis()->SetTitle(
"Normalized Residuals");
resgr->SetMarkerStyle(21);
resgr->SetMarkerColor(2);
resgr->SetMarkerSize(.9);
resgr->SetTitle(
"Normalized Residuals");
TF1 *
f =
new TF1(
"f",
"TMath::Gaus(x,0,1)",-10,10);
qqplot->SetTitle(
"Q-Q plot of Normalized Residuals");
}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
This class allows to draw quantile-quantile plots.
A TGraph is an object made of two arrays X and Y with npoints each.
1-D histogram with a double per channel (see TH1 documentation)
void SetTitle(const char *title) override
Change/set the title.
virtual void SetBinError(Int_t bin, Double_t error)
Set the bin Error Note that this resets the bin eror option to be of Normal Type and for the non-empt...
void Draw(Option_t *option="") override
Draw this histogram with options.
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content see convention for numbering bins in TH1::GetBin In case the bin number is greater th...
virtual Double_t Chi2Test(const TH1 *h2, Option_t *option="UU", Double_t *res=nullptr) const
test for comparing weighted and unweighted histograms.
virtual void SetEntries(Double_t n)
- Author
- Nikolai Gagunashvili, Daniel Haertl, Lorenzo Moneta
Definition in file chi2test.C.