probability interview questions of posterior probability of two unfair coins

Here is a probability interview questions: two independent unfair coins with probabilities of head, $$p_1,p_2\sim U(0,1).$$ Then what's the probability of $$p_1>p_2$$ if we tossed each coin 3 times with 2 head for $$p_1$$ and 1 head for $$p_2?$$ We simply denote as:

$$P(p_1>p_2| 2H^1,1H^2).$$

I know we should use Bayes formula: $$P(p_1>p_2| 2H^1,1H^2)P(2H^1)P(1H^1) = P(p_1>p_2,2H^1, 1H^2).$$

And I know we can calculate $$P(2H^1),P(1H^2)$$ by $$P(2H^1) = \int^1_0p_1P(2H^1|p_1)dp_1.$$

But how to calculate the joint distribution $$P(p_1>p_2,2H^1, 1H^2)?$$ Am I right to calculate as: $$P(p_1>p_2,2H^1, 1H^1) = \int_{p_1,p_2\in [0,1],p_1 > p_2}P(2H^1|p_1)P(1H^2|p_2)dp_1dp_2?$$

\begin{align}\mathbb P(p_1>p_2,2H^1,1H^2)&=\int_{[0,1]\times[0,1]} \mathbb P(p_1>p_2,2H^1,1H^2|p_1,p_2)\underbrace{f_{P_1,P_2}(p_1,p_2)}_{f_{P_1}(p_1)f_{P_2}(p_2)=1}dp_1dp_2\\&=\int_{[0,1]\times[0,1]}\mathbb P(p_1>p_2|p_1,p_2)\mathbb P(2H^1|p_1,p_2)\mathbb P(1H^2|p_1,p_2)dp_1dp_2\\&=\int_{[0,1]\times[0,1]} \mathbb I(p_1>p_2)\mathbb P(2H^1|p_1)\mathbb P(1H^2|p_2)dp_1dp_2\\&=\int_{p_1,p_2\in [0,1] \cap p_1>p_2}\mathbb P(2H^1|p_1)\mathbb P(1H^2|p_2)dp_1dp_2\end{align}
• for the second equation, why is $P(p_1>p_2|p_1,p_2)$ independent on the $P(2H^1|p_1,p_2)?$ Nov 22, 2020 at 5:47
• Because given $p_i$, the event $p_1>p_2$ is deterministic and doesn’t depend any other event Nov 22, 2020 at 7:15