\problemdata       % Takes 5 *mandatory* arguments
  {equivalent-forms}       % latex-friendly label for the prob.
  {variance}  % The topic(s) of the problem content.
  {}                       % Source (if known)
  {S02 cp12M-4}            % Usage (list ones you are aware of).
  {Nick Matsakis, S02}     % Last revision info (author, date).
\begin{problem}
Prove that the following two formulas for calculating variance are equivalent:
\begin{eqnarray}
\variance{R} \eqdef \expect{(R - \expect{R})^2}.\\
\variance{R} = \expect{R^2} - \expectsq{R},
\end{eqnarray}

\solution{From the Notes:
Remember that $\expect{R^2}$ is generally not equal to $\expectsq{R}$.
The expected value of a product is the product of the expected values only
for independent variables, and $R$ is not independent of itself unless it
is constant.
\begin{proof}
  Write $\mu = \expect{R}$.  Then
  \begin{eqnarray*}
    \variance{R}
        & = &   \expect{(R - \mu)^2} \\
        & = &   \expect{R^2 - 2 R \cdot \mu + \mu^2} \\
        & = &   \expect{R^2} - \expect{2 R \cdot \mu} + \expect{\mu^2} \\
        & = &   \expect{R^2} - 2 \expect{R} \cdot \mu + \mu^2 \\
        & = &   \expect{R^2} - 2 \expectsq{R} + \expectsq{R} \quad
           \text{(definition of $\mu$)}\\
        & = &   \expect{R^2} - \expectsq{R}.
  \end{eqnarray*}
  The first step uses the definition of variance.  In the second step,
  we multiply out the squared term.  The third step uses linearity of
  expectation.  There are two transformations on the fourth line.  In
  the second term, we pull the constant $2 \mu$ out of the
  expectation.  In the third term, we use the fact that the
  expectation of a constant, namely $\mu^2$, is that constant.  The
  final step is simplification.
\end{proof}
}
\end{problem}
