# Probability of fair coin given 20 heads observed

It's known that out of 1000000 coins there is one coin that has a head on both of its sides. If one coin is randomly selected out of those 1000000 coins and you observe 20 heads in 20 throws, what is the probability that the coin was fair?

My attempt:

Let F=coin is fair and N=20 heads were observed, we are looking for:

$$P(F | N)= \frac{P(N|F)P(F)}{P(N)}$$

with $P(F)=\frac{9999999}{1000000}$ and $P(N|F)=0.5^{20}, P(N|F^C)=1$

$$P(F|N) = \frac{0.5^{20}\frac{9999999}{1000000}}{0.5^{20}+1}$$

The result is extremly small, but then again the probability should be pretty small, can anybody please check my solution?

• If the denominator $P(N)$ is a probability, then how is it greater than $1$? – Thomas Andrews Feb 18 '15 at 14:32
• Consider if you only saw 2 heads in a row. How big do you think the probability should be in that case? – Joffan Feb 18 '15 at 14:33
• @ThomasAndrews Good point. I used P(20x heads) = P(20x|fair coin)+P(20x|not fair),where P(head|not fair)=1. So the result is obviously nonsense, but I don't see whats wrong with the approach. – eager2learn Feb 18 '15 at 14:36
• It seems you're getting confused with computing $P(N)$, as Thomas Andrews observed. Perhaps it would be easier to see how to proceed if you wrote $N$ as the disjoint union of the events $N = (N\cap F)\cup(N\cap F^{C})$, so that $P(N) = P(N|F)P(F)+P(N|F^{C})P(F^{C})$. – Alex Wertheim Feb 18 '15 at 14:36
• $P(N)\neq P(N\mid F)+P(N\mid F^c)$. – Thomas Andrews Feb 18 '15 at 14:37

Let A denote the event of picking a fair coin.

Let B denote the event of tossing $20$ consecutive heads.

$$P(A|B)=\frac{P({A}\cap{B})}{P(B)}=\frac{\frac{1000000-1}{1000000\cdot2^{20}}}{\frac{1000000-1}{1000000\cdot2^{20}}+\frac{1}{1000000\cdot1^{20}}}\approx48.81\%$$

• As $2^{20}\doteq10^6$ it is about equally likely to throw $20$ heads in a row with a fair coin as it is picking the single unfair coin. That's why the result comes up to roughly ${1\over2}$. – Christian Blatter Feb 18 '15 at 15:02
• @ChristianBlatter: Yep, didn't think of it that way though (i.e., I would not have intuitively guessed that the probability is approximately $50\%$ because $2^{20}\approx1000000$). Thanks for pointing that out. – barak manos Feb 18 '15 at 15:07
• Right, if you simplify the above, with $n=1000000$ and $k=20$, you get $\frac{n-1}{n-1+2^k}$, which works with $n$ coins and $k$ tosses. – Thomas Andrews Feb 18 '15 at 15:37

$P(F) = (N-1) / N$

$P(H\mid F) = 2^{-20} = p$

$P(H) = P(H \mid F)P(F) + 1 \cdot P(F^*) = p (N-1) / N + 1 / N$

$$P(F \mid H) = \frac{P(F, H)}{P(H)} = \frac{P(H\mid F)P(F)}{P(H)}$$

So,

$$P(F \mid H) = \frac{p (N-1) / N}{p (N-1) / N + 1 / N} = \frac{p (N-1)}{p (N-1) + 1} = 1 - \frac{1}{p (N-1) + 1} \approx 0.488.$$