# Proving $\operatorname{Var}(X) = E[X^2] - (E[X])^2$

I want to understand something about the derivation of $\text{Var}(X) = E[X^2] - (E[X])^2$

Variance is defined as the expected squared difference between a random variable and the mean (expected value): $\text{Var}(X) = E[(X - \mu)^2]$

Then:

$\operatorname{Var}(X) = E[(X - \mu)^2]$

$\operatorname{Var}(X) = E[(X - E[X])^2]$

$\operatorname{Var}(X) = E[(X - E[X])(X - E[X])]$

$\operatorname{Var}(X) = E[X^2 - 2XE[X] + (E[X])^2]$

$\operatorname{Var}(X) = E[X^2] - 2E[XE[X]] + E[(E[X])^2]$

$\operatorname{Var}(X) = E[X^2] - 2E[E[X]E[X]] + E[(E[X])^2]$

$\operatorname{Var}(X) = E[X^2] - 2(E[X])^2 + (E[X])^2$

$\operatorname{Var}(X) = E[X^2] - (E[X])^2$

What I don't quite understand is the steps that get us from $E[XE[X]]$ to $E[E[X]E[X]]$ to $(E[X])^2$, also $E[(E[X])^2]$ to $(E[X])^2$.

While I'm sure these jumps are intuitive and obvious I would still like to understand how we can (more formally) make these jumps / consider them mathematically equivalent.

• E[c] = c when c is a constant. E[X] is a constant itself, so E[E[X]] = E[X]. – o0BlueBeast0o Jul 18 '16 at 20:37
• I prefer to think of it as $E[X~E[X]] = E[X]\cdot E[X]$. The expectation operator $E[~]$ is linear, so $E[X+Y] = E[X]+E[Y]$. Also, $E[\alpha X] = \alpha E[X]$ for constant $\alpha$. As $E[X]$ is a constant, the constant can be pulled out of $E[X~E[X]]$ – JMoravitz Jul 18 '16 at 20:39
• Isn't anything a constant assuming we know the answer on the righthand side of an equation? – user6596353 Jul 18 '16 at 20:42
• And how can we prove that $E[c] = c$ for constant $c$? – user6596353 Jul 18 '16 at 20:43
• If the random variable $W$ is the amount you get from one play of a gambling game, then $E(W)$ is the average amount you get. If $W$ is constant, say $c$, then every time you get $c$, so on average you get $c$. – André Nicolas Jul 18 '16 at 20:55

## 1 Answer

$\newcommand{\E}{\operatorname{E}}$It should not have been written as $$\E[X\E[X]] = \E[\E[X]\E[X]].$$ Instead, it should have said $$\E[X\E[X]] = \E[X] \E[X].$$ The justification is this: $$\E[X\cdot5] = 5\E[X],$$ and similarly for any other constant besides $5$. And in this context, "constant" means "not random". So just treat $\E[X]$ the same way you treat $5$, because it's a constant.