Integral of cdf times pdf is a probability? Let $X$ be a random variable with distribution function $F_X$.  Consider $$P=\int_0^\infty (1-F_X(x))e^{-x}dx.$$ Because $1-F_X(x)$ is the probability of $X>x$ and $e^{-x}$ is the pdf of an exponential random variable (with $\lambda=1$), this integral $P$ apparently equals the probability of $X>Y$ where $Y$ is an exponential random vairbale with $\lambda=1$.
Can anyone explain how we can conclude that $P$ is the probability of the event $X>Y$? I guess $X$ is defined over the same probability space as $X$?
 A: I am going to assume that $X$ is a non-negative continuous random variable so that $F_X(0) = 0$.
Let $Y \sim \text{Exp}(1)$ be independent of $X$ and note that $\mathbb{P}(Y < x) = 1-e^{-x}$.  To get the result you want, define the functions $u(x) \equiv 1-F_X(x)$ and $v(x) \equiv -e^{-x}$ and use integration by parts to get:
$$\begin{align}
\int \limits_0^\infty (1-F_X(x)) e^{-x} \ dx 
&= \int \limits_0^\infty u(x) \ v'(x) \ dx \\[6pt]
&= \Bigg[ u(x) \ v(x) \Bigg]_{x=0}^{x \rightarrow \infty} - \int \limits_0^\infty u'(x) \ v(x) \ dx \\[6pt]
&= \Bigg[ -(1-F_X(x)) e^{-x} \Bigg]_{x=0}^{x \rightarrow \infty} - \int \limits_0^\infty f_X(x) \ e^{-x} \ dx \\[6pt]
&= \Bigg[ 0-(-1) \Bigg] - \int \limits_0^\infty f_X(x) \ e^{-x} \ dx \\[6pt]
&= 1 - \int \limits_0^\infty f_X(x) \ e^{-x} \ dx \\[6pt]
&= \int \limits_0^\infty f_X(x) \ (1-e^{-x}) \ dx \\[6pt]
&= \int \limits_0^\infty f_X(x) \ \mathbb{P}(Y<x) \ dx \\[12pt]
&= \mathbb{P}(Y<X). \\[6pt]
\end{align}$$
(The final step follows from the law of total probability and the independence of $X$ and $Y$.)
A: 
Can anyone explain how we can conclude that P is the probability of the event $\mathbb P(X>Y)$?

Since $1-F_{X}(x)$ also called survival function is $\int_{x}^{\infty} f_{X}(t) \mathrm{d} t = P(X \geq x)$ because $F_{X}(x) = \int_{0}^{x} f_{X}(t) \mathrm{d} t$ where $\int_{0}^{\infty} f_{X}(t) \mathrm{d} t =1$, where $f_{X}(x) = e^{-x}$ is our PDF.
Also,
$$
\int_{0}^{\infty}\left(1-F_{X}(x)\right) \mathrm{d} x=\int_{0}^{\infty} P(X \geq x) \mathrm{d} x=\int_{0}^{\infty} \int_{x}^{\infty} f_{X}(t) \mathrm{d} t \mathrm{~d} x
$$
Then change the order of integration
$$
=\int_{0}^{\infty} \int_{0}^{t} f_{X}(t) \mathrm{d} x \mathrm{~d} t=\int_{0}^{\infty}\left[x f_{X}(t)\right]_{0}^{t} \mathrm{~d} t=\int_{0}^{\infty} t f_{X}(t) \mathrm{d} t  
$$
Then substitute
$$
= \int_{0}^{\infty} x f_{X}(x) \mathrm{d} x = \mathbb E(X)
$$
I copied it all.
I read before you may omit $F_{X}(x)$ and write just $F(x)$ same for the $f(x)$ when you know what RV you deal with.
