{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Definition\n\nLet $n \\ge 2$ and $k \\ge 1$, and let $X_1, \\dots, X_n$ be random vectors in $\\R^k$, written as columns.\nThe *sample mean* is the [[statistic|036756NFD6]]\n$$\\bar{X} = \\frac{1}{n} \\sum_{i=1}^{n} X_i \\in \\R^k.$$\nThe *sample covariance matrix* is the $k \\times k$ matrix\n$$Q = \\frac{1}{n - 1} \\sum_{i=1}^{n} \\left(X_i - \\bar{X}\\right)\\left(X_i - \\bar{X}\\right)^T.$$\nIts entry $Q_{jl}$ is the sample covariance of the $j$-th and the $l$-th coordinates.\n\n## Remarks\n\nExample: for the observations $(0, 0)^T$ and $(2, 2)^T$, the mean is $(1, 1)^T$ and the deviations are $(-1, -1)^T$ and $(1, 1)^T$.\nEach deviation gives the matrix with all entries $1$, so $Q$ has all four entries equal to $2$.\nFor $k = 1$, $\\bar{X}$ is the [[sample mean|0QNRBHWV35]] and $Q$ is the [[sample variance|0JN9P4A944]].\nIf the $X_i$ are i.i.d. with mean vector $\\mu$ and finite [[covariance matrix|02CBHV4ZZQ]] $\\Sigma$, then $E[\\bar{X}] = \\mu$ and $E[Q] = \\Sigma$.\nNon-example: the matrix with divisor $n$ in place of $n - 1$ is also used, but it is not unbiased; its expectation is $\\frac{n-1}{n}\\Sigma$.\nThe matrix $Q$ is symmetric and positive semidefinite, and it is singular when $n \\le k$.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "defines": "ZP455BADJ3",
    "kind": "definition",
    "msc": [
      "62H12",
      "62F10"
    ],
    "name": "Sample mean and sample covariance",
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Sample_mean_and_covariance"
      }
    ],
    "tag": "9JP83HPAEX",
    "uses": [
      "0QNRBHWV35",
      "0JN9P4A944",
      "02CBHV4ZZQ",
      "036756NFD6"
    ]
  },
  "kind": "definition",
  "link": "https://tamnd.github.io/math2/node/9JP83HPAEX/",
  "links": [
    {
      "field": "defines",
      "target": "ZP455BADJ3"
    },
    {
      "field": "uses",
      "target": "0QNRBHWV35"
    },
    {
      "field": "uses",
      "target": "0JN9P4A944"
    },
    {
      "field": "uses",
      "target": "02CBHV4ZZQ"
    },
    {
      "field": "uses",
      "target": "036756NFD6"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/9JP83HPAEX.md",
  "msc": [
    "62H12",
    "62F10"
  ],
  "name": "Sample mean and sample covariance",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/9JP/9JP83HPAEX.md",
  "status": null,
  "tag": "9JP83HPAEX",
  "uri": "m2://9JP83HPAEX",
  "url": "https://tamnd.github.io/math2/wiki/sample-mean-and-sample-covariance-definition/",
  "writing": {
    "tag": "9JP83HPAEX",
    "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
      }
    ]
  }
}
