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 *) 0x55f791e32290
{
h1->SetTitle(
"Unweighted Histogram");
h1->SetBinContent(9, 22);
h1->SetBinContent(10, 30);
h1->SetBinContent(11, 27);
h1->SetBinContent(12, 20);
h1->SetBinContent(13, 13);
h1->SetBinContent(14, 9);
h1->SetBinContent(15, 9 +
w);
h1->SetBinContent(16, 13);
h1->SetBinContent(17, 19);
h1->SetBinContent(18, 11);
h1->SetBinContent(19, 9);
h1->SetBinContent(20, 0);
h1->Chi2Test(h2,
"UW P",res);
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");
}
int Int_t
Signed integer 4 bytes (int).
float Float_t
Float 4 bytes (float).
double Double_t
Double 8 bytes.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void w
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
virtual void SetRangeUser(Double_t ufirst, Double_t ulast)
Set the viewing range for the axis from ufirst to ulast (in user coordinates, that is,...
This class allows to draw quantile-quantile plots.
void Draw(Option_t *chopt="") override
Default Draw method for all objects.
void SetTitle(const char *title="") override
Set the title of the TNamed.
1-D histogram with a double per channel (see TH1 documentation)
void SetTitle(const char *title) override
Set the title of the TNamed.
void Draw(Option_t *option="") override
Default Draw method for all objects.
virtual void SetBinError(Int_t bin, Double_t error)
virtual void SetBinContent(Int_t bin, Double_t content)
virtual void SetEntries(Double_t n)
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
- Author
- Nikolai Gagunashvili, Daniel Haertl, Lorenzo Moneta
Definition in file chi2test.C.