Expanding the square in the variance

1.3k Views Asked by At

$\newcommand{\var}{\operatorname{var}}$

In the Pattern Recognition book of Bishop, I'm reading the following statement, that I don't fully understand.

The variance of $f(x)$ is defined by
$$\var[f] = E[(f(x)-E[f(x)])^2]$$
Expanding out the square, we see that the variance can also be written in terms of the expectations of $f(x)$ and $f(x)^2$:
$$\var[f] = E[f(x)^2]-E[f(x)]^2$$

I can derive this the following way, but I'm not sure if this is correct, and if it is, why?

$$ \begin{align} \var[f] & = E[(f(x)-E[f(x)])^2]\\[6pt] & = E[f(x)^2-2f(x)E[f(x)]+E[f(x)]^2]\\[6pt] & = E[f(x)^2]-E[2f(x)E[f(x)]]+E[E[f(x)]^2] \quad\text{since }E[X+Y] = E[X] + E[Y] \\[6pt] & = E[f(x)^2]-2E[f(x)]E[f(x)]+E[E[f(x)]^2]\\[6pt] & {}\qquad\text{since }E[cX] = cE[X], \text{ but is $E[f(x)]$ const. here?} \\[6pt] & = E[f(x)^2]-2E[f(x)]E[f(x)]+E[f(x)]^2 \\[6pt] & {}\quad\quad\text{ I guess $E[E[X]] = E[X]$, or something like that?} \\[6pt] & = E[f(x)^2]-E[f(x)]^2 \end{align} $$

Is this correct? Are my assumptions I marked correct?

1

There are 1 best solutions below

0
On BEST ANSWER

Your argument is correct. $E(f(x))$ is constant since it's not random. And $E(c)=c$ if $c$ is constant, so $E(E(f(x)))=E(f(x))$.