# Expected number of coin tosses

A fair coin is tossed until either 4 heads or 9 tails obtained ( total). What is the expected number of tosses?

Edit: I calculated the probability. It is 10% for 4 heads and 12% for 9 tails. But how to get expectation from this?

Edit:

• You can grind it out. The number of tosses is anything from $4$ to $12$. Find the probability it is $k$ for these various $k$, and calculate the expectation as usual. – André Nicolas Apr 26 '16 at 23:15
• @André: Oh foo, I misunderstood the problem. Dupe vote retracted. – Henning Makholm Apr 26 '16 at 23:20
• @André Nicolas: I calculated the probabilities, but how to get expectations from there? – ReeSSult Apr 26 '16 at 23:37
• Perhaps you could show how your reached your solution, @ReeSSult. That might help others to guide you in the right direction. – buruzaemon Apr 26 '16 at 23:41
• Calculate $p_4$ (the probability the game ends in $4$), $p_5$, and so on up to $p_{12}$. Then the expectation is $4p_4+5p_5+\cdots$. – André Nicolas Apr 27 '16 at 0:15

Let $N_{H=4}$ be the number of trials until we count four heads and $N_{T=9}$ that until we count nine tails.

We want to find: $E~=~\mathsf E(\min \{N_{H=4}, N_{T=9}\})$

Now, this is just the sum of Heads and Tails under condition that we have either four heads and less than nine tails, or nine tails and at most four heads.   (Thus including the case where we have both four heads and nine tails).

Letting $H$ count heads and $T$ count tails then:....

$$E ~=~ \mathsf E(H{+}T\mid (H{=}4\cap T{<}9)\cup (T{=}9\cap H{\leq}4))$$

Now, since for disjoint events† $A,B$, and random variable $X$, we can show (can you?): $$\mathsf E(X\mid {A\cup B}) ~=~ \dfrac{\mathsf E(X\mid A)~\mathsf P(A)+\mathsf E(X\mid B)~\mathsf P(B)}{\mathsf P(A\cup B)}$$

(† that is, disjoint, non-zero probability-measure events, to be proper.)

Then...

$$E ~=~ \dfrac{\mathsf E(H{+}T\mid H{=}4,T{<}9)~\mathsf P(H{=}4, T{<}9)+\mathsf E(H{+}T\mid H{\leq}4, T{=}9)~\mathsf P(H{\leq}4, T{=}9)}{\mathsf P(H{=}4, T{<}9)+\mathsf P(T{=}9, H{\leq 4})}$$

Okay, so because we know that $\mathsf P(H{=}h \cap T{=}t) ~=~ \dbinom{h+t}{h}~2^{-(h+t)}$ , then: ...

$$E ~=~ \dfrac{\sum\limits_{t=0}^8\dfrac{4+t}{2^{4+t}}\dbinom{4+t}{4}+\sum\limits_{h=0}^4\dfrac{9+h}{2^{9+h}}\dbinom{9+h}{9}}{\sum\limits_{t=0}^8\dfrac{1}{2^{4+t}}\dbinom{4+t}{4}+\sum\limits_{h=0}^4\dfrac{1}{2^{9+h}}\dbinom{9+h}{9}}$$

Simplify and evaluate.

PS Hint: A short cut to evaluating those series may be obtained by observing that we are dealing with two negative binomials cases: the count of trials until 4 heads before 9 tails, and the count of trials until 9 tails before 4 heads.

The game may last for $4$ rounds, $5$ rounds, and so on up to $12$ rounds. For note that at the end of the $12$-th round, we must have at least $4$ heads or at least $9$ tails, but not both.

For $k=4$ to $12$, let $p_k$ be the probability that the game ends in the $k$-th round. If $X$ is the number of trials, then $$E(X)=4p_4+5p_5+\cdots +12p_{12}.$$ It remains to compute the $p_k$.

If $4\le k\le 8$, the game ends in round $k$ if we have $3$ heads in the first $k-1$ trials, and then a head. So $$p_k=\binom{k-1}{3}(1/2)^k$$ for $k=4$ to $8$.

For $k=9$ to $12$, the game ends in the $k$-th round if on the $k$-th trial we get the $4$-th head or the $9$-th tail. These events are disjoint. Thus for $9\le k\le 12$, $$p_k=\binom{k-1}{3}(1/2)^k+\binom{k-1}{8}(1/2)^k.$$