Hello ROOTers,

I’m trying to compare two binned histograms with “KolmogorovTest” to check if they are compatible in shape and also in absolute values (for each bin). Both histograms have 17 bins, the “# of counts” goes from 0.1 to 1 and each bin has its corresponding error (not just statistical). Before do the check, both histograms were scaled by a factor 100. I’m calling the function like this:

prob = hist1->KolmogorovTest(hist2,“N”);

and the result is prob = 0.0528. The first bin in “hist2” has a huge error and within the error that point in “hist2” agrees with “hist1”. The problem appears when I redo the test removing the first bin. The prob jumps from 0.0528 to 0.9860. Since the error of that point is so big, that point should not affect that much the resulting probability. It seems that the function just take sqrt of the counts instead of the real error in the histogram. If this is true how can I perform the test using the error in that bin content?

I’m using ROOT Version 5.15/08 on LinuxRH9 and CINT/ROOT C/C++ Interpreter version 5.16.19

Both histograms are in the attached ROOT file.

Best regards,
histograms.root (4.34 KB)


the Kolmogorov test is based on the differences (distances) in the empirical cumulative distributions. It looks therefore only at the bin contents and it does not consider the errors.
If you want to use the bin errors (i.e. weighted histograms) you should use the chi2 test with option “WW”.
(see root.cern.ch/root/htmldoc/TH1.html#TH1:Chi2Test)

Best Regards


Hi Lorenzo,

Thanks for your fast reply. Actually its not clear to me why I should use “WW”. I thought the correct option should be “UU”. Using the “WW” option and calling:

prob = hist1->Chi2Test(hist2,“WW”,&res[0]);

I got the following message:

Error in TH1F::ChistatTestX: Hist2: zero events in bin (1,1,1)

When using “UU”, I don’t get the error message, but again the result seems do not depend on the bin errors.

I don’t understand what is going on !! Please, remember I’ve attached the histograms in the previous message.

Thanks again,


if the errors are not sqrt(N), you should use the “WW” option.

Which ROOT version are you using ? With the latest, 5.22, running with your histograms I get:

The info message is just a warning indicating that the test might be not very reliable, since there are too few events in some bins.

Best Regards


Hi Lorenzo,

Now I understand better how to deal with these options.
Concerning the versions, I was using the version 5.18 and I was getting that error message (I don’t know why??)

Using 5.22 version, now I get the same result as you.
Thank you for your help.


There was a bug which it was fixed I think for version 5.20.