Show the Face

ExpectationConditional ProbabilityMarkov ChainsGeometric Distribution

Problem

Roll a fair standard 6-sided die until a 6 appears. Given that the first 6 occurs before the first 5, find the expected number of times the die was rolled.

Original Problem Link: Click here

Solution

Let us first drop the condition and solve the easy version:

"Roll a fair die until a 6 appears. What is the expected number of rolls?"

Let be the number of rolls. To take exactly rolls, the first must be non-6 and the -th must be a 6. The rolls are independent, so we just multiply:

This is geometric with , so .

Now add the condition: we are told the first 6 came before the first 5. What breaks?

Step 1: Why counting sequences goes wrong here

The tempting fix is this. If the 6 must beat the 5, then none of the rolls before it can be a 5, so each intermediate roll has only available — 4 faces instead of 5. So swap for :

First problem: multiplying per-roll probabilities was allowed because the rolls were independent. The condition is a statement about the whole run, not about each roll separately, so it couples the rolls together — knowing what roll 3 was tells you something about roll 7. That licence is gone.

Fine, so let us retreat to counting instead, and write everything as a fraction over sequences of length :

The numerator is honest enough: choices for each of the first rolls, with the last roll forced to be a 6.

But now look at the denominator. Our experiment stops at the first 6. So a run of length only exists if the -th roll is a 6! Any string that does not end in a 6 is not an outcome of our experiment at all — it is just the beginning of some longer run. It belongs to a bigger .

So the numerator counts finished runs while the denominator counts unfinished fragments, and the ratio is not measuring anything we asked for. There is no honest denominator to write, because a stopped experiment does not have a fixed-length sample space.

Interesting enough, In the unconditioned case we got away with this. " rolls failed, then one worked" is a fine argument there, and happens to be the right number. But that is the arithmetic being kind to us, not the framing being correct — and carrying the same argument over to the conditioned problem is not strictly valid, coz as discussed, individual throws aren't independant anymore.

Lets tackle this from another perspective, with something much more suited to handle infinite chain lengths, i.e. Markov Chains.

Step 2: The Markov chain

Track the only thing that matters: is the race between the first 5 and the first 6 still open? Faces decide nothing; only and do. So three states are enough:

  • running. No 5 and no 6 yet.
  • win. A 6 arrived with no 5 before it. This is our condition.
  • lose. A 5 arrived first.

One roll from does one of three things:

Both and are dead ends. Note that we call a dead end, purely because the first 5 coming before the first 6, invalidates the original condition given in the condition, and hence won't be a valid chain in our reduced sample space of "experiments which follow the given condition - i.e. the first 6 comes before the first 5".

Note that this Markov Chain formulation allows us to exploit the memoryless properly and simply multiply transition probabilities.. effectively removing the complications arising from "lack of independance between events" in the previous naive formulation of Step 1.

So the problem becomes:

"Starting at , find the expected number of steps to get absorbed, given that we end up at and not ."

Step 3: Probability of the condition

We want the probability that a run started at ends up at . Call it — and note this means ending at eventually, after however many rolls it takes, not the chance of jumping straight there on the next roll.

Condition on the first roll. With probability we land in at once, with probability we land in and are finished, and with probability we are back at — where, since the chain has no memory, our chances are described by the very same . So

Which is just what symmetry would tell us: and are interchangeable faces, so whichever shows up first is equally likely to be either one.

Now here is the point of computing this. The event is exactly what the problem conditions on — "the first 6 comes before the first 5" says precisely that our run ends at . So the quantity we are being asked for is

and to get it we need the conditional distribution

We have just found the denominator. The numerator — the probability of ending on a 6 at roll and the run finishing at — is what we work out next.

Step 4: The distribution, and the answer

How can the chain land in at step exactly ? Only one way — take the self-loop times, then the edge into :

A quick check that this is right: summing over all should give the total chance of winning,

which matches the from Step 3.

Now divide to get the conditional distribution:

So given the condition, is geometric with , and

Step 5: Sanity check

Unconditionally we expected rolls, and is smaller — which is the right direction, since long runs give the 5 lots of chances to sneak in first, and the condition throws exactly those away.

Thus, given that the first 6 occurs before the first 5, the expected number of rolls is