One coin in a thousand

You have 1000 coins. One of them has heads on both sides. The other 999 are fair. You pick a coin at random, flip it 10 times, and get heads every time.

What do you think?
You flip a random coin 10 times and get all heads. What's P(coin is the double-headed one)?

Applying Bayes' theorem

Let AA = the coin is double-headed, and BB = all 10 flips are heads.

Bayes' theorem calculation
P(A)=11000,P(Ac)=9991000P(A) = \frac{1}{1000}, \quad P(A^c) = \frac{999}{1000}
The prior: you picked one coin at random from 1000.
Step 1 of 6
The Unfair Coin

1000 coins: 1 has heads on both sides, 999 are fair. You pick one at random and flip it 10 times.

Getting 10 heads is 1024 times more likely with the unfair coin than the fair one. This ratio of 1024 nearly cancels the prior of 1/1000, pushing the posterior close to 1/2.

Why the numbers work out so neatly

The posterior odds are:

P(AB)P(AcB)=P(BA)P(BAc)P(A)P(Ac)=102419991.025\frac{P(A|B)}{P(A^c|B)} = \frac{P(B|A)}{P(B|A^c)} \cdot \frac{P(A)}{P(A^c)} = 1024 \cdot \frac{1}{999} \approx 1.025

The likelihood ratio (1024) and the prior odds (1/999) nearly cancel, leaving posterior odds close to 1:1.

If you'd gotten 11 heads instead of 10, the likelihood ratio would be 2048:

Posterior odds=204819992.05\text{Posterior odds} = 2048 \cdot \frac{1}{999} \approx 2.05

That would make P(AB)0.67P(A|B) \approx 0.67 — now the unfair coin is twice as likely as a fair one.

What do you think?
After getting 10 heads, you flip the coin once more and get tails. Now what's P(unfair coin)?

Practice

With 100 coins (1 unfair, 99 fair), you flip 10 heads. P(unfair)? (decimal like 0.91)
1/2