# Chi squared of two histograms

Hi all,

I want to compare two histograms in terms of chi-squared (LaTeX equation):
\chi ^{2}= \sum (\frac{(n^{data}-n^{mc})^{2}}{\sigma_{data}^{2}+\sigma_{mc}^{2} })
where we sum over all bins
n is the number od entries for data and mc respectively
sigma is statistic uncertainty for data and mc respectively

I know there is a built-in option in ROOT like GetChisquare() but I dont know how to use it for two histograms comparison

Now, let h1 be “data” histogram and h2 “mc” histogram
TH1F *h1 = new TH1F(*data)
TH1F *h2 = new TH1F(*mc)

How can I get Chi-squared from the equation above between h1 and h2?

Currently available statistical tests of compatibility in shape between histograms:
TH1::AndersonDarlingTest
TH1::Chi2Test
TH1::KolmogorovTest

root [3] h1->Chi2Test(h2,“UU”)
Warning in TH1F::Chi2TestX: Both histograms are not unweighted and option UU has been requested
(double) 0.000000

Whys not working this way?

This message comes from here.
I am not sure why you ended up there in your case.
Maybe @moneta knows.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.