2
$\begingroup$

enter image description here

Does anyone know that why in the Kolmogorov-Smirnov Test, the empirical distribution function is compared with the cumulative distribution function and not the probability distribution function? Is there a reason behind this?

Source: https://en.wikipedia.org/wiki/Kolmogorov%E2%80%93Smirnov_test

$\endgroup$
5
  • 4
    $\begingroup$ Difficult to know what kind of explanation would satisfy here. The empirical density function for a continuous variable is just a series of spikes at the observed values. That's hard to work with. $\endgroup$
    – Nick Cox
    Oct 7, 2021 at 7:59
  • 1
    $\begingroup$ The empirical cdf is an estimator of the theoretical cdf, so it is hard to fathom why it should be compared with the theoretical pdf. $\endgroup$
    – Xi'an
    Oct 7, 2021 at 8:27
  • 1
    $\begingroup$ @Xian I guess the OP is asking why is K-S not about comparing empirical and theoretical PDFs. That is a different problem is a short reply. $\endgroup$
    – Nick Cox
    Oct 7, 2021 at 9:40
  • 1
    $\begingroup$ The comparison of cdfs is (i) well defined and (ii) distribution-free. With pdfs you get neither - e.g. what's the definition of sample pdf? $\endgroup$
    – Glen_b
    Oct 8, 2021 at 5:23
  • 1
    $\begingroup$ This is a very strange question. K-S test is on CDFs. If you somehow build a test on PDFs then it wouldn't be K-S test, right? It's like asking why ping-pong isn't played with hockey sticks. $\endgroup$
    – Aksakal
    Nov 9, 2021 at 1:57

3 Answers 3

6
$\begingroup$

I think it's because comparing empirical pdf with theoretical pdf is not feasible (or hard to do).

Empirical pdf is just a finite sum of Diracs : it is not a function with computable values so how would you compare it with a nice continuous theoretical pdf?

You could try comparing a histogram with the theoretical pdf, but then comes the problem of choosing the width of the histogram bars. Same holds for any estimator density: if you were to use kernel estimation, you would need to chose a bandwidth, and probably make this bandwidth shrink with your sample size.

You would also need some asymptotic results on the distribution of the mismatch between the estimated and true pdf, which I'm not sure exist.

$\endgroup$
5
  • $\begingroup$ Why doesn't the point about bandwidth also hold for eCDFs? That is, why are histograms somehow problematic to compare, but eCDFs are not? $\endgroup$
    – Alexis
    Nov 8, 2021 at 6:20
  • 1
    $\begingroup$ Ecdf doesn't require any bandwidth: to plot it you just need to sort your observations, this will give you the x values, and plot as y values regularly spaced points ranging from 0 to 1, that's it. $\endgroup$
    – Pohoua
    Nov 9, 2021 at 1:53
  • $\begingroup$ I think I see... eCDFs lend themselves to an order statistic representation without any need for binning, whereas histograms require bins, or some form of smoother. $\endgroup$
    – Alexis
    Nov 9, 2021 at 2:10
  • 1
    $\begingroup$ Yes. And as the pdf is the derivative of the cdf, you can interpret the problem of chosing a bin size for histogram to the problem of computing the derivative a function while only having access to some points of it. $\endgroup$
    – Pohoua
    Nov 9, 2021 at 13:14
  • 1
    $\begingroup$ Comparing the PDF or quantiles might require bins (or a kernel smoothener), but does it give worse results? $\endgroup$ Nov 9, 2021 at 15:11
1
$\begingroup$

The kernel density of probabilistic function would be hard to interpret, the width of each individual Dirac can change, that is why cumulative distribution is chosen which gives a wholistic picture about the distribution at any point in cdf.

$\endgroup$
0
$\begingroup$

The Kolmogorov Smirnov test uses the cumulative distribution function, because that's what the Kolmogorov Smirnov test is.

There are other tests that use a comparison with the density function rather than the cumulative distribution function, and they have different names.

Well known tests are Pearson's chi-squared test and the G-test.

Those tests work best for distributions describing a categorical or discrete variable, but they can be applied to continuous distributions as well. With continuous distributions you first transform the data to discrete data by binning (this post provides a lot of information about this binning when it is done based on the data).

In a certain sense this binning (based on the data) is almost the same as the Kolmogorov Smirnov test where the binning is done in a cumulative way.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.