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.
 A: 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}$$
A: 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$
A: 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?
