{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Definition\n\nLet $X_1, \\dots, X_n$ be [[i.i.d.|0AJN7WHBJZ]] real random variables with [[cumulative distribution function|0MXMS3AE13]] $F$, and let $F_n$ be their [[empirical distribution function|A05WR6TEK5]].\nLet $F_0$ be a fixed continuous cumulative distribution function.\nThe *one-sample Kolmogorov–Smirnov statistic* is\n$$D_n = \\sup_{x \\in \\R} \\abs{F_n(x) - F_0(x)}.$$\nThe *Kolmogorov–Smirnov test* of the null hypothesis $H_0 \\colon F = F_0$ at level $\\alpha$ rejects $H_0$ when $D_n \u003e c_{n, \\alpha}$, where $c_{n, \\alpha}$ is chosen so that $P(D_n \u003e c_{n, \\alpha}) \\le \\alpha$ under $H_0$.\n\nLet two independent i.i.d. samples of sizes $n$ and $m$ have empirical distribution functions $F_n$ and $G_m$.\nThe *two-sample statistic* is $D_{n,m} = \\sup_{x} \\abs{F_n(x) - G_m(x)}$.\nIt tests whether the two samples have the same continuous distribution.\n\n## Remarks\n\nUnder $H_0$ the law of $D_n$ is the same for every continuous $F_0$, because $F_0(X_i)$ is uniform on $[0, 1]$.\nAs $n \\to \\infty$, $\\sqrt{n} D_n$ converges in distribution to the Kolmogorov distribution, the law of $\\sup_{0 \\le t \\le 1} \\abs{B(t)}$ for a [[Brownian bridge|3MCVMBAGD1]] $B$:\n$$\\lim_{n \\to \\infty} P(\\sqrt{n} D_n \\le t) = 1 - 2 \\sum_{k=1}^{\\infty} (-1)^{k-1} e^{-2k^2 t^2}, \\qquad t \u003e 0.$$\nFor ordered data $x_{(1)} \\le \\dots \\le x_{(n)}$ the supremum is a finite maximum: $D_n = \\max_{i} \\max\\big(i/n - F_0(x_{(i)}), \\, F_0(x_{(i)}) - (i - 1)/n\\big)$.\n\nExample: $n = 1$, $X_1 = 0.3$ and $F_0(x) = x$ on $[0, 1]$.\nThen $F_1$ jumps from $0$ to $1$ at $0.3$, and $D_1 = \\max(0.3, 1 - 0.3) = 0.7$.\n\nNon-example: testing normality with the mean and variance estimated from the same data is not this test.\nThen $F_0$ is not fixed in advance, and the null law of $D_n$ changes; the corrected procedure is the Lilliefors test.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "defines": "YZYHWC6C5F",
    "kind": "definition",
    "msc": [
      "62G10",
      "62G30"
    ],
    "name": "Kolmogorov–Smirnov test",
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Kolmogorov%E2%80%93Smirnov_test"
      }
    ],
    "tag": "SARNZPAKE5",
    "uses": [
      "A05WR6TEK5",
      "087P03NEND",
      "0MXMS3AE13",
      "0AJN7WHBJZ"
    ]
  },
  "kind": "definition",
  "link": "https://tamnd.github.io/math2/node/SARNZPAKE5/",
  "links": [
    {
      "field": "defines",
      "target": "YZYHWC6C5F"
    },
    {
      "field": "uses",
      "target": "A05WR6TEK5"
    },
    {
      "field": "uses",
      "target": "087P03NEND"
    },
    {
      "field": "uses",
      "target": "0MXMS3AE13"
    },
    {
      "field": "uses",
      "target": "0AJN7WHBJZ"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/SARNZPAKE5.md",
  "msc": [
    "62G10",
    "62G30"
  ],
  "name": "Kolmogorov–Smirnov test",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/SAR/SARNZPAKE5.md",
  "status": null,
  "tag": "SARNZPAKE5",
  "uri": "m2://SARNZPAKE5",
  "url": "https://tamnd.github.io/math2/wiki/kolmogorov-smirnov-test-definition/",
  "writing": {
    "tag": "SARNZPAKE5",
    "kind": "definition",
    "level": "W0",
    "next": [
      {
        "what": "an inventory row",
        "note": "the row of the inventory that the node accounts for",
        "have": 0,
        "want": 1
      },
      {
        "what": "a source with a locator",
        "have": 0,
        "want": 1
      }
    ]
  }
}
