Find pdf of a random variable $Z$ which is a function of two random variables $X$ and $Y$.

Given two arbitrary positive constants $A$ and $B$, and two independent random variables $X$ and $Y$, I want to find out the pdf of $$Z=\frac{A+X}{B+Y}.$$

My process is as follows:

\begin{align} F_Z(z) &= \Pr\left\{Z \le z \right\} = \Pr\left\{\frac{A+X}{B+Y}\le z\right\}\\ &=\Pr\left\{X \le z(B+Y)-A \right\}\\ &= \int_{-\infty}^{\infty}\int_{-\infty}^{z(B+y)-A} f_{X,Y}(x,y)\,dx\,dy\\ &= \int_{-\infty}^{\infty}\int_{-\infty}^{z(B+y)-A} f_X(x) \cdot f_Y(y)\,dx\,dy.\\ \end{align}

By the Leibniz integral rule, \begin{align} f_Z(z) &= \frac{\partial}{\partial z} F_Z(z)\\ &= \int_{-\infty}^{\infty}\left(\frac{\partial}{\partial z}\int_{-\infty}^{z(B+y)-A}f_X(x) \cdot f_Y(y)\,dx\right)dy\\ &= \int_{-\infty}^{\infty}(B+y)\cdot f_X\left(z(B+y)-A\right) \cdot f_Y(y)\,dy\\ &= B\int_{-\infty}^{\infty}f_X\left(z(B+y-A\right)\cdot f_Y(y)\,dy + \int_{-\infty}^{\infty} y\cdot f_X\left(z(B+y)-A\right)\cdot f_Y(y)\,dy\\ \end{align}

Actually, if the process above is correct, $f_Z(z)$ must be non-negative whatever $A$, $B$, $z$ are, and $$\int_{-\infty}^{\infty}f_Z(z)\,dz$$ must be one. However, when I suppose that $X$ and $Y$ are i.i.d. Gaussian RVs, $f_Z(z)$ becomes negative despite having calculated $f_Z(z)$ three times. Is this just my calculation mistake? Is the process above correct?

• There is the possibility that $B+Y$ can be negative when you calculate $F_Z$. Of course, this is assuming there is no further restriction on $A,B$. – StubbornAtom Aug 12 '18 at 11:35
• @StubbornAtom Sorry, I edited my post from "arbitrary constraints $A$ and $B$" to "arbitrary positive constraints $A$ and $B$". – Danny_Kim Aug 12 '18 at 11:37

You cannot write $\frac {A+X} {B+Y} \leq z$ as $X \leq z(B+Y)-A$ so the first step is itself wrong. You have to write $\{\frac {A+X} {B+Y} \leq z \}$ as $\{X\leq z(B+Y)-A, B+Y>0\} \cup \{X\geq z(B+Y)-A, B+Y<0\}$ assuming that $Y$ is a continuous random variable ( so that $P\{B+Y=0)\}=0$).

• Thus, \begin{align}\Pr\left\{\frac{A+X}{B+Y}\le z\right\} &= \Pr\left\{Y>-B\right\}\times\Pr\left\{X\le z(B+Y)-A : Y>-B\right\}\\ &+ \Pr\left\{Y<-B\right\}\times\Pr\left\{X\ge z(B+Y)-A : Y<-B\right\}.\end{align} Do I have to solve this above equation, right? – Danny_Kim Aug 12 '18 at 11:47
• You are now on the right track. – Kavi Rama Murthy Aug 12 '18 at 11:52
• Thank you so much, if so lastly, is it correct if I solve the following equation? \begin{align} f_Z(z) &= \Pr\left\{Y\ge-B\right\}\int_{-B}^{\infty} \frac{\partial}{\partial z} \int_{-\infty}^{(B+y)z-A} f_{X,Y}(x,y)\,dx\,dy\\ &+ \Pr\left\{Y<-B\right\}\int_{-\infty}^{-B} \frac{\partial}{\partial z} \int_{(B+y)z-A}^{\infty} f_{X,Y}(x,y)\,dx\,dy, \end{align} where $X\sim\mathcal{N}(0,\sigma^2)$, $Y\sim\mathcal{N}(0,\sigma^2)$, and $f_{X,Y}(x,y) = f_X(x) f_Y(y)$. – Danny_Kim Aug 12 '18 at 12:00
• Once again, you are doing everything right. – Kavi Rama Murthy Aug 12 '18 at 12:05

The values of $X,Y$ that contribute to the same $Z$ are such that

$$Y=Z(A+X)-B.$$

Then taking $X$ as the independent variable

$$f_Z(z)=\int_{-\infty}^\infty f_X(x)\,f_Y(z(A+x)-B)\,dx.$$

• I do not understand your answer, can you state your answer in a bit more detail? – Danny_Kim Aug 12 '18 at 11:54
• @Danny_Kim: you add the product of probabilities of all $x,y$ combinations that give $z$. – Yves Daoust Aug 12 '18 at 11:58