# Die roll and coin flip - Bayes' theorem

I am thinking to the question posed here: Die roll and coin flip.

"Suppose I roll a 4-sided die, then flip a fair coin a number of times corresponding to the die roll. Given that i got three heads on the coin flip, what is the probability the die score was a 4?"

We are looking for $$P(\textrm{die} = 4 | 3\ \textrm{heads})$$. I wanted to verify Bayes' theorem by just counting the events.

Let's suppose that the order of the coin flipping matters:

• if the die scores 1, the coin cannot score 3 heads, out of 2 possible events.
• if the die scores 2, the coin cannot score 3 heads, out of 4 possible events.
• if the die scores 3, the coin can score 3 heads in 1 way, out of 8 possible events.
• if the die scores 4, the coin can score 3 heads in 4 ways, out of 16 possible events.

So, I count: $$P(3\text{ heads})= \frac{5}{30}\\ P(3\text{ heads}|\text{die}=4)=\frac{4}{16}\\ P(\text{die}=4)=\frac14$$ so, by Bayes' theorem, I compute $$P(\text{die=4}|3\text{ heads})=\frac{P(3\text{ heads}|\text{die}=4)P(\text{die}=4)}{P(3\text{ heads})}=\frac{4}{16}\frac14\frac{30}5=\frac38.$$ If I just count the events, I see that there are 5 combinations with 3 heads, and 4 are possible if the die scores 4, so I expect $$P(\text{die=4}|3\text{ heads})$$ to be equal to 4/5 and not 3/8.

We can redo the exercise disregarding the order of the coin flips:

• if the die scores 1, the coin cannot score 3 heads, out of 2 possible events.
• if the die scores 2, the coin cannot score 3 heads, out of 3 possible events.
• if the die scores 3, the coin can score 3 heads in 1 way, out of 4 possible events.
• if the die scores 4, the coin can score 3 heads in 1 way, out of 5 possible events.

So, I count: $$P(3\text{ heads})= \frac{2}{14}\\ P(3\text{ heads}|\text{die}=4)=\frac15\\ P(\text{die}=4)=\frac14$$ so, by Bayes' theorem, I compute $$P(\text{die=4}|3\text{ heads})=\frac{P(3\text{ heads}|\text{die}=4)P(\text{die}=4)}{P(3\text{ heads})}=\frac15\frac14\frac{14}2=\frac{7}{20},$$ which in turn, reasoning like above, is not the expected 1/2.

What am I missing?

I'll compute the probability of getting 3 heads ($$h$$). As you wrote, we only have two possibilities: either we got a roll of 3 from the die $$d=3$$, or $$d=4$$. So: $$P(h=3) = P(h=3 \cap d = 3) + P(h=3 \cap d = 4)$$ $$P(h=3) = P(h=3 | d = 3) \cdot P(d = 3) + P(h=3 | d = 4) \cdot P(d = 4)$$ $$P(h=3) = \binom{3}{3} \cdot \frac{1}{2^3} \cdot \frac{1}{4} + \binom{4}{3} \cdot \frac{1}{2^4} \cdot \frac{1}{4}$$ $$P(h=3) = \frac{1}{32} + \frac{2}{32} = \frac{3}{32}$$

With this, the computation of the answer is obtained by applying the conditional probability formula: $$P(d=4 | h=3) = \frac{P(d=4 \cap h=3)}{P(h=3)} = \frac{\frac{2}{32}}{\frac{3}{32}} = \frac{2}{3}$$

So, this was like applying Bayes theorem step by step.

Note that your second and third approaches are not correct because you can't compute probabilities using the number of events if they are not equiprobable. In the second approach each event when $$d=4$$ is less probable than when $$d=3$$ and in the third approach it is the other way around.

• Thanks @DavidK for the comment. I've corrected my post accordingly. – Ertxiem Apr 19 at 0:22

I give you credit for plenty of effort in this question. There's a fundamental error in the idea behind the question, but that's part of math, finding out which ideas are good and which are erroneous.

The fundamental flaw is that counting events only works when the events are equally likely to occur. You seem to have found four different ways to count events, resulting in four different answers ($$\frac38,$$ $$\frac45,$$ $$\frac7{20},$$ and $$\frac12$$), but every single time you have included events of unequal probability in your count.

In order to figure the probability by counting, you have to find a way to list the outcomes in a way so that each individual observation is equally likely. One way to do that would be to flip the coin four times no matter what the die showed, but if the die shows $$N$$ you have to get three heads within the first $$N$$ flips. You don't use the remaining flips to reach the goal of three heads, but you do use them to count the outcomes. So on a roll of $$1$$ you have $$16$$ possible outcomes, all of which fail to get three heads within the required number of flips, and likewise there are another $$16$$ failing outcomes if the roll is $$2.$$ If the roll is $$3$$ then exactly two of the $$16$$ possible sequences of flips give you three heads within the first three flips: $$HHHH$$ and $$HHHT.$$ If the roll is $$4$$ then the sequences $$HHHH$$ has too many heads, but you have a total of four sequences that each produce exactly three heads as required.

So, counting equally likely outcomes in this way (each outcome being a number on the die and the results of a sequence of four flips), we have a total of $$4 \times 16 = 64$$ outcomes, of which exactly $$2$$ outcomes give you a roll of $$3$$ followed by three heads in the first three flips, and exactly $$4$$ give you a roll of $$4$$ followed by exactly three heads in the first four flips. So:

\begin{align} P(3\text{ heads})&= \frac{6}{64}\\ P(3\text{ heads}\mid\text{die}=4)&=\frac{4}{16}\\ P(\text{die}=4)&=\frac14 \end{align} and therefore $$P(\text{die}=4\mid3\text{ heads})= \frac{P(3\text{ heads}|\text{die}=4)P(\text{die}=4)}{P(3\text{ heads})} =\frac{4}{16}\frac14\frac{64}6=\frac23.$$

If you just count events that have three heads in the first number-showing-on-the-die flips, there are $$6$$ such events, of which $$4$$ occur after rolling a $$4,$$ which also gives a probability of $$\frac46 = \frac23.$$