# Using Bayes Theorem to calculate the probability of a coin being biased given a specific test result

Suppose I have a bag full of coins (could be any amount). One of the coins has a bias 2/3 towards heads and all the rest are fair. A random coin is then picked from the bag and tossed 25 times (the same coin is tossed all 25 times), and these tosses can be viewed as a test of whether the coin is biased or fair.

My question is then; Can you use Bayes Theorem to calculate the probability of the coin being biased 2/3 towards heads, given that all 25 tosses comes out heads?

Intuitively I would think so, but surely I would need to know the prior probability of the coin being bias 2/3 towards heads, and I can't know that without knowing how many coins are in the bag to begin with..?

I do know the probability of the test resulting in 25 heads out of 25 tosses given that the coin is biased 2/3 towards heads (0.000031) as well as the probability of the test resulting in 25 heads out of 25 tosses given that the coin is not biased (fair) (0.000000745). But I can't seem to figure out how to calculate the probability of the coin being biased in the first place P(biased)...

Let's say that the test resulting in 25 times heads out of 25 tosses is a positive result. Bayes Theorem would then (in my mind) look like this:

P(Biased|Positive) = ( P(Positive|Biased) * P(Biased) ) / ( P(Positive|Biased) * P(Biased) + P(Positive|not Biased) * P(not Biased) )

But I don't know P(Biased)...

• You are correct. The answer will depend on the number of coins in the bag as $P(\text{biased})= \frac{1}{a}$, where $a$ is the number of coins. – Harto Saarinen Nov 12 '17 at 15:36

B-biased coin

H_i -Experiment i came out heads

$P(B | H_1, H_2, ... H_{25}) = \frac{P(B) P(H_1, H_2, ... H_{25})}{P(H_1, H_2, ... H_{25} | B)}$

The denominator can be easily calculated since coin tosses are independent.

The numerator is equal to the joint probability $P(B, H_1, H_2, ... H_{25})$.

Let's expand that a little bit.

$P(B, H_1, H_2, ... H_{25}) = P(H_1, H_2, ... H_{25}, B) = P(H_1 | H_2, ... H_{25}, B) P(H_2, ... H_{25}, B) = ... = P(H_1 | H_2, ... H_{25}, B) P(H_2| H_3, ... H_{25}, B) ...P(H_{24}|H_{25}, B)P(H_{25}|B)P(B)$

But again from independence of coin tosses we know that $P(H_{i} | H_{i+1}, ... H_{25}, B) = P(H_i | B)$

So overall we have that reduces to $P(B) \prod_{i=1}^{25}P(H_i|B) = P(B) \prod_{i}^{25}\frac{2}{3} = (\frac{2}{3})^{25}P(B)$

You need to know that $P(B)$ is to calculate the answer (Meaning you are correct, the number of coins in the bag is missing), but this is the way.

• I can't upvote your answer due to my lack of reputation on here, but thank you anyway! Your answer does clarify the problem a bit, but I was still hoping that you could, if not calculate the exact probability, at least estimate the probability by finding the lower and upper probabilities or something similar. Given that I know the probability of the test being positive given a biased coin as well as the probability of the positive given a fair coin, it would make sense to me that I could find the probability of the coin being biased given a positive test, but I guess that's just not possible.. – Rasmus Eskesen Nov 12 '17 at 16:21
• @RasmusEskesen You could however accept the answer to close the question. – Oria Gruber Nov 13 '17 at 9:37