{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Definition\n\nLet $X_1, \\dots, X_n$ be [[i.i.d.|0AJN7WHBJZ]] real random variables with an unknown [[probability density function|04YG690N5V]] $f$.\nLet $K \\colon \\R \\to \\R$ be an integrable function with $\\int_{\\R} K(u) \\, du = 1$, called the kernel, and let $h \u003e 0$, called the bandwidth.\nThe *kernel density estimator* of $f$ is\n$$\\hat f_h(x) = \\frac{1}{n h} \\sum_{i=1}^{n} K\\Big(\\frac{x - X_i}{h}\\Big), \\quad x \\in \\R.$$\n\n## Remarks\n\nThe substitution $u = (x - X_i)/h$ gives $\\int_{\\R} \\hat f_h(x) \\, dx = 1$; if moreover $K \\ge 0$, then $\\hat f_h$ is a probability density.\nCommon kernels are the Gaussian kernel $K(u) = e^{-u^2/2}/\\sqrt{2\\pi}$ and the Epanechnikov kernel $K(u) = \\frac{3}{4}(1 - u^2)$ for $\\abs{u} \\le 1$, $0$ otherwise.\nExample: with $K = \\frac{1}{2} \\mathbf{1}_{[-1, 1]}$, $\\hat f_h(x)$ is the fraction of data in $[x - h, x + h]$ divided by $2h$.\nNon-example: $K = \\mathbf{1}_{[-1, 1]}$ has integral $2$, so the resulting $\\hat f_h$ integrates to $2$ and is not a density estimate.\nIf $f$ is twice continuously differentiable and $K$ is a bounded symmetric density with finite variance, the mean integrated squared error is smallest for $h$ of order $n^{-1/5}$.\nIn $\\R^d$, one uses $\\frac{1}{n h^d} \\sum_i K((x - X_i)/h)$ with a kernel on $\\R^d$.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "defines": "ZV65XMJ9A4",
    "kind": "definition",
    "msc": [
      "62G07"
    ],
    "name": "Kernel density estimation",
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Kernel_density_estimation"
      }
    ],
    "tag": "BEEJJA60BX",
    "uses": [
      "04YG690N5V",
      "0AJN7WHBJZ"
    ]
  },
  "kind": "definition",
  "link": "https://tamnd.github.io/math2/node/BEEJJA60BX/",
  "links": [
    {
      "field": "defines",
      "target": "ZV65XMJ9A4"
    },
    {
      "field": "uses",
      "target": "04YG690N5V"
    },
    {
      "field": "uses",
      "target": "0AJN7WHBJZ"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/BEEJJA60BX.md",
  "msc": [
    "62G07"
  ],
  "name": "Kernel density estimation",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/BEE/BEEJJA60BX.md",
  "status": null,
  "tag": "BEEJJA60BX",
  "uri": "m2://BEEJJA60BX",
  "url": "https://tamnd.github.io/math2/wiki/kernel-density-estimation-definition/",
  "writing": {
    "tag": "BEEJJA60BX",
    "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
      }
    ]
  }
}
