# Derivation of the density function of product of two random variables

I am looking for distribution of product of two random variables. Best I could found so far was this formula from the relevant Wikipedia page:

$$f_Z(z) = \int_{-\infty}^{+\infty} \frac{1}{|x|} f_{XY}(x, \frac{z}{x}) dx$$

However, when I try to derive it myself, I find a different result.

The work I have done so far is below.

$X$: The first random variable
$Y$: The second random variable
$Z$: The product of these two random variables; that is:

$$Z = XY$$

$$F_Z(z) = P(Z \leq z) = \iint\limits_{D_z} f_{XY}(x, y) dx dy$$

Region of $Z$, $D_Z$, depends on the sign of $Z$:

So I decided to solve it in the situations; for $z<0$ and $z>0$.

• Case #1 - $(z>0)$

$$F_Z(z) = \int_{y=-\infty}^{y=0} \int_{x=\frac{z}{y}}^{x=0} f_{XY}(x, y) dx dy + \int_{y=0}^{y=+\infty} \int_{x=0}^{x=\frac{z}{y}} f_{XY}(x, y) dx dy$$ $$f_Z(z) = \frac{d F_Z(z)}{dz} = \int_{y=-\infty}^{y=0} (-\frac{1}{y}) f_{XY}(\frac{z}{y}, y) dy + \int_{y=0}^{y=+\infty} (\frac{1}{y}) f_{XY}(\frac{z}{y}, y) dy$$

• Case #2 - $(z<0)$

$$F_Z(z) = \int_{y=-\infty}^{y=0} \int_{x=0}^{x=\frac{z}{y}} f_{XY}(x, y) dx dy + \int_{y=0}^{y=+\infty} \int_{x=\frac{z}{y}}^{x=0} f_{XY}(x, y) dx dy$$ $$f_Z(z) = \frac{d F_Z(z)}{dz} = \int_{y=-\infty}^{y=0} (\frac{1}{y}) f_{XY}(\frac{z}{y}, y) dy + \int_{y=0}^{y=+\infty} (-\frac{1}{y}) f_{XY}(\frac{z}{y}, y) dy$$

By combining these two cases, I find the general partial equation:

$$f_Z(z) = \left\{ \begin{array}{ll} + \int_{y=-\infty}^{y=0} \frac{1}{y} f_{XY}(\frac{z}{y}, y) dy - \int_{y=0}^{y=+\infty} \frac{1}{y} f_{XY}(\frac{z}{y}, y) dy & \mbox{if } z < 0 \\ ??? & \mbox{if } z = 0 \\ - \int_{y=-\infty}^{y=0} \frac{1}{y} f_{XY}(\frac{z}{y}, y) dy + \int_{y=0}^{y=+\infty} \frac{1}{y} f_{XY}(\frac{z}{y}, y) dy & \mbox{if } z > 0 \end{array} \right.$$

Why is my solution SO different from the one in Wikipedia? What am I doing wrong? Can you please fix any mistakes in my derivation, or make the derivation in your own way?

-
Actually, it seems that your formula for $z>0$ coincides with the formula in the wikipedia page. So I guess your solution is not SO different from the wikipedia one. Are you familiar with the transformation theorem of random variables with density? –  Stefan Hansen Jan 19 '13 at 11:51

There are two reasons: 1. The wikipedia solution is obtained by conditioning on x and eliminating y, but you are trying the other way (which is also correct, the only difference comes in the way you handle the inequalities). 2. You don't have to divide the problem into two cases of z, because the inequalities wrt x & y are not affected by the sign of z.

-

When $X$ and $Y$ are independent, things are very simple..

\begin{align} P(Z\in dz)=&\int P(Z\in dz| X\in dx)P(X\in dx)\\ =&\int E[\delta(xY-z)]P(X\in dx)\\ =&\int\frac{1}{|x|}P(Y\in dz/x)P(X\in dx), \end{align} where we have used the elementary property $\delta(z/x)=\delta(z)/|x|$ to go from the penultimate to the last line.

-

Personally I think the easiest way to get this formula (and many others) is using the following equation. It is essentially the definition of the probability density of the random variable $Z$:

$$P_Z(z) := \mathsf{E} \left[ \delta(Z-z) \right]$$

where $z$ are the possible outcomes of $Z$, and $\mathsf{E}$ denotes expectation value. The equation above is the continuous analogue of the intuitive "sum over favorable cases" for the probability of a certain event. In this case the event is $Z=z$. Now we use the fact that $Z=XY$ and call $P_{X,Y}$ the joint probability distribution of $X, Y$. So

$$P_Z(z) = \int\!\!\!\!\int dx dy P_{X,Y}(x,y) \delta(xy-z).$$

Now change variables to, say, $(s,t)$ with $s=xy$ and $t=x$ or $x=t, y=s/t$. The Jacobian determinant of the transformation is

$$\frac{\partial(x,y)}{\partial(s,t)} = \frac{1}{|t|}$$

Hence $$P_Z(z) = \int\!\!\!\!\int ds dt \frac{1}{|t|} P_{X,Y}(t,s/t) \delta(s-z) = \int dt \frac{1}{|t|} P_{X,Y}(t,z/t)$$

-