[Math] the probability that a coin is fair

bayesianprobability

You paly a game with your friend Alice where you bet on the outcome of a coin toss. The coin has been provided by Alice. You think there is a 50% chance that she would have provided an unfair coin. If the coin is unfair then you believe that the probability that it will turn up heads is uniform in [0, 1].

The question is that,

1: You toss the coin and it comes up head. What is the probability that the coin is fair?

2: You toss the coin for the second time and it comes up head again. Now, what is the probability that the coin is fair?

For me, I solve this problem through this way,

P(fair|data) = $\frac{P(data|fair)P(fair)}{P(data|fair)P(fair)+P(data|unfair)P(unfair)}$

Where I know that P(fair)=0.5, P(data|fair)=$p^1(1-p)^0$=$p=0.5$ (as fair means P(head)=0.5=p), P(unfair)=0.5,

So, the previous equation can be substitued as,

P(fair|data) = $\frac{0.5*0.5}{0.5*0.5+P(data|unfair)*0.5}$

My question is how to express the term of P(data|unfair)?

Thanks.

Best Answer

Part 1: if the coin is fair, it comes up $H$ with probability $\frac 12$. If it is unfair then it comes up $H$ with probability $$\int_0^1 pdp=\frac 12$$. Thus the two cases are symmetric and the answer is $\boxed {\frac 12}$.

Part II. Now the probability that the unfair coin comes up $HH$ is $$\int_0^1 p^2dp=\frac 13$$ While the fair coin of course comes up $HH$ with probability $\frac 14$. Thus we apply Bayes to get $$\frac {\frac 12 \times \frac 14}{\frac 12 \times \frac 13+\frac 12 \times \frac 14}=\boxed {\frac 37}$$