\problemdata       % Takes 5 *mandatory* arguments
  {binomial-variance}      % latex-friendly label for the prob.
  {variance}  % The topic(s) of the problem content.
  {}                       % Source (if known)
  {S02 cp12W-1}            % Usage (list ones you are aware of).
  {Nick Matsakis, S02}     % Last revision info (author, date).
\begin{problem}
Let $R$ be the number of heads that come up when we toss $n$
independent coins, where each coin comes up heads with probability
$p$. The random variable $R$ has a binomial distribution. Using the
formula for variance of sums, show that $\variance{R} = np(1-p)$.

\solution{

\textit{From the course notes:} Recall that if a random variable,
$R$, has a binomial distribution, then
\[
\pr{R = k} = \binom{n}{k} p^k (1-p)^{n-k}
\]
where $n$ and $p$ are parameters such that $n \geq 1$ and $0 < p < 1$.

We can think of $R$ as the sum of $n$ independent Bernoulli variables.
Formally, we can write $R = R_1 + R_2 + \cdots + R_n$ where
\begin{displaymath}
  R_i = \begin{cases}
    1 & \text{with probability $p$,} \\
    0 & \text{with probability $1-p$.}
  \end{cases}
\end{displaymath}
Now we can compute the variance of the binomially distributed
variable~$R$.
\begin{align*}
\variance{R}
   & =  \variance{R_1} + \variance{R_2} + \ldots + \variance{R_n}
              & \text{(Theorem~\ref{th:varsum})}\\
   & =  n \variance{R_1} & (\variance{R_i} = \variance{R_j})\\
   & =  n (\expect{R_1^2} - \expectsq{R_1}) 
             & \text{(Def. of variance)}\\
   & =  n (\expect{R_1} - \expectsq{R_1}) & (R_1^2 = R_1)\\
   & =  n (p - p^2). & (\expect{R_1} = \pr{R_1 = 1} = p)
\end{align*}

The binomial distribution has an $\expect{np}$. This shows that
the binomial distribution has variance $p (1 - p) n$ and standard
deviation $\sqrt{p (1- p) n}$.  In the special case of an unbiased
binomial distribution ($p = 1/2$), the variance is $n/4$ and the
standard deviation is $\sqrt{n}/2$.
}
\end{problem}
