TMath::KolmogorovTest returns a wrong value?

Hi,
I am comparing 2 ks values returned from:

TMath::KolmogorovTest

and

hist1->KolmogorovTest(hist2);

in TH1.

Due to my understanding, if we set histogram’s bin size as small as possible, they should return the similar result. However, I cannot get this through. I have a test attached. Please help figure it out why?

Either I use the method in TMath wrongly or I misunderstand something, or there is a bug in the function.

I am using: root_v5-23src_trunk

Thank you,
Zhiyi.
test_KS.C (20.5 KB)

Hi,

in TMath::KolmogorovTest the arrays need to be sorted before.
See root.cern.ch/root/htmldoc/TMath. … ogorovTest

In your example you just need to add these two lines before calling TMath::KolmogorovTest:

  std::sort(a,a+N_a);
  std::sort(b,b+N_b);

Best Regards

Lorenzo

Aha, thanks for the hint.

I am wondering why the sorting is not done internally although I admit that I should read the document carefully next time.

Thanks,
Zhiyi.