Chi2 and DOF between TH1F and TF1 (not from fit)


I’m fitting a distribution (dijet invariant mass) obtained with a Monte Carlo simulation with an analytic formula. The histogram is filled with unweighted events but is normalized to unit area. The fit is performed in a limited range (3-10 TeV), but the histogram has a broader range (0-10 TeV). I want to calculate the chi2/dof between the fitted function and another histogram that I created with a different simulation. It seems very cumbersome to do that, as TH1::Chi2Test() only accepts a TH1 as an argument, and TH1::Chisquare() does not return the DOF. Is there any other way to do this?


_ROOT Version: 6.14/06
_Platform: Ubuntu 13
_Compiler: pyroot / gcc-7.3.0 / python 2.7

I think @moneta can help you.


The function to use is TH1::Chi-square, that can also compute the Poisson Likelihood ratio value as suggested by Baker and Cousins (_S. Baker and R. D. Cousins, “Clarification of the use of chi-square and likelihood functions in fits to histograms,” Nucl. Instrum. Meth. 221 (1984) 43_7)

The DOF is simply the number of bins of the histogram (or the bins in the range). In case of Neymar chi-square only the non-empty bins are considered


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