Expected value and variance: $Var[X] = E[(X – E[X])^2] = E[X^2] – (E[X])^2$

probability

My notes claim the following:

The variance of a random variable $X$ is

$$Var[X] = E[(X – E[X])^2]$$

$\dots$

For any random variable $X$,

$Var[X] = E[X^2] – (E[X])^2$

I'm wondering how it is that $Var[X] = E[(X – E[X])^2] = E[X^2] – (E[X])^2$?

We have that

$$Var[X] = E[(X – E[X])^2] = E[X^2] – 2XE[X] + (E[X])^2 \not= E[X^2] – (E[X])^2$$

I would greatly appreciate it if people could please take the time to clarify this.

Best Answer

$$Var[X] = E[(X - E[X])^2] = E[X^2] - 2E[XE[X]] + (E[X])^2 =E[X^2] - 2E[X]E[X] + (E[X])^2 $$ that is $$Var[X] =E[X^2] - 2(E[X])^2 + (E[X])^2 $$