{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Definition\n\nLet $X$ be a random vector in $\\R^p$ with [[mean|0WQNRCNY3M]] $\\mu$ and [[covariance matrix|0V7G6WMFK0]] $\\Sigma$, and assume that $\\Sigma$ is [[positive definite|0KX66CZMBB]].\nThe *Mahalanobis distance* of a point $x \\in \\R^p$ from the distribution of $X$ is\n$$D_M(x) = \\sqrt{(x - \\mu)^T \\Sigma^{-1} (x - \\mu)}.$$\nThe Mahalanobis distance between two points $x, y \\in \\R^p$ with respect to $\\Sigma$ is\n$$d_M(x, y) = \\sqrt{(x - y)^T \\Sigma^{-1} (x - y)}.$$\n\n## Remarks\n\nExample: let $\\mu = 0$ and $\\Sigma = \\operatorname{diag}(4, 1)$.\nThen $\\Sigma^{-1} = \\operatorname{diag}(1/4, 1)$, so $D_M(2, 0) = \\sqrt{4/4} = 1$ and $D_M(0, 1) = 1$, while $D_M(0, 2) = 2$.\nNon-example: if $\\Sigma = \\begin{pmatrix} 1 \u0026 1 \\\\ 1 \u0026 1 \\end{pmatrix}$, then $\\Sigma$ is not invertible, so the formula is not defined.\nIf $\\Sigma = A A^T$ with $A$ invertible, then $d_M(x, y) = \\abs{A^{-1} x - A^{-1} y}$, the Euclidean distance after the change of variables $x \\mapsto A^{-1} x$.\nSo $d_M$ is a metric on $\\R^p$.\nIf $\\Sigma$ is the identity, $d_M$ is the Euclidean distance.\nIf $X$ is multivariate normal, then $D_M(X)^2$ has the chi-squared distribution with $p$ degrees of freedom.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "defines": "P546TSFBK2",
    "kind": "definition",
    "msc": [
      "62H30",
      "62H20"
    ],
    "name": "Mahalanobis distance",
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Mahalanobis_distance"
      }
    ],
    "tag": "HF8AJZP6PG",
    "uses": [
      "0V7G6WMFK0",
      "0KX66CZMBB",
      "0WQNRCNY3M"
    ]
  },
  "kind": "definition",
  "link": "https://tamnd.github.io/math2/node/HF8AJZP6PG/",
  "links": [
    {
      "field": "defines",
      "target": "P546TSFBK2"
    },
    {
      "field": "uses",
      "target": "0V7G6WMFK0"
    },
    {
      "field": "uses",
      "target": "0KX66CZMBB"
    },
    {
      "field": "uses",
      "target": "0WQNRCNY3M"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/HF8AJZP6PG.md",
  "msc": [
    "62H30",
    "62H20"
  ],
  "name": "Mahalanobis distance",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/HF8/HF8AJZP6PG.md",
  "status": null,
  "tag": "HF8AJZP6PG",
  "uri": "m2://HF8AJZP6PG",
  "url": "https://tamnd.github.io/math2/wiki/mahalanobis-distance-definition/",
  "writing": {
    "tag": "HF8AJZP6PG",
    "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
      }
    ]
  }
}
