Coin Toss with Prior Distribution for $p$ I am attempting to answer the following question from my actuarial exams:

We are asked to find $P(p=0.5|X=7)$.
Using Bayes Rule, I believe this is
$$P(p=0.5|X=7) = \frac{P(X=7|p=0.5)P(p=0.5)}{P(X=7|p=0.5)P(p=0.5) + P(X=7|p \sim Unif[0.5,1])P(p \sim Unif[0.5,1])}$$
Straightforwardly, using $X \sim Bin(8,p)$:
$$P(X=7|p=0.5)P(p=0.5) = {8 \choose 7}0.5^70.5 \times 0.8$$
I am less sure of $P(X=7|p \sim Unif[0.5,1])P(p \sim Unif[0.5,1])$, if even this is the right expression. Given it's continuous, I thought it might be:
$$P(X=7|p \sim Unif[0.5,1])P(p \sim Unif[0.5,1]) = \int^1_{0.5}{P(x|p)f(p) dp}$$
where $P(x|p) = {8 \choose 7}p^7(1-p)$ and $f(p) = 2$ (being the pdf of $Unif[0.5,1]$). But this doesn't account for the probability of p being uniformly distributed, $P(p \sim Unif[0.5,1]) = 0.2$.
What is the correct way to think about this?
Many thanks
Steven

Great question!  I think your denominator would be better written as
$$P(X=7|p=0.5)\cdot P(p=0.5) $$
$$+\int_{0.5}^1 P(X=7|p= r\cap  0.5<p<1 )\cdot P(p=r|0.5<p<1)\cdot P(0.5<p<1)dr$$.
Let me know if I have made a mistake.  The term $P(p=r|0.5<p<1)$ is the pdf of the uniform distribution over (0.5,1) and the term $P(0.5<p<1)$ would account for the belief mass of 20%.  Here is a related thread asking about how to apply these probability statements to the coin and octopus under investigation.
