Confusion about linearity of expectation in Binomial Distribution

66 Views Asked by At

I was working through a basic example and realized that I'm might not be understanding the linearity of expectation properly. We have a coin that has probability $p$ of coming up heads and we flip this coin $N$ times. Let $r$ be the number of heads we get. It's a pretty standard result for binomial distributions that $$<r>= {\rm Exp}(r)=Np\quad {\rm Var}(r) = Np(1-p)$$ And I understand how to get the expectation value of $r$ from linearity of expectation as well as the variance above from the linearity of variance for independent coin tosses. However I was also trying to get the variance in another way. We have $${\rm Var}(r) = <r^2> - <r>^2$$ For a single coin toss we have $<r^2> = p(1^2) + (1-p)(0^2)$ and so by linearity of expectation we have for $N$ tosses $<r^2> = N p$ which gives us the variance $${\rm Var}(r)= Np - N^2 p^2 = Np(1- Np)$$ Obviously something has gone wrong(I think in computing $<r^2>$) but I can't figure out what. Could someone nudge me towards whats' wrong?