---
tag: H81VD38Y1B
kind: proof
name: Proof of the formula for the variance as the mean of the square minus the square of the mean
msc: [60A05]
proves: 0NMF95YK8W
uses: [0DCT0QZVQ1, 007QED3E0Y, 0P7PTC8DDE]
sources:
  - url: https://en.wikipedia.org/wiki/Variance
    locator: Definition
---

## Proof

We expand the square and use linearity of expectation.

1. Let $X$ be a real random variable with $E[X^2] < \infty$.
2. For each real $x$, $(\abs{x} - 1)^2 \ge 0$, so $\abs{x} \le (1 + x^2)/2$.
3. Hence $0 \le \abs{X} \le (1 + X^2)/2$. The integral of nonnegative functions is monotone, so the [[expected value|0DCT0QZVQ1]] $E[\abs{X}]$ is at most $(1 + E[X^2])/2 < \infty$.
4. So $X$ is integrable. Let $m = E[X]$, a real number. The [[variance|007QED3E0Y]] of $X$ is $E[(X - m)^2]$.
5. Pointwise, $(X - m)^2 = X^2 - 2mX + m^2$.
6. The variables $X^2$, $X$ and the constant $m^2$ are integrable. By [[linearity of expectation|0P7PTC8DDE]], $E[(X - m)^2] = E[X^2] - 2m E[X] + m^2$.
7. Since $E[X] = m$, the right side is $E[X^2] - 2m^2 + m^2 = E[X^2] - m^2$.
8. So $\operatorname{Var}(X) = E[X^2] - (E[X])^2$.

## Idea

Square out $(X - m)^2$ and take the expectation of each term. The cross term gives $-2m^2$, which cancels the constant $m^2$ down to $-m^2$.
