The PDF of a Function of Two Random Variables

Shoichi Midorikawa

General Formula

 Let \(X\) and \(Y\) be two independent continuous random variables. Suppose \(Z\) is a function of \(X\) and \(Y\), i.e., \(z = \varphi(x, y)\), then the pdf of \(z\) is \[ f_Z(z) = \int \delta \left(z-\varphi(x, y) \right) f_X(x) f_Y(y) \, dx \, dy \] where \( \delta \left(z-\varphi(x, y) \right) \) is the Dirac delta function.

 To evaluate the integral, it is convenient to use the formula \[ \delta\left( g(x) \right) = \sum_i \frac{1}{|g'(\alpha_i)|}\delta(x-\alpha_i) \] where \(\alpha_i\) is a solution of \( g(x)=0 \), namely, \( g(\alpha_i)=0 \) .

 The following are representative examples.

1. \(\bf Z=X+Y\)

\begin{eqnarray*} f_Z(z) &=& \int \delta(z-x-y)f_X(x)f_Y(y)\, dx\, dy \\ &=& \int f_X(z-y) f_Y(y)\, dy \end{eqnarray*}

2. \(\bf Z=X-Y\)

\begin{eqnarray*} f_Z(z) &=& \int \delta(z-x+y)f_X(x)f_Y(y)\, dx\, dy \\ &=& \int f_X(z+y) f_Y(y)\, dy \end{eqnarray*}

3. \(\bf Z=XY\)

\[ f_Z(z) = \int \delta(z-xy)f_X(x)f_Y(y)\, dx\, dy \\ \]
Note that
\[ \delta(z-xy) = \delta\left(y(x-\frac{z}{y})\right)= \frac{1}{|y|}\delta\left(x-\frac{z}{y}\right) \]
Thus we find
\[ f_Z(z) = \int \frac{1}{|y|}f_X(z/y) f_Y(y)\, dy \]

4. \(\bf Z=X/Y\)

\[ f_Z(z) = \int \delta\left(z-\frac{x}{y}\right)f_X(x)f_Y(y)\, dx\, dy \\ \]
Note that
\[ \delta\left(z-\frac{x}{y}\right) = \delta\left(\frac{1}{y}(x-yz)\right)= |y|\delta\left(x-yz\right) \]
We thus find
\[ f_Z(z) = \int |y| f_X(yz) f_Y(y)\, dy \]

5. \(\bf Z=X^Y\)

\[ f_Z(z) = \int \delta(z-x^y)f_X(x)f_Y(y)\, dx\, dy \\ \] \[ {\rm Let} \ \ g(x) = z-x^y. \] \[ {\rm Then, \ \ from}\ \ g(x)= 0, \ \ x = z^{1/y} . \] \[ {\rm From}\ \ g'(x) = -yx^{y-1}, \] \[ g'(z^{1/y}) = - y z^{1-1/y}.     \]
We finally find
\[ f_Z(z)= \int \frac{1}{|yz^{1-1/y}|}f_X\left(z^{1/y}\right) f_Y(y)\, dy \]

For more details, see   PDFs of X + Y, XY, X/Y , and XY