# Expected number of heads on coin flip?

Suppose you were to toss 2 coins each with different probabilities of landing on heads 2 times each, one at a time. So coin 1 tossed twice. Then coin 2 tossed twice. Let N be the total number of heads. To calculate E[N], would you find E[number of heads on coin 1's tosses] and E[number of heads on coin 2's tosses] and sum them together? And to find the var[N] would it be the same concept?

For expectation - yes due to linearity of expectation. As for variance, you can do the same since the each toss (or each event) are independent. Note that it does not matter whether you toss each coin 'one at a time' or the order you do it in due to independence, of course.

Formally, if you let $X_1$ and $X_2$ be the indicator variables for each toss of the first coin ($1$ for heads, $0$ for tails) and the same with $Y_1$ and $Y_2$ for the tosses of the second coin, we have:

$$N=X_1+X_2+Y_1+Y_2$$

Then

$$E(N)=E(X_1+X_2+Y_1+Y_2)$$

$$=E(X_1)+E(X_2)+E(Y_1)+E(Y_2)$$

due to linearity of expectation.

Also, as $X_1,X_2,Y_1,Y_2$ are independent events, we have

$$Var(N)=Var(X_1+X_2+Y_1+Y_2)$$

$$=Var(X_1)+Var(X_2)+Var(Y_1)+Var(Y_2)$$

The general rules being used here are:

$$E(aX+bY)=aE(X)+bE(Y)\tag{linearity of expectation}$$

and if $X$ and $Y$ are independent,

$$Var(aX+bY)=a^2Var(X)+b^2Var(Y)$$

• I just have a general question. I had a practice problem like this but with given probabilities for each coin. Let's assume N=X+Y. X is number of heads on coin 1, and Y is the number of heads on coin 2. I tried calculating the variance by doing E[(X+Y)^2] - E^2[(X+Y)] but received a negative number. But when I calculated the variances of each coin individually and then summing it, I received a positive number. Why does this happen? Basically I'm asking, why doesn't E[(X+Y)^2] - E^2[(X+Y)] =var(X)+var(Y)? Aug 10, 2017 at 21:18
• Could you give the probabilities in particular or edit your question to include your calculation? Aug 10, 2017 at 21:23
• Never mind, I see what I did wrong. When squaring E[(X+Y)^2], I did not calculate it correctly. Aug 10, 2017 at 21:35
• Letting the probabilities be $p_1$ and $p_2$, we have $E[(X+Y)^2] - (E[X+Y])^2=(0\times(1-p_1)^2(1-p_2)^2+1\times(1-p_1)^2p_2(1-p_2)+4\times(1-p_1)^2p_2^2+1\times p_1(1-p_1)(1-p^2)^2+4\times p_1(1-p_1)p_2(1-p_2)+9\times p_1(1-p_1)p_2^2+4\times p_1^2(1-p_2)^2+9\times p_1^2p_2(1-p_2)+16\times p_1^2p_2^2)-4(p_1+p_2)^2$ Aug 10, 2017 at 21:35

Long answer: It sounds like the two coins in your example do not affect each other in any way. In other words, it sounds like the number of heads on one is independent of how many heads happen for the other. For any two random variables, whether independent or not, we do indeed have that $E[X+Y]=E[X]+E[Y]$. Furthermore, when the variables are independent, we also have that $E[XY]=E[X]E[Y]$. This allows us to reason as follows. \begin{align} Var[X+Y] &= E[((X+Y)-E(X+Y))^2]\\ &=E[(X-E[X]+Y-E[Y])^2]\\ &=E[(X-E[X])^2] +2E[(X-E[X])(Y-E[Y])] + E[(Y-E[Y])^2]\\ &=Var[X] + Var[Y] + 2 E[XY -XE[Y] -YE[X] + E[X]E[Y]]\\ &= Var[X] + Var[Y] + 2(E[XY] -E[X]E[Y] - E[X]E[Y] + E[X]E[Y])\\ &= Var[X] + Var[Y] + 2(E[X]E[Y] -E[X]E[Y] - E[X]E[Y] + E[X]E[Y])\\ &= Var[X] + Var[Y] +2 \cdot 0\\ &= Var[X] + Var[Y] \end{align} So the variance of the sum of independent random variables is the sum of their variance.