### Flipping coins!

Thanks to Peet Morris for this excellent example of probability running counter to common sense.

Imagine I have a huge stack of coins and flip them one after another. These are fair coins, with a 50:50 chance of coming up heads or tails.

First of all I flip the coins one after another (leaving the flipped coins on the table) until the sequence H T H comes up. At that point I stop and count the coins. Then I repeat this experiment many times.

For the second part I again flip the coins, leaving them on the table, until the sequence H T T comes up. At that point I stop and count the coins. Then I repeat the experiment many times.

On average would you expect it to take more flips to produce H T H, more flips to produce H T T or the same number of flips?

Common sense says this is pretty obvious. It's the same number of flips. And certainly if I take three coins and flip them, there's the same chance of H T H or H T T coming up. But, remarkably, things are different in the experiment above. On average you will take fewer flips to produce H T T than you would to to produce H T H.

Just take a moment to think how that might be possible.

Here's the sneaky probabalistic component that isn't obvious: in both cases, you need the sequence H T to come up first. Now imagine that you then get the wrong face on the next flip. So if you were looking for H T H you actually get H T T and vice versa. With this starting point, H T T has an advantage. If you were looking for H T T, and actually got H T H, then the last coin in the sequence is H. So you only need T T to complete your sequence. If you were looking for H T H and actually got H T T, then the last coin the sequence is T, so you need all three of H T H to complete the sequence.

The reason H T T does better is that the sequence of faces that isn't correct ends in the face that starts your sequence. For H T H, the wrong result produces a bad starting point, so you have to run the exercise that bit longer.