Here is something I am unable to explain. I use TH1::FillRandom() to fill two histograms from a base template histogram. Then I perform a chi-square comparison between the two filled histograms.
Over a large number of toys, I naively expect the distribution of this chi-square to be that of a true chi-square distribution with degrees of freedom = number of bins. So the mean should be close to the number of bins.
But I find this to not be the case. I run 100k toys in each run, and results vary from run to run, and in some cases the mean is quite different from the expectation.
I attach code to reproduce what I do, and a plot of the chi2 distribution from one of my runs. Note that the mean should be 20, since there are 20 bins.
It is quite possible that I am misusing the rng’s in some way. So I would appreciate any feedback on this.
I am using ROOT 6.22.06, invoked by source /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.22.06/x86_64-centos7-gcc48-opt/bin/thisroot.sh;