Kolmogorovsmirnov TestEdit

The Kolmogorov-Smirnov test is a nonparametric method used to assess whether a sample comes from a specified continuous distribution or whether two samples come from the same distribution. It operates by comparing the empirical distribution function of the data to a reference cumulative distribution function under the null hypothesis, or by comparing the empirical distributions of two samples directly. The test is valued for its simplicity, its lack of reliance on a particular parametric family beyond continuity, and its ability to detect differences in both location and shape of distributions.

Historically, the method traces back to foundational work by Andrey Kolmogorov and Nikolai Smirnov in the early 20th century. The one-sample version and the two-sample version are often distinguished in practice, with the former testing against a specified F0 and the latter testing whether two samples originate from the same underlying distribution.

Statistical framework

  • One-sample Kolmogorov-Smirnov test

    • Data are modeled as an independent and identically distributed sample X1, X2, ..., Xn drawn from a continuous distribution with cumulative distribution function F. The null hypothesis is that F is equal to a specified F0.
    • The test statistic is Dn = supx |Fn(x) − F0(x)|, where Fn is the empirical distribution function Empirical distribution function based on the sample.
    • Decision rules compare Dn to critical values derived from the limiting distribution of √n Dn under the null, often referred to as the Kolmogorov distribution Kolmogorov distribution.
  • Two-sample Kolmogorov-Smirnov test

    • Data consist of two independent samples, say X1, …, Xn and Y1, …, Ym, drawn from distributions F and G, respectively. The null hypothesis is that F = G.
    • The test statistic is Dn,m = supx |Fn(x) − Gn(x)|, where Fn and Gn are the empirical distribution functions of the two samples.
    • As with the one-sample version, the null distribution of √N Dn,m (with N typically related to n and m) provides the basis for p-values and critical values, though exact finite-sample results are more involved for the two-sample case.
  • Interpreting the statistic

    • Large values of Dn (or Dn,m) indicate a greater maximum difference between the empirical distribution and the reference (or between the two empirical distributions), signaling a potential departure from the null hypothesis.
    • In practice, p-values are obtained from the asymptotic Kolmogorov distribution, with refinements or exact tables available for small samples or particular settings.

Assumptions and interpretation

  • Independence and random sampling: The KS test assumes that observations are independent and drawn from the population of interest. Violations can distort the null distribution and p-values.
  • Continuity: The standard KS test is developed for continuous distributions. Ties or discreteness can affect the distribution of the statistic, and adjustments or alternative tests may be preferred.
  • Specified versus estimated parameters: If the null hypothesis specifies a distribution with known parameters, the asymptotic distribution of Dn applies directly. If parameters are estimated from the data to fit the null distribution, the distribution of Dn changes, and corrections such as the Lilliefors adjustment for normality or other adaptations may be necessary.
  • Sensitivity profile: The KS test is most sensitive to differences near the center of the distribution and less sensitive to tails. Other goodness-of-fit tests (e.g., the Anderson-Darling test) may be more powerful against tail alternatives.

Practical considerations

  • Critical values and p-values: For the one-sample KS test with a fully specified F0, critical values are tabulated and p-values can be computed from the Kolmogorov distribution. For the two-sample KS test, tables and asymptotic approximations exist, with refinements for unequal sample sizes.
  • Parameter estimation: When testing for a normal distribution with unknown mean and variance, the Lilliefors correction or related approaches are commonly used, as the standard KS distribution no longer applies without adjustment.
  • Software: The Kolmogorov-Smirnov test is implemented in many statistical packages, often under functions named in terms of the KS test or as part of broader goodness-of-fit testing suites. Users typically specify the reference distribution or enable the two-sample comparison.

Variants and related tests

  • Lilliefors test: a modification of the KS test for normality when the mean and variance are unknown and estimated from the data.
  • Kuiper test: a variant of the KS test that is equally sensitive around all parts of the distribution and is particularly useful for circular data.
  • Cramér–von Mises criterion and Anderson-Darling test: alternative goodness-of-fit tests with different sensitivity profiles, often more powerful in tails or overall deviations.
  • Other nonparametric two-sample tests: there are several approaches for comparing distributions that do not assume a particular parametric form, each with its own strengths.

Practical examples and applications

  • Model validation: assessing whether a simulated dataset matches a theoretical model for a given continuous distribution.
  • Goodness-of-fit in quality control: checking whether observed measurements conform to a specified process distribution.
  • Comparative studies: evaluating whether two populations exhibit the same distribution for a variable of interest, without assuming normality.

See also