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 $$
Also see this: Can we prove the law of total probability for continuous distributions?