Expression for one random variable greater than another random variable Say I have two independent random variables $X$ and $Y$ and I want to get an expression on the probability that $X$ is greater than $Y$. 
I saw somewhere that the expression is:
$$Pr[X>Y] = \int_{-\infty}^\infty \int_{x}^{-\infty} f_{X}(x)f_{Y}(y)dxdy$$
where $f_{X}$ and $f_{Y}$ refer to the PDF of $X$ and $Y$.
I do not understand the expression. Can someone explain intuitively how do you come up with this expression?
Thanks!
 A: The probability density of one point $(x,y)$ is $f_X(x) f_Y(y)$. You integrate the probability densities of all the points where $x>y$. You can do this in either integration order. 
Say you integrate $dx dy$, so the outer integral is the $y$ integral. Now $y$ can be anything, if $x$ hasn't been picked yet, so the outer limits are $-\infty$ to $\infty$. For the inner limits, you can think of it like $y$ has already been picked, so now you need the appropriate limits where $x>y$, which is $y$ to $\infty$. So you get
$$P[X>Y]=\int_{-\infty}^\infty \int_y^\infty f_X(x) f_Y(y) dx dy.$$
If you integrate the other way, then $x$ is unconstrained, and now for a given value of $x$, $y$ must be between $-\infty$ and $x$, so you get
$$P[X>Y]=\int_{-\infty}^\infty \int_{-\infty}^x f_X(x) f_Y(y) dy dx.$$
In a 2D situation like this it often helps to draw a picture. I can't easily do this on MSE, but I can instruct you how to do it:


*

*In the $dx dy$ integral, you draw the line $y=x$, you draw an arbitrary horizontal line (with $y$ fixed), and you include all points on the horizontal line located to the right of $y=x$. Since they are to the right of $y=x$, you have $x>y$. 

*In the $dy dx$ integral, you draw the line $y=x$, you draw an arbitrary vertical line (with $x$ fixed) and you include all points on the vertical line located below $y=x$. Since they are below $y=x$, you have $y<x$.

