# What is the probability that a coin is fair?

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.

For the case where you are looking at $\mathbb P(H)$ assuming that the coin is unfair with a $\theta \sim U[0, 1]$ probability of landing heads, one can use a continuous analogue to the law of total probability to get

$$\mathbb P(H) = \int_\Omega \mathbb P(H\mid \theta)f(\theta)d\theta$$ where $f$ is the pdf of $\theta$. In your case $\mathbb P(H \mid \theta) = \theta$, $f(\theta) = 1$ and $\Omega = [0, 1]$ so you end up with $$\mathbb P(H) = \int_0^1\theta d\theta$$

• Yes, it makes sense and thank you for clarifying. – Peter Feb 21 '17 at 9:55

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}$$

• Yes, I got stuck when I was thinking about this term. Thank you very much and I will give you an upvote as soon as I am qualified. LOL – Peter Feb 20 '17 at 22:27
• It seems that you made a little mistake. In the second part of this question, shouldn't the numerator be (1/2)*(1/4) instead of (1/2)*(1/3)? – Peter Feb 20 '17 at 22:34
• You are correct. I thought you were asking for the probability that the coin was unfair. I will edit. – lulu Feb 20 '17 at 22:35
• where do you automatically get $\int^1_0 pdp$ from?. Not really a good answer imo. – Slug Pue Feb 20 '17 at 22:37
• As the question described, If the coin is unfair, then the probability of head will be uniform distribution in [0, 1]. So.... – Peter Feb 20 '17 at 22:42

If it is unfair, the probablity that it will turn up heads is uniform in [0,1]: so Integrate: $\int_0^1 p dp = 1/2$

• Thank you so much, unfortunately, I don't have enough reputation for an upvote. I will give it to up as soon as I am qualified. – Peter Feb 20 '17 at 22:25