# Expected value and Variance

Although this is not actually homework, it's an exercise from the book;

I want to rewrite the variance,

\begin{equation*} var[f]=E[(f(x)-E[f(x)])^2] \end{equation*}

as

\begin{equation*} E[f(x)^2]-E[f(x)]^2. \end{equation*}

I'm not sure how it reduces, and it has had me stumped for a while. The answer would be nice. Any insight [a brief, yet, interesting explanation] would be great.

• The notation f(x) only adds obscurity. Is that an arbitrary (deterministic) function of the random variable x ? If so, just write replace 'f(x)' by 'y' and start from there. – leonbloy Oct 19 '10 at 14:14

Let $X = f(x)$ denote the random variable in question. Let $\mu = E(f(x))$. Then, you are looking to prove the following

$E((X-\mu)^2) = E(X^2)-\mu^2$

Let me outline the steps needed to prove this and you can try to fill in the gaps.

1. Expand the LHS algebraically and use linearity of expectation to split it into $3$ different terms.
2. Note that $\mu$ is a constant and $E(aX)$ is related in a simple way to $E(X)$ when $a$ is a constant.

These two steps combined should get you to the right hand side.

• Thank you. $E[(X-\mu)^2]=E[X^2]-\muE[X]+\mu^2$ What I hadn't noticed was that $E[X] = \mu$ and the expression reduces quite nicely. – sova Oct 19 '10 at 17:52
• Also, I had trouble noticing that $E[E[f(x)]]=E[f(x)]$, is a good way to think of the expectation operator as turning its argument into a constant? Or lowering the dimensionality, if it were something like $E_x[f(x,y)]$ ? – sova Oct 19 '10 at 18:12