If a fair coin is tossed repeatedly, what is the probability that there are 3 (not necessarily consecutive) heads before there are 4 (not necessarily consecutive) tails?


closed as off-topic by heropup, Leucippus, Namaste, Shailesh, levap Dec 10 '16 at 2:53

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question is missing context or other details: Please improve the question by providing additional context, which ideally includes your thoughts on the problem and any attempts you have made to solve it. This information helps others identify where you have difficulties and helps them write answers appropriate to your experience level." – heropup, Leucippus, Namaste, Shailesh, levap
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ At least three? Or three? $\endgroup$ – David Peterson Dec 9 '16 at 1:47
  • $\begingroup$ @DavidP: I have taken it to be exactly 3 which turns out (in my formulation) to be at least 3 "wins" in a series of 6 matches. $\endgroup$ – true blue anil Dec 9 '16 at 10:58
  • $\begingroup$ @DavidP The wording of the question is strictly (in form and narrative) a classical negative binomial problem, and if we are to get a mathematical answer, we probably should take it at face value: "probability that there are 3 H... before 4 tails" (i.e. $\Pr(H=3\,|\,\text{ before }4T$). $\endgroup$ – Antoni Parellada Dec 9 '16 at 16:49
  • $\begingroup$ @AntoniParellada: It is true that it is a classical negative binomial distribution, and your formulation of the problem above is correct, but I believe you have misapplied it. I have used a creative twist to easily arrive at the answer , but am shortly adding a brute force explanation [ Btw, my answer and Lulu's answer match.] $\endgroup$ – true blue anil Dec 10 '16 at 3:53
  • $\begingroup$ @trueblueanil I am not sure why you repeat my "brute force" expression, but I hope you didn't miss out on its self-deprecating intention. $\endgroup$ – Antoni Parellada Dec 10 '16 at 3:57

We denote the states of the game as $S(a,b)$, to indicate that we have seen $a$ Heads and $b$ tails. And we let $p(a,b)$ denote the probability that we'll see $3$ Heads before we see $4$ Tails. The answer we seek is, of course, $p(0,0)$.

We have the (backwards) relation $$p(a,b)=\frac 12 \times \left(p(a+1,b)+p(a,b+1)\right)$$ And, of course, $b<4\implies p(3,b)=1$ and $a<3\implies p(a,4)=0$.

We remark that, in situations where we require the same number of Heads and Tails the answer must be $\frac 12$ by symmetry. Thus $$p(2,3)=p(1,2)=p(0,1)=\frac 12$$

It follows that:

$$p(2,3)=\frac 12\times \left(1+0\right)=\frac 12$$ $$p(2,2)=\frac 12\times \left(1+\frac 12\right)=\frac 34$$ $$p(2,1)=\frac 12 \times \left(1+\frac 34\right)=\frac 78$$ $$p(2,0)=\frac 12 \times \left(1+\frac 78\right)=\frac {15}{16}$$ $$p(1,3)=\frac 12\times \left(\frac 12+0\right)=\frac 14$$ $$p(1,2)=\frac 12 \times \left(\frac 34+\frac 14\right)=\frac 12$$ $$p(1,1)=\frac 12 \times \left(\frac 78 + \frac 12\right)=\frac {11}{16}$$ $$p(1,0)=\frac 12 \times \left(\frac {15}{16}+\frac {11}{16}\right)=\frac {26}{32}$$

Finally we get $$p(0,0)=\frac 12 \times \left( \frac {26}{32}+\frac 12\right)=\boxed {\frac {42}{64}}$$

Note: the above is straight forward but somewhat error prone. I advise checking.

  • $\begingroup$ I had a feeling we had crossed paths before... It's the rectangle around the answer... What do you see as a discrepancy with my answer here? $\endgroup$ – Antoni Parellada Dec 13 '16 at 1:12
  • $\begingroup$ @AntoniParellada this problem is nearly identical to the baseball problem, though I did not approach it that way. As trueblueanil points out, you can do it simply by asking whether Heads comes up at least three times in the first six tosses. After all, if we see at least three $H's$ then Heads wins, if we don't then we must have had at least four $T's$ so Tails wins. Much better approach than mine. My method works best for problems in which we might return to these states infinitely often, but that isn't the case here. Of course, the answer comes out the same. $\endgroup$ – lulu Dec 13 '16 at 14:49
  • $\begingroup$ Thank you (+1) for looking into it. Can I conclude that my answer is not incorrect, but rather it depends on whether you consider just $3$ or $3$ or more as part of the original question? $\endgroup$ – Antoni Parellada Dec 13 '16 at 16:40
  • $\begingroup$ @AntoniParellada The logic certainly looks right. $\endgroup$ – lulu Dec 13 '16 at 16:44
  • $\begingroup$ @AntoniParellada No problem. Good luck! $\endgroup$ – lulu Dec 13 '16 at 16:50

This follows a negative binomial distribution:

Number of successes in a sequence of independent and identically distributed Bernoulli trials before a specified (non-random) number of failures occurs.

Now, it is very important to take into consideration the word BEFORE in the definition, as well as the INDEXING of the successes and failures. As a result, we can have different, and equally valid PMFs.

Let's call the last outcome $L$, and since we are dealing with binary outcomes, and the OP reads "...before there are $4$ tails", let's consider tails "failures" ($F$) and heads, "successes" ($S$), and see what can possibly happen before $L$. Since we are counting before $L$, there will be $S+F-1=3+4-1=6$ experiments carried out.

Since we are looking at the whole thing from the perspective of $L$, we'll focus on $F$ ($L$ is a "failure"), and we can say that there'll be $F-1$ ways of selecting or choosing these failed experiments before $L$ among the $S+F-1$ calculated in the prior paragraph. This is $\binom{S+F-1}{F-1}.$

Moving on to the probability of this happening, we can see that, before $L$, we could calculate $\Pr(S)^{\text{no.S}}\times \Pr(F-1)^{\text{no. F - 1}}$. BUT we also need to include the probability of $L$ as the last, determining outcome. Hence,


In this case,

$$\Pr(3S\text{ before }4F)=\binom{3+4-1}{4-1}0.5^7=0.15625$$

In R,

dnbinom(x = 3, size = 4, prob = 0.5) = 0.15625

Here x is the number of successes (the outcome complementary to $L$: "heads"): $S=3$. In contrast, size is the total number of outcomes like $L$, including $L$: $F=4.$

PROOF: Since we have three answers with different results, I just resorted to brute force:

n = 10^6  #no. simulations
sam = replicate(n, sample(0:1, 7, replace = T))
L = sam[,sam[7,]==0]
(freq_ending_in_T_and_three_heads = sum(colSums(L)==3)/n)
[1] 0.156561
  • $\begingroup$ For contrast, I found this post, in which the actual final, $L$, outcome is actually a head, "What is the probability you get the 4th cross before the 3rd head, flipping a coin?", calculated in R as dnbinom(4,3,0.5). $\endgroup$ – Antoni Parellada Dec 9 '16 at 16:58

The problem can be viewed as "heads" winning $\ge 3$ matches in a $6$ match series,

$$thus\quad \dfrac {\sum_{k=3}^6 \binom6{k}}{2^6} = \frac{21}{32}$$


Since an unorthodox method has been used in lieu of the negative binomial distribution to arrive at the answer easily, I am confirming by brute forcing.
An exhaustive list of disjoint favorable cases is given below:

Note that as soon as we get three heads, we can stop the experiment, which means that the last result must be heads

  • $Two\; heads\; |H : \dfrac18$

  • $Two\; heads,\; one\; tail\; |H : \dfrac{\binom31}{16}$

  • $Two\; heads,\; two\; tails\; | H: \dfrac{\binom42}{32}$

  • $Two\; heads,\; three\; tails\; | H: \dfrac{\binom53}{64}$

$\dfrac18 +\dfrac3{16}+\dfrac{6}{32} + \dfrac{10}{64} = \dfrac{42}{64} = \dfrac{21}{32}$

The simplification I made is that once $3$ heads have been obtained within a span of $6$ trials, the results of subsequent trials don't matter, so any result of $\ge3$ "wins" in a fixed series of $6$ trials gives the answer.


Not the answer you're looking for? Browse other questions tagged or ask your own question.