Interview question: You have two unfair coins with respectively $p_1$ and $p_2$ probability of head. You toss both coins 3 times, first coin gets 2 heads while second gets 1 head. What is the probability $P(p_1>p_2)$?
I think that I should use bayesian inference but I am not sure how to, especially with discrete variables. And also I am not sure of how to deal with the comparison, should I do a joint distribution? Any help is appreciated, thanks!
The answer they were probably (hopefully) looking for was that you can't tell without knowing the prior distributions of $p_1$ and $p_2$.
But lets do the calculation for the standard “uninformative” priors – the uniform prior over $[0,1]$, the Haldane prior $\frac1{p(1-p)}$ and the Jeffreys prior $\frac1{\sqrt{p(-1p)}}$.
For the uniform prior, the observations yield the posteriors $12p_1^2(1-p_1)$ and $12p_2(1-p_2)^2$, respectively, and integrating over the region where $p_1\gt p_2$ yields
\begin{eqnarray*} P(p_1\gt p_2)&=&12^2\int_0^1\mathrm dp_1p_1^2(1-p_1)\int_0^{p_1}\mathrm dp_2p_2(1-p_2)^2\\ &=&12^2\int_0^1\mathrm dp_1p_1^2(1-p_1)\left(\frac14p_1^4-\frac23p_1^3+\frac12p_1^2\right)\\ &=&\frac{53}{70}\\ &\approx&0.757\;. \end{eqnarray*}
For the Haldane prior, the observations yield the posteriors $2p_1$ and $2p_2$, respectively, and integrating over the region where $p_1\gt p_2$ yields
\begin{eqnarray*} P(p_1\gt p_2)&=&2^2\int_0^1\mathrm dp_1p_1\int_0^{p_1}\mathrm dp_2(1-p_2)\\ &=&2^2\int_0^1\mathrm dp_1p_1\left(p_1-\frac12p_1^2\right)\\ &=&\frac56\\ &\approx&0.833\;. \end{eqnarray*}
For the Jeffreys prior, the observations yield the posteriors $\frac{16}\pi p_1^{\frac32}p_1^{\frac12}$ and $\frac{16}\pi p_2^{\frac12}p_2^{\frac32}$, respectively, and integrating over the region where $p_1\gt p_2$ yields (with help from Wolfram|Alpha)
\begin{eqnarray*} P(p_1\gt p_2)&=&\frac{2^8}{\pi^2}\int_0^1\mathrm dp_1p_1^{\frac32}p_1^{\frac12}\int_0^{p_1}\mathrm dp_2p_2^{\frac12}p_2^{\frac32}\\ &=&\frac12+\frac{2^7}{45\pi^2}\\ &\approx&0.788\;. \end{eqnarray*}
So, as might have been expected, the result for the Jeffreys prior with exponent $\frac12$ lies somewhere between the ones for the uniform prior with exponent $0$ and the Haldane prior with exponent $1$.
Despite the differences, we can conclude that we should expect with a probability somewhere in the vicinity of $0.8$ that the coin that yielded heads twice has a higher probability for heads than the one that yielded heads once.