\[X\]
follows a binomial distribution \[X \im B(n,p)\]
. The variance of \[X\]
is the variance of the binomial distribution \[B(n,p)\]
is\[V(X)=E(X^2)-(E(X))^2\]
\[\begin{equation} \begin{aligned} E(X) &= \sum_{r=0}^n r P(X=r) \\ &= \sum_{r=0}^n r{}^nC_r p^r (1-p)^{n-r} \\ & = \sum_{r=0}^n r \frac{n!}{r!(n-r)!} p^r (1-p)^{n-r} \\ &= np \sum_{r=0}^n r \frac{(n-1)!}{r!(n-r)!} p^{r-1}r (1-p)^{n-r} \end{aligned} \end{equation}\]
The
\[r=0\]
term makes no contribution to the summation, so we can start the summation from \[r=1\]
.\[\begin{equation} \begin{aligned} \mu &= np \sum_{r=1}^n r \frac{(n-1)!}{r!(n-r)!} p^{r-1}r (1-p)^{n-r} \\ &= np \sum_{r=1}^n \frac{(n-1)!}{(r-1)!((n-1)-(r-1))!} p^{r-1}(1-p)^{(n-1)-(r-1)} \\ &= np \sum_{r=0}^{n-1} \frac{(n-1)!}{r!((n-1)-r)!} p^{r}r (1-p)^{(n-1)-r} \\ &= np \times 1 =np \end{aligned} \end{equation}\]
\[\begin{equation} \begin{aligned} E(X^2) &= \sum_{r=0}^n r^2 P(X=r) \\ &= \sum_{r=0}^n r^2 \frac{n!}{r!(n-r)!} p^r (1-p)^{n-r} \\ & = \sum_{r=0}^n (r^2-r+r) \frac{n!}{r!(n-r)!} p^r (1-p)^{n-r} \\ & = \sum_{r=0}^n (r(r-1)+r) \frac{n!}{r!(n-r)!} p^r (1-p)^{n-r} \\ & = \sum_{r=0}^n r(r-1) \frac{n!}{r!(n-r)!} p^r (1-p)^{n-r} + \sum_{r=0}^n r \frac{n!}{r!(n-r)!} p^r (1-p)^{n-r} \end{aligned} \end{equation}\]
The first two terms contribute nothing to the first expression so
\[\begin{equation} \begin{aligned} E(X^2) &= \sum_{r=2}^n r(r-1) \frac{n!}{r!(n-r)!} p^r (1-p)^{n-r} + \sum_{r=0}^n r \frac{n!}{r!(n-r)!} p^r (1-p)^{n-r} \\ &= p^2 n(n-1) \sum_{r=2}^{n} r(r-1) \frac{(n-2)!}{r!(n-r)!} p^{r-2} (1-p)^{n-r} + \sum_{r=0}^n r \frac{n!}{r!(n-r)!} p^r (1-p)^{n-r} \\ &= p^2 n(n-1) \sum_{r=2}^{n} \frac{(n-2)!}{(r-2)!((n-2)-(r-2))!} p^{r-2} (1-p)^{(n-2)-(r-2)} + \sum_{r=0}^n r \frac{n!}{r!(n-r)!} p^r (1-p)^{n-r} \\ &= = p^2 n(n-1) \sum_{r=0}^{(n-2)} \frac{(n-2)!}{(r)!((n2)!-r!} p^{r} (1-p)^{(n-2)-r} + \sum_{r=0}^n r \frac{n!}{r!(n-r)!} p^r (1-p)^{n-r} \\ &=p^2n(n-1)+ np \end{aligned} \end{equation}\]
Thre variance is then
\[V(X)=E(X^2)-(E(X))^2=p^2n(n-1)+ np -(np)^2=np(1-p)\]