Degrees of freedom via Chi2 for TH1

Apologies in advance for what I’m sure is a naive question.

I’m attempting to apply the Chi2Test function to compare two histogram distributions. If I use the option ‘CHI2’ within this function, the chi2 value is returned, whilst using ‘CHI2/NDF’ returns the reduced chi-squared value.

I want to know the number of degrees of freedom involved in this calculation. Since there doesn’t seem to be some sort of function belonging to the TH1 class that returns this, I assumed it would be valid to divide the chi-squared value by the reduced chi-squared value. Doing this returns a value of 39 for two particular histograms.

However, both of these histograms have 50 bins each. Where exactly are the other 11 degrees of freedom going? Does plotting my variable somehow involve 11 parameters? (I’m comparing pT distributions).


In the histogram-histogram comparison, the number of degrees of freedom is the number of bins, but excluding the empty bins which are not used in the chi2 test.
I remind you that the obtained chi2 value follows a chi2 distributions with n degree of freedom, only when the histogram bin content is not too small and the bin uncertainties can be approximated by a normal distribution.

Best Regards


1 Like

Hi Lorenzo,

Thank you for your fast response. I’ve marked the topic as solved.