{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Proof\n\nWe expand the square of the centred sum and use linearity of expectation.\n\n1. Let $X_1, \\dots, X_n$ be real random variables on one probability space with $E[X_i^2] \u003c \\infty$ for each $i$. Let $S = X_1 + \\dots + X_n$.\n2. For each real $x$, $\\abs{x} \\le (1 + x^2)/2$, because $(\\abs{x} - 1)^2 \\ge 0$.\n3. The integral of nonnegative functions is monotone. So by step 2, $E[\\abs{X_i}] \\le (1 + E[X_i^2])/2 \u003c \\infty$, and each $X_i$ is integrable, with [[expected value|0DCT0QZVQ1]] $m_i = E[X_i]$.\n4. Let $Y_i = X_i - m_i$. Since $(x - m)^2 \\le 2x^2 + 2m^2$ for real $x$ and $m$, we get $E[Y_i^2] \\le 2E[X_i^2] + 2m_i^2 \u003c \\infty$.\n5. For real $u$ and $v$, $\\abs{uv} \\le (u^2 + v^2)/2$. So $\\abs{Y_i Y_j} \\le (Y_i^2 + Y_j^2)/2$, and each product $Y_i Y_j$ is integrable.\n6. By [[linearity of expectation|0P7PTC8DDE]], $S$ is integrable and $E[S] = m_1 + \\dots + m_n$. So $S - E[S] = Y_1 + \\dots + Y_n$.\n7. Expanding the square of a finite sum gives, pointwise,\n$$(S - E[S])^2 = \\sum_{i=1}^n Y_i^2 + 2 \\sum_{1 \\le i \u003c j \\le n} Y_i Y_j.$$\n8. All terms on the right are integrable by steps 4 and 5. By linearity of expectation,\n$$E[(S - E[S])^2] = \\sum_{i=1}^n E[Y_i^2] + 2 \\sum_{1 \\le i \u003c j \\le n} E[Y_i Y_j].$$\n9. By the definition of the [[variance|007QED3E0Y]], the left side is $\\operatorname{Var}(S)$ and $E[Y_i^2] = \\operatorname{Var}(X_i)$.\n10. By the definition of the [[covariance|0DJ8W3HP2D]], $E[Y_i Y_j] = E[(X_i - m_i)(X_j - m_j)] = \\operatorname{Cov}(X_i, X_j)$.\n11. Steps 8 to 10 give\n$$\\operatorname{Var}\\left(\\sum_{i=1}^n X_i\\right) = \\sum_{i=1}^n \\operatorname{Var}(X_i) + 2 \\sum_{1 \\le i \u003c j \\le n} \\operatorname{Cov}(X_i, X_j).$$\n12. For $n = 2$ with $X_1 = X$ and $X_2 = Y$, the only pair is $(1, 2)$. So $\\operatorname{Var}(X + Y) = \\operatorname{Var}(X) + \\operatorname{Var}(Y) + 2 \\operatorname{Cov}(X, Y)$.\n\n## Idea\n\nThe deviation of the sum from its mean is the sum of the deviations of the terms. Squaring a sum gives the squares plus twice the cross products. Their expectations are the variances and the covariances.\n",
  "commit": "4a3290d299c8b2cd6493fce2296920ba7f82d942",
  "front": {
    "kind": "proof",
    "msc": [
      "60A05"
    ],
    "name": "Proof of the formula for the variance of a sum",
    "proves": "0D86GJEZ39",
    "sources": [
      {
        "locator": "Sum of correlated variables",
        "url": "https://en.wikipedia.org/wiki/Variance"
      }
    ],
    "tag": "1Q8PDAHQVC",
    "uses": [
      "0DCT0QZVQ1",
      "007QED3E0Y",
      "0DJ8W3HP2D",
      "0P7PTC8DDE"
    ]
  },
  "kind": "proof",
  "link": "https://math2.tamnd.com/node/1Q8PDAHQVC/",
  "links": [
    {
      "field": "proves",
      "target": "0D86GJEZ39"
    },
    {
      "field": "uses",
      "target": "0DCT0QZVQ1"
    },
    {
      "field": "uses",
      "target": "007QED3E0Y"
    },
    {
      "field": "uses",
      "target": "0DJ8W3HP2D"
    },
    {
      "field": "uses",
      "target": "0P7PTC8DDE"
    }
  ],
  "markdown": "https://math2.tamnd.com/node/1Q8PDAHQVC.md",
  "msc": [
    "60A05"
  ],
  "name": "Proof of the formula for the variance of a sum",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/1Q8/1Q8PDAHQVC.md",
  "status": null,
  "tag": "1Q8PDAHQVC",
  "uri": "m2://1Q8PDAHQVC",
  "url": "https://math2.tamnd.com/wiki/proof-of-the-formula-for-the-variance-of-a-sum/",
  "writing": {
    "tag": "1Q8PDAHQVC",
    "kind": "proof",
    "level": "W0",
    "next": [
      {
        "what": "an inventory row",
        "note": "the row of the inventory that the node accounts for",
        "have": 0,
        "want": 1
      }
    ]
  }
}
