{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Definition\n\nLet $(X_t)_{t \\in \\Z}$ be a real weakly [[stationary process|DT0QXJE705]]: $E[X_t^2] \u003c \\infty$, the mean $E[X_t] = \\mu$ does not depend on $t$, and the [[covariance|0KBFAWYRTE]] $\\operatorname{Cov}(X_{t+h}, X_t)$ depends only on $h$.\nThe *autocovariance function* is $\\gamma(h) = \\operatorname{Cov}(X_{t+h}, X_t)$ for $h \\in \\Z$.\nIf $\\gamma(0) \u003e 0$, the *autocorrelation function* is\n$$\\rho(h) = \\frac{\\gamma(h)}{\\gamma(0)}, \\qquad h \\in \\Z.$$\nIt is the [[correlation coefficient|0DNN9B6Q2F]] of $X_{t+h}$ and $X_t$.\nFor observations $x_1, \\dots, x_n$ of a [[time series|EA3MF4VTEH]] with mean $\\bar x$, the *sample autocovariance* and *sample autocorrelation* at lag $\\abs{h} \u003c n$ are\n$$\\hat\\gamma(h) = \\frac1n \\sum_{t=1}^{n - \\abs{h}} (x_{t + \\abs{h}} - \\bar x)(x_t - \\bar x), \\qquad \\hat\\rho(h) = \\frac{\\hat\\gamma(h)}{\\hat\\gamma(0)}.$$\n\n## Remarks\n\nEvery autocorrelation function satisfies $\\rho(0) = 1$, $\\rho(-h) = \\rho(h)$ and $\\abs{\\rho(h)} \\le 1$.\nIt is nonnegative definite: $\\sum_{i,j} a_i a_j \\rho(t_i - t_j) \\ge 0$ for all real $a_i$ and integers $t_i$, since this sum is $\\operatorname{Var}(\\sum_i a_i X_{t_i}) / \\gamma(0)$.\n\nExample: let $(\\varepsilon_t)$ be uncorrelated with mean $0$ and variance $\\sigma^2 \u003e 0$, and let $X_t = \\varepsilon_t + \\varepsilon_{t-1}$.\nThen $\\gamma(0) = 2\\sigma^2$, $\\gamma(\\pm 1) = \\sigma^2$ and $\\gamma(h) = 0$ for $\\abs{h} \\ge 2$, so $\\rho(\\pm 1) = 1/2$ and $\\rho(h) = 0$ for $\\abs{h} \\ge 2$.\n\nNon-example: for a random walk $S_t = \\varepsilon_1 + \\cdots + \\varepsilon_t$, the variance $t \\sigma^2$ depends on $t$, so the process is not weakly stationary and $\\rho$ is not defined.\n\nThe divisor $n$ in $\\hat\\gamma$, rather than $n - \\abs{h}$, makes the sample autocovariance nonnegative definite.\nIn signal processing, autocorrelation often means the unnormalized $E[X_{t+h} X_t]$.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "defines": "YCZHYY8VE5",
    "kind": "definition",
    "msc": [
      "62M10",
      "60G10"
    ],
    "name": "Autocorrelation function",
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Autocorrelation"
      }
    ],
    "tag": "K0KF9KMF5W",
    "uses": [
      "EA3MF4VTEH",
      "DT0QXJE705",
      "0KBFAWYRTE",
      "0DNN9B6Q2F"
    ]
  },
  "kind": "definition",
  "link": "https://tamnd.github.io/math2/node/K0KF9KMF5W/",
  "links": [
    {
      "field": "defines",
      "target": "YCZHYY8VE5"
    },
    {
      "field": "uses",
      "target": "EA3MF4VTEH"
    },
    {
      "field": "uses",
      "target": "DT0QXJE705"
    },
    {
      "field": "uses",
      "target": "0KBFAWYRTE"
    },
    {
      "field": "uses",
      "target": "0DNN9B6Q2F"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/K0KF9KMF5W.md",
  "msc": [
    "62M10",
    "60G10"
  ],
  "name": "Autocorrelation function",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/K0K/K0KF9KMF5W.md",
  "status": null,
  "tag": "K0KF9KMF5W",
  "uri": "m2://K0KF9KMF5W",
  "url": "https://tamnd.github.io/math2/wiki/autocorrelation-function-definition/",
  "writing": {
    "tag": "K0KF9KMF5W",
    "kind": "definition",
    "level": "W0",
    "next": [
      {
        "what": "a source with a locator",
        "have": 0,
        "want": 1
      }
    ]
  }
}
