Skip to content

Functions of a Random Variable

Let $X$ be a random variable with pdf $f_X(x)$, and let $X$ be defined in the domain $x_0 \leq X \leq x_1$. Let $Y=g(X)$. Naturally, $Y$ is also a random variable. What is the pdf associated  with $Y$, $f_Y(y)$? We will consider two cases: First, we will consider $g(.)$ as one-to-one. Next, we will consider $g(.)$ as two-to-one. Other many-to-one cases can be deduced by generalization from two-to-one case.

$g(.)$ is one-to-one

This means $g(.)$ is either increasing or decreasing, with $y_0=g(x_0)$ and $y_1=g(x_1)$, and $y_0 \le Y \le y_1$.Then there is a three step algorithm:

  1. Express $X$ in terms of $Y$ by inverting $g(.)$, ie, $X=g^{-1}(Y)$
  2. Using the cumulative distribution function for r.v. $X$
    \begin{eqnarray} F_X(x)=P(X \leqslant x)=\int_{x_0}^{x} f(u)du \end{eqnarray}
    compute the cumulative distribution function for r.v. $Y$
    \begin{eqnarray} F_Y(y)=P(Y \leqslant y)=\int_{g^{-1}(y_0)}^{g^{-1}(y)} f(u)du \end{eqnarray}
  3. Use leibniz’ rule fo find the pdf of $Y$ from the cdf of $Y$:
    f_Y(y) =\frac{\partial}{\partial y} \int_{g^{-1}(y_0)}^{g^{-1}(y)} f(u)du = f(g^{-1}(y))\left|\frac{\partial g^{-1}(y) }{\partial y} \right|
    Note that if $g(x)$ is decreasing, the limits of the integration must be flipped. Hence the absolute value.

Problem: Let $f_X(x)=3x^2$ for $0 \leqslant x \leqslant 1$. What is the pdf for $Y=X^2$?
Solution: Note that $Y=X^2$ is 1-1 in the interval $[0,1]$. Hence $f_Y(y)=3(\sqrt{y})^2$

$g(.)$ is two-to-one

In this case, the inversion of $g(.)$ is not straightforward. The solution method is best understood by an example.
Problem: Let $f_X(x)=\frac{x^2}{3}$ for $-1\leq X \leq 2$. What is the pdf for $Y=X^2$?
Solution: Note that $Y \in [0,4]$. $Y$ is 2-1 for $Y \in [0,1]$ and $Y$ is 1-1 for $Y \in [1,4]$.
cdf for $Y \leq 1$ is
F_Y(y) = \int_{-\sqrt(y)}^{\sqrt(y)} \frac{x^2}{3}dx
The pdf in the same range is, by leibniz’ rule
f_Y(y)= \frac{d}{dy} F_Y(y) = \frac{d}{dy} \int_{-\sqrt{y}}^{\sqrt{y}} \frac{x^2}{3}dx =
\frac{y}{3} \frac{1}{2 \sqrt{y}}-\left[ \frac{y}{3} \left(-\frac{1}{2 \sqrt{y}} \right) \right] = \frac{\sqrt{y}}{3}
cdf for $1 \leq Y \leq 4$ is
F_Y(y) = K+\int_{1}^{\sqrt(y)} \frac{x^2}{3}dx
where K is a constant. By leibniz rule
f_Y(y)= \frac{\sqrt{y}}{6}