Distribution of $\frac{X}{X+Y}$, exponential On this site the distribution of $\frac{X}{X+Y}$ has been derived. Suppose $X$ and $Y$ are independently distributed exponential random variables with mean $1$. This means $f_X(x)=e^{-x}=P(X\geq x)$.
Then it starts with 
For $t\in (0,1)$
$$P\left(\frac{X}{X+Y}\leq t\right)=P\left(\frac{X+Y}{X}\leq \frac1t\right)$$
$$=P(Y\geq X(\frac1t-1))$$
So far so good. But the next step I really don´t understand.
$$=\int_0^{\infty} f_X(x)\cdot P(Y\geq x(\frac1t-1)) \, dx$$
It is obvious that $X \in (0, \infty)$. But the rest is unclear to me. I hope somebody can explain me why the two latter lines are equal.
Thanks for your time
calculus
 A: This is (one way) how we compute the expectation of a function of a random variable.  We write
$$
E[g(X)] = \int_{x=0}^\infty f_X(x) g(x) \, dx
$$
where $f_X(x)$ is the PDF of $X$.  This is assuming that $X$ ranges from $0$ to $\infty$; adjust the limits of integration accordingly if it's otherwise.
Some intuition for this expression might be obtained by considering the discrete case.  Suppose a random variable $X$ takes on values $1$, $2$, and $3$ with probabilities $p_1 = 1/2, p_2 = 1/3, p_3 = 1/6$.  What is $E(X^2)$?  We would write
$$
E(X^2) = \sum_{k=1}^3 p_k k^2 = \frac{10}{3}
$$
and in general,
$$
E[g(X)] = \sum_{k=1}^3 p_k g(k)
$$
Well, the continuous case is much the same thing, except that instead of $p_k$, we have $f_X(x)\, dx$.  But otherwise, the principle is the same.
A: In my opinion, this is simply an application/extension of the law of total probability for sets, i.e., $$P(A) = \sum_i P(B_i) \times P(A | B_i)$$ where $\{B_i\}$ is a disjoint of partition of the sample space.
If you thought about the joint pdf analogous to $P(A \, \text{and} \, B)$, marginal and conditional PDF's in the obviously analogous way, one can see that $$ \iint f(x,y) \, dx \, dy = \int f_X(x) \, f_{Y|X}(y|x) dx$$
Keep that in the background. Now dealing with $P(Y \geq X(1/t - 1))$ you are dealing with two random variables $X$ and $Y$ simultaneously. A way to approach it (from the total law of probability perspective) is to condition on one of them ($X$ in this case, which allows to handle that random variable $X$ as a real number $x$), multiply the expression by probability of $X$ being approximately that $x$ (this is loosely speaking the density of $X$), then integrate across all possible values of $x$. This is really an application of the law of total probability.
