How is the equation $P(X_1>X_2) = \displaystyle \int_{0}^1 P(X_1>X_2 | X_2=x) f_{X_2}(x) dx$ derived?

In Probability and uniform distribution, the following equation is used:

$P(X_1>X_2) = \displaystyle \int_{0}^1 P(X_1>X_2 | X_2=x) f_{X_2}(x) dx$

How the equation is derived? Base on which definition or theorem?

• It is the Total Probability Theorem for continuos densities Jan 16, 2016 at 7:37
• @sinbadh, en.wikipedia.org/wiki/Law_of_total_probability only talks about Total Probability Theorem for discrete probability distribution. Can you point out any reference for Total Probability Theorem for continuos densities? Jan 16, 2016 at 7:56
• en.wikipedia.org/wiki/Conditional_probability_distribution has references, but the general idea is the given by @angryavian in his answer Jan 16, 2016 at 8:02

It follows from conditioning on $X_2$. In the case when $X_2$ is a discrete random variable, we have
When $X$ is a continuous random variable, the idea is the same, but we replace $P(X_2=x_2)$ with the density of $X_2$, and replace the sum with an integral. This gives the expression you wrote in your question. There are some technical issues with doing this, but I think you are at a point where you can overlook that.