How to distinguish between two biased coins

I have two very biased coins:

1. The first coin (C1) lands on heads 95% of the time.
2. The second coin (C2) lands on heads only 1% of the time.

One of the coins has been selected and I want to determine which coin that is. I can toss the coin as many times as possible and record a series of heads and tails results.

Let's say I want to know with 99.99% confidence, and as soon as possible, which coin is being flipped. How can I do so?

I would like to flip the coin, and after each result either continue or make a decision on which coin I have. I don't need to know how many times to flip before I start.

(Sorry if this is a very basic question that has been asked before. I lack the vocab to know how to search for this problem).

• I don't have time to answer, but this is an awesome question. Sep 25, 2020 at 1:15
• Sounds like a task for a sequential probability ratio test which is known to have (on average) the smallest number of trials to reach a decision. Sep 25, 2020 at 1:50
• This feels like a homework question. Is this self-study? Sep 25, 2020 at 2:02
• It's not a homework question. It is related to my work but rewritten using coins.
– WW.
Sep 25, 2020 at 2:54
• There are two kinds of valid answers to this question, depending on what you mean by "as soon as possible:" would that mean (1) you wish to determine a minimal but fixed sample size that will produce a correct decision with a chance of 99.99% or (2) you wish to have a sequential decision procedure that will tell you when to stop flipping, as well as tell you which coin it is with 99.99% accuracy, that yields a minimal expected number of flips? The latter value is going to be less than the former, but in (2) you risk having to flip a long time in rare cases. Which is it?
– whuber
Sep 25, 2020 at 14:11

Say the odds of getting $$C_1$$ over $$C_2$$ are, in principle, $$1:1$$. Then, you flip the coin $$n$$ times and get $$x$$ heads. If we call the probabilities of heads $$p_1=0.95$$ and $$p_2=0.01$$, then the probability that each coin gives $$x$$ heads is:

$$P(x|C_1)=p_1^x(1-p_1)^{n-x}$$

$$P(x|C_2)=p_2^x(1-p_2)^{n-x}$$

If we use Bayes theorem, we get the odds that the coin is $$C_1$$ including the information from the coin tosses:

\begin{align} \frac{P(C_1|x)}{P(C_2|x)}&=\frac{P(C_1)\cdot p_1^x(1-p_1)^{n-x}}{P(C_2)\cdot p_2^x(1-p_2)^{n-x}}\\ &=\frac{p_1^x(1-p_1)^{n-x}}{p_2^x(1-p_2)^{n-x}}\\ &=\left(\frac{p_1}{p_2}\right)^x\left(\frac{1-p_1}{1-p_2}\right)^{n-x} \end{align}

For example, if you tossed the coin 3 times and had 2 heads, you would have:

$$\frac{P(C_1|x)}{P(C_2|x)}=\left(\frac{0.95}{0.01}\right)^{2}\left(\frac{0.05}{0.99}\right)^{1}\approx456$$

That means the odds that the coin is $$C_1$$ are $$456:1$$, which is equivalent to a probability of $$\frac{456}{456+1}\approx99.8\%$$. That looks like a huge value for such a low number of trials, and the reason is that the probabilities $$95\%$$ and $$1\%$$ are very different. If the coins had closer probabilities, the odds would not be so dramatic.

• Thank you for this answer. It has made me realise that a more accurate description of my problem includes that C1 is much more common than C2. So we could say I have a bag of 100 x C1 and 1 x C2 and I want to detect the C2 coin.
– WW.
Sep 25, 2020 at 3:15
• @WW In that case P(C1) and P(C2) change, but the approach remains the same. Sep 25, 2020 at 4:51
• How does Bayes' theorem apply here, since there is no prior distribution??
– whuber
Sep 25, 2020 at 14:08
• @whuber there is a prior distribution, given by $(P(C_1),P(C_2))$. I assumed the prior odds were 1:1, therefore they cancelled when finding the posterior odds. It was a rather arbitrary assumption though, and the OC's comment indicates that it would be better to use 100:1 prior odds Sep 25, 2020 at 17:43
• There is no prior distribution mentioned in the question. Indeed, it's not necessarily the case that there is any relevant distribution.
– whuber
Sep 25, 2020 at 18:33