# Calculating Variance of a binomial distribution using the standard formula $E(X^2) - \mu^2$

Binomial problems: Mean and standard deviation

Suppose that the New England Colonials baseball team is equally likely to win any particular game as not to win it. Suppose also that we choose a random sample of Colonials games. Estimate the number of games in the sample that the Colonials win by giving the mean of the relevant distribution (that is, the expectation of the relevant random variable). Do not round your response. Quantify the uncertainty of your estimate by giving the standard deviation of the distribution. Round your response to at least three decimal places.

I've calculated the mean to be $10 (np=20*0.5)$. The short cut for calculating the variance of a binomial distribution is $np(1-p)$, but can you show me how to use the standard discrete distribution formula for variance ($Var(X) = E(X^2) - \mu^2$)to calculate variance in this case?

-
I think you mean $Var(X)=E(X^2)-\mu^2$. – Max Oct 17 '12 at 16:35
@Max you are correct. I made the correction. thank you – user133466 Oct 17 '12 at 16:38

\begin{align} \textrm{Var}\left[X\right] &= \sum_{i=0}^{n}\left(i-np\right)^2\binom{n}{i}p^i(1-p)^{n-i}\\ &= \sum_{i=0}^{n}\left(i^2-2inp+\left(np\right)^2\right)\binom{n}{i}p^i(1-p)^{n-i}\\ &= \sum_{i=0}^{n}i^2\binom{n}{i}p^i(1-p)^{n-i}-2np\sum_{i=0}^{n}i\binom{n}{i}p^i(1-p)^{n-i}+(np)^2\sum_{i=0}^{n}\binom{n}{i}p^i(1-p)^{n-i}\\ &= \sum_{i=0}^{n}i^2\binom{n}{i}p^i(1-p)^{n-i}-2(np)^2+(np)^2\\ &= \sum_{i=0}^{n}i^2\binom{n}{i}p^i(1-p)^{n-i}-(np)^2\\ &= \sum_{i=0}^{n}ni\binom{n-1}{i-1}p^i(1-p)^{n-i}-(np)^2\\ &= np\sum_{i=0}^{n}i\binom{n-1}{i-1}p^{i-1}(1-p)^{n-i}-(np)^2\\ &= np\sum_{i=1}^{n}i\binom{n-1}{i-1}p^{i-1}(1-p)^{n-i}-(np)^2\\ &= np\sum_{j=0}^{n-1}(j+1)\binom{n-1}{j}p^{j}(1-p)^{n-1-j}-(np)^2\\ &= np\left(\sum_{j=0}^{n-1}j\binom{n-1}{j}p^{j}(1-p)^{n-1-j}+\sum_{j=0}^{n-1}\binom{n-1}{j}p^{j}(1-p)^{n-1-j}\right)-(np)^2\\ &= np\left((n-1)p+1\right)-(np)^2\\ &= np\left(np-p+1\right)-(np)^2\\ &= (np)^2-np^2+np-(np)^2\\ &= np-np^2\\\ &= np(1-p)\\ \end{align}

EDIT: I misunderstood the question.

The variance can be calculated as follows:

$\textrm{Var}(X)=\left(0^2\times P(X=0)+1\times P(X=1)+\cdots+20^2\times P(X=20)\right)-10^2$

-
i think you've posted how $np(1-p)$ is derived, but can you show me how you'd substitute the numbers from this particular question (20 games 0.5 chance of winning). you don't have to write all 20, just write the first few then use "dot dot dot" ... – user133466 Oct 17 '12 at 16:52
$P(X=0) = {20 \choose 0}(0.5)^0(0.5)^{20}, P(X=1)={20 \choose 1}(0.5)(0.5)^{19}, P(X=2)={20 \choose 2}(0.5)^2(0.5)^{18}$ etc etc? – user133466 Oct 17 '12 at 16:58
is that correct? – user133466 Oct 17 '12 at 17:09
Yes, that is correct. – Max Oct 17 '12 at 17:15