/1000$. Each consecutive head you flip should make you more suspicious. The key question is: how quickly does the evidence pile up? A fair coin flips 10 heads in a row with probability
/2^{10} = 1/1024$, which is almost exactly
/1000$ -- suspiciously close to your prior odds against the bad coin. So after 10 heads, you should expect the posterior to be right around 50-50. That is the quick intuition before doing any algebra.
Quick Estimate: The prior odds of bad-to-fair are
: 999$. Each head multiplies the likelihood ratio by
/ 0.5 = 2$. After $k$ heads, the odds become
^k : 999$. For $k = 10$:
024 : 999 \approx 1 : 1$, so roughly even odds -- about 50%. For $k = 9$: $512 : 999 \approx 1 : 2$, so about 33%. For 95% confidence, you need
^k / 999 \geq 19$ (since 95/5 = 19), giving
^k \geq 18981$, so $k \geq 15$ (since
^{14} = 16384 < 18981 < 32768 = 2^{15}$).
Formal Derivation: Apply Bayes' theorem. Let $B$ denote the event that the coin is bad and $kH$ denote $k$ consecutive heads.
$P(B \mid kH) = \frac{P(kH \mid B)\,P(B)}{P(kH \mid B)\,P(B) + P(kH \mid \text{fair})\,P(\text{fair})}$
Since $P(kH \mid B) = 1$ and $P(kH \mid \text{fair}) = (1/2)^k$:
$P(B \mid kH) = \frac{\frac{1}{1000}}{\frac{1}{1000} + \frac{1}{2^k} \cdot \frac{999}{1000}} = \frac{1}{1 + \frac{999}{2^k}} = \frac{2^k}{2^k + 999}$
Part 1 ($k = 10$):
$P(B \mid 10H) = \frac{1024}{1024 + 999} = \frac{1024}{2023} \approx 0.506$
After 10 heads, you are just barely more likely than not to have the bad coin -- about 50.6%.
Part 2 ($k = 9$):
$P(B \mid 9H) = \frac{512}{512 + 999} = \frac{512}{1511} \approx 0.339$
After 9 heads, you are only about 34% confident -- not enough to call it.
Part 3 (finding the threshold for 95% confidence): Set $P(B \mid kH) \geq 0.95$:
$\frac{2^k}{2^k + 999} \geq 0.95 \implies 2^k \geq 0.95(2^k + 999) \implies 0.05 \cdot 2^k \geq 0.95 \cdot 999$
$2^k \geq \frac{0.95 \times 999}{0.05} = 18981$
Since