{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Summary\n\nLet $A$ be a real $m \\times n$ matrix and let $b \\in \\R^m$.\nA *least squares solution* of $Ax = b$ is a vector $\\hat x \\in \\R^n$ that minimises $\\norm{Ax - b}$, for the Euclidean norm.\nThe vectors $\\hat x$ that do this are exactly the solutions of the *normal equations*\n$$A^T A \\hat x = A^T b.$$\nIf the columns of $A$ are linearly independent, then $A^T A$ is invertible, and $\\hat x = (A^T A)^{-1} A^T b$ is unique.\n\n## Remarks\n\nThe vector $A \\hat x$ is the [[orthogonal projection|0B8KZRT28M]] of $b$ onto the column space of $A$, see [[the closest point property|0MCDDSCB9Z]].\nThe normal equations say that the residual $b - A\\hat x$ is orthogonal to each column of $A$.\nFitting a line $y = c_0 + c_1 t$ to data points $(t_i, y_i)$ is a least squares problem.\nIn practice, the [[QR decomposition|0ERWG4NXQ9]] gives a more stable method than the normal equations.\n\n## Explanations\n\n### L1 human\n\nA system $Ax = b$ with more equations than unknowns usually has no solution.\nThe least squares method finds the $x$ that makes $Ax$ as close as possible to $b$.\nIt is the standard way to fit a model to noisy data.\n",
  "commit": "f591989ed15704e9d8755a7a5a6426d73de7a3ae",
  "front": {
    "kind": "concept",
    "msc": [
      "65F20",
      "15A06"
    ],
    "name": "Least squares",
    "same_as": {
      "wikidata": "Q6553462",
      "wikipedia": "Linear least squares"
    },
    "sources": [
      {
        "locator": "Basic formulation",
        "url": "https://en.wikipedia.org/wiki/Linear_least_squares"
      }
    ],
    "tag": "0BYTQ4X1HC",
    "uses": [
      "0MCDDSCB9Z",
      "0Q8HZTJC7G",
      "0W809K6AW0"
    ]
  },
  "kind": "concept",
  "link": "https://math2.tamnd.com/node/0BYTQ4X1HC/",
  "links": [
    {
      "field": "uses",
      "target": "0MCDDSCB9Z"
    },
    {
      "field": "uses",
      "target": "0Q8HZTJC7G"
    },
    {
      "field": "uses",
      "target": "0W809K6AW0"
    }
  ],
  "markdown": "https://math2.tamnd.com/node/0BYTQ4X1HC.md",
  "msc": [
    "65F20",
    "15A06"
  ],
  "name": "Least squares",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/0BY/0BYTQ4X1HC.md",
  "status": null,
  "tag": "0BYTQ4X1HC",
  "uri": "m2://0BYTQ4X1HC",
  "url": "https://math2.tamnd.com/wiki/least-squares/",
  "writing": {
    "tag": "0BYTQ4X1HC",
    "kind": "concept",
    "level": "W0",
    "next": [
      {
        "what": "an inventory row",
        "note": "the row of the inventory that the node accounts for",
        "have": 0,
        "want": 1
      }
    ]
  }
}
