Find the density function of a random variable that depends on two other random variables with a given joint distribution. For example,

The joint density of $X$ and $Y$ is given by
  $$f(x, y) = \begin{cases}e^{-x-y}&\text{ if } 0<x<\infty, 0<y<\infty\\ 0 &\text{ otherwise}\end{cases}.$$
  Find the density function of the random variable $Z = X/Y$.

How would I do or even approach a problem like this?
Source http://dept.stat.lsa.umich.edu/~ionides/425/notes/joint_rvs.pdf
 A: There are a couple ways. First, it's usually easiest to attack these things through the CDF. We have $$ F_Z(z) = P(Z\le z) = P(X/Y\le z) = P(X\le zY).$$ Then we can express the final probability as an integral. We want to integrate the joint PDF of $X$ and $Y$ over the region $x\le zy.$ This can be set up as $$ \int_0^\infty \int_0^{zy}e^{-(x+y)}dx\; dy = \int_0^\infty e^{-y}\int_0^{zy}e^{-x}dx\; dy \\= \int_0^\infty e^{-y}(1-e^{-zy})dy \\= \int_0^\infty (e^{-y}-e^{-(z+1)y})dy \\= 1-\frac{1}{z+1}.$$
Now, the PDF is the derivative of the CDF, $$ f_Z(z) = \frac{d}{dz}\left(1-\frac{1}{z+1}\right) = \frac{1}{(z+1)^2}.$$
Another way is, if you're familiar with variable transformations. We can set $Z=X/Y$ and $W = XY$ and then do a transformation of the PDF to get $f_{Z,W}(z,w)$ and then integrate over $w$ to get the marginal PDF of $Z.$
Finally, there is a general formula for the quotient of two continuous random variables (that can be derived from either of these two methods: $$ f_Z(z) = \int uf_{X,Y}(u,zu) du$$
A: $P\{\frac X Y \leq t\}=P\{X\leq tY\}=EP\{X\leq tY|Y\}$
$=E\int_o^{tY} e^{-x} \, dx=E(1-e^{-tY})=\int_0^{\infty} (1-e^{-ty}) \, e^{-y}dy=1-\frac 1 {1+t}=\frac t {1+t}$.  Differentiating we get the density as $\frac 1 {(1+t)^{2}}$
A: I believe the procedure is to first rewrite the inequality, sketch the area that the inequality represents in $\mathbb R^2$ and then integrate the joint pdf over this area.


*

*Rewrite the inequality:


Your first instinct might be to cross-multiply:
$$P(Z := \frac X Y \le z) = P(X \le Yz)$$
But wait, can we cross-multiply inequalities? Yes if $Y > 0$ surely. What if $Y > 0$ only almost surely, i.e. $P(Y > 0) = 1$ but technically we don't have surely that $Y > 0$ (Precisely there are $\omega$'s s.t. $Y(\omega)<0$, but they are too small to count)?
Well then, we'll use total probability:
$$P(\frac X Y \le z) = P(\frac X Y \le z \cap Y > 0) + P(\frac X Y \le z \cap Y < 0)$$
$$ = P(X \le Yz \cap Y > 0) + P(X \ge Yz \cap Y < 0)$$
Now consider the latter term, $P(X \ge Yz \cap Y < 0)$. Observe that $\{X \ge Yz \cap Y < 0 \} \subseteq \{Y<0 \}$. By monotonicity of probability, since $P(Y<0)=0$, (*) we have that $P(X \ge Yz \cap Y < 0) = 0$.
Hence,
$$P(\frac X Y \le z) = P(X\le Yz)$$


*Sketch the area.


You may have noticed in the beginning that the expression $'\frac X Y \le z'$ looks something like an area below or above a line. That's because it is. But which area? Le't take cases.
Case 1: $z<0$
Since $P(X<0)=0$ for the same symmetric reasoning as $P(Y<0)=0$ (*), we have that $P(X \le zY)=P(0<X \le zY < 0) = P(\emptyset) = 0$ because $\{0<X \le zY < 0\}=\{0<0\}=\emptyset$. Nothing to sketch here.
Case 2: $z=0$
Again, since $P(X<0)=0$, we have that $P(X \le zY)=P(X \le 0)=P(X<0)=0$. Nothing to sketch here.
Case 3: $z>0$
Finally, we have something to sketch, namely the set $\{X \le zY\}$. Observe that $X = zY$ is a line, if we plot $Y$ vertically and $X$ horizontally. Imagine $z=5$. Consider any point in $\mathbb R^2$, say $(0,1)$. Is that in the set? Yes. Let's check: $0 = X \le z(1) = z = 5$ is true, and this extends to any $z > 0$. Thus, $\{X \le zY\}$ is all the points above the line $X \le zY$ as seen in $(0,1)$, which is above $X \le zY$. We have shown that $Y>0$, $X>0$ almost surely, hence, by total probability,
$$P(X \le zY) = P(0 < X \le zY)$$


*Integrate


Case 1: 0
Case 2: 0
Case 3:
Let $y_0 < 0, y_1 > 0, x_0 < 0, x_1 > 0$. Try to sketch a rectangle with these 4 lines as boundaries and then draw $x=zy$ as a diagonal of the rectangle. Then,
$$P(X \le zY) = \lim_{(y_0,y_1,x_0) \to (-\infty,\infty,-\infty)} \int_{y_0}^{y_1}\int_{x_0}^{zy} f(x,y) dx dy$$
$$\implies P(X \le zY) = P(0 < X \le zY) = \lim_{(y_0,y_1) \to (-\infty,\infty)} \int_{y_0}^{y_1}\int_{0}^{zy} f(x,y) dx dy$$
Because $Y>0$ almost surely, we have $$P(X \le zY) = \lim_{y_1 \to \infty} \int_{0}^{y_1}\int_{0}^{zy} f(x,y) dx dy$$
For reversed order of integration, we have:
$$P(X \le zY) = \lim_{(x_1,y_1,x_0) \to (\infty,\infty,-\infty)} \int_{x_0}^{x_1}\int_{\frac x z}^{y_1} f(x,y) dy dx$$
$$\implies P(X \le zY) = P(0 < X \le zY) = \lim_{(x_1,y_1) \to (\infty,\infty)} \int_{0}^{x_1}\int_{\frac x z}^{y_1} f(x,y) dy dx$$
I'll do the one without the fraction in the bound for integration:
$$P(X \le zY) = \lim_{y_1 \to \infty} \int_{0}^{y_1}\int_{0}^{zy} f(x,y) dx dy$$
$$ = \lim_{y_1 \to \infty} \int_{0}^{y_1}\int_{0}^{zy} e^{-x}e^{-y}1_{x>0}1_{y>0} dx dy$$
$$ = \lim_{y_1 \to \infty} \int_{0}^{y_1}\int_{0}^{zy} e^{-x}e^{-y} dx dy$$
$$ = \lim_{y_1 \to \infty} \int_{0}^{y_1}e^{-y}\int_{0}^{zy} e^{-x} dx dy$$
$$ = \lim_{y_1 \to \infty} \int_{0}^{y_1}e^{-y} [- e^{-zy} + e^{0}] dx dy$$
$$ = \lim_{y_1 \to \infty} \int_{0}^{y_1}e^{-y} [- e^{-zy} + 1] dx dy$$

(*) Pf that $P(Y<0)=0$, i.e. $P(Y > 0)=1$, i.e. $Y>0$ almost surely.
$$P(Y<0) = \int_{y<0} f_Y(y) dy = \int_{y<0} \int_{\mathbb R} f_{X,Y}(x,y) dx dy = \int_{y<0} \int_{\mathbb R} e^{-x}e^{-y}1_{x>0,y>0} dx dy$$
$$ = \int_{y<0} \int_{\mathbb R} e^{-x}e^{-y}1_{x>0}1_{y>0} dx dy = \int_{y<0} e^{-y} 1_{y>0} \int_{\mathbb R} e^{-x}1_{x>0} dx dy = \int_{y<0} e^{-y} 1_{y>0} \int_{x>0} e^{-x} dx dy$$
$$ = \int_{y<0} e^{-y} 1_{y>0} (1) dy = \int_{y<0} e^{-y} 1_{y>0} dy = \int_{\mathbb R} e^{-y} 1_{y>0} 1_{y<0} dy = \int_{\mathbb R} e^{-y} (0) dy = \int_{\mathbb R} 0 dy = 0$$
QED
