# Kolmogorov-Smirnov Test Mean

**URL:** <https://root-forum.cern.ch/t/kolmogorov-smirnov-test-mean/36385>\
**Category:** TMVA\
**Created:** [October 17, 2019, 1:08pm UTC](https://root-forum.cern.ch/t/kolmogorov-smirnov-test-mean/36385 "2019-10-17T13:08:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anprodri](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/8dc957/32.png) [@anprodri](https://root-forum.cern.ch/u/anprodri)\
**Post date:** [October 17, 2019, 1:08pm UTC](https://root-forum.cern.ch/t/kolmogorov-smirnov-test-mean/36385/1 "2019-10-17T13:08:40Z")

</div>

Hi again!

I have a question about KS-Test, it is related to a previous post answer:

> [@Kolmogorov-Smirnov test values](https://root-forum.cern.ch/t/kolmogorov-smirnov-test-values/32868/):
>
> Dear TMVA users, I have a very quick question regarding the KS test used to check for overtraining. I have been using the BDT method with the following number of events: Signal – training events : 21889 Signal – testing events : 21889 Signal – training and testing events: 43778 Background – training events : 53955 Background – testing events : 53955 Background – training and testing events: 107910 And when checking the BDT score d…

I couldn’t find any info about KS-test on the guide, and I still don’t understand why it’s optimal value is 0.5? how is it calculated exactly?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [October 17, 2019, 2:11pm UTC](https://root-forum.cern.ch/t/kolmogorov-smirnov-test-mean/36385/2 "2019-10-17T14:11:35Z")

</div>

Maybe @moneta can give you some hints

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [October 17, 2019, 3:04pm UTC](https://root-forum.cern.ch/t/kolmogorov-smirnov-test-mean/36385/3 "2019-10-17T15:04:49Z")

</div>

Hi,

A Kolmogorov Smirnov test is applied between the training and the test output distribution. In case the two distributions are compatible a random value between 0 and 1 should be obtained, if they are not you will observe a difference and this might be an indication of overtraining. So a very small value is not good. A value which is not small is good, while a value too close to 1 is also no so good, because indicates that the statistical fluctuations are too small, and this can be also an indication of some potential problems.

See [https://root.cern.ch/doc/master/classTH1.html#aeadcf087afe6ba203bcde124cfabbee4](https://root.cern.ch/doc/master/classTH1.html#aeadcf087afe6ba203bcde124cfabbee4)

Lorenzo

---

<div class="post-metadata">

**Author:** ![anprodri](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/8dc957/32.png) [@anprodri](https://root-forum.cern.ch/u/anprodri)\
**Post date:** [October 17, 2019, 3:24pm UTC](https://root-forum.cern.ch/t/kolmogorov-smirnov-test-mean/36385/4 "2019-10-17T15:24:49Z")

</div>

Thanks for the answer!

Then, what would mean that the value is close to 0?

---

<div class="post-metadata">

**Author:** ![kialbert](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/kialbert/32/16537_2.png) [@kialbert](https://root-forum.cern.ch/u/kialbert)\
**Post date:** [October 17, 2019, 6:16pm UTC](https://root-forum.cern.ch/t/kolmogorov-smirnov-test-mean/36385/5 "2019-10-17T18:16:05Z")

</div>

Hi,

Are you asking about the KS score in the TMVA output?

For the TMVA plot several KS tests are performed and their average reported. As Lorenzo explained, for a single test, if the two distributions are equal, the result will be a value between 0 and 1 (uniform dist). The expectation for the average is then 0.5.

A value close to 0 (in this case with repeated experiments) mean that the two distributions are dissimilar.

Cheers,  
Kim
