Post · 8 min read· pp. 225–230

4.1.3 Functions of Continuous Random Variables


Video Available Video Available

If XX is a continuous random variable and Y=g(X)Y=g(X) is a function of XX, then YY itself is a random variable. Thus, we should be able to find the CDF and PDF of YY. It is usually more straightforward to start from the CDF and then to find the PDF by taking the derivative of the CDF. Note that before differentiating the CDF, we should check that the CDF is continuous. As we will see later, the function of a continuous random variable might be a non-continuous random variable. Let's look at an example.


Example

Let XX be a Uniform(0,1)Uniform(0,1) random variable, and let Y=eXY=e^X.

  1. Find the CDF of YY.
  2. Find the PDF of YY.
  3. Find EYEY.
  • Solution
    • First, note that we already know the CDF and PDF of XX. In particular, \begin{equation} %\label{eq:CDF-uniform} \nonumber F_X(x) = \left{ \begin{array}{l l} 0 & \quad \textrm{for } x < 0 \ x & \quad \textrm{for }0 \leq x \leq 1\ 1 & \quad \textrm{for } x > 1 \end{array} \right. \end{equation} It is a good idea to think about the range of YY before finding the distribution. Since exe^x is an increasing function of xx and RX=[0,1]R_X=[0,1], we conclude that RY=[1,e]R_Y=[1,e]. So we immediately know that
      FY(y)=P(Y≤y)=0,for y<1,F_Y(y)=P(Y \leq y)=0, \hspace{20pt} \textrm{for } y < 1,
      FY(y)=P(Y≤y)=1,for y≥e.F_Y(y)=P(Y \leq y)=1, \hspace{20pt} \textrm{for } y \geq e.
      1. To find FY(y)F_Y(y) for y∈[1,e]y \in[1,e], we can write

        FY(y)F_Y(y)=P(Y≤y)=P(Y \leq y)
        =P(eX≤y)=P(e^X \leq y)
        =P(X≤ln⁡y)=P(X \leq \ln y)$\textrm{since exe^x is an increasing function}$
        =FX(ln⁡y)=ln⁡y=F_X(\ln y)=\ln y \hspace{30pt}$\textrm{since $0 \leq \ln y \leq 1.}

        To summarize \begin{equation} \nonumber F_Y(y) = \left{ \begin{array}{l l} 0 & \quad \textrm{for } y < 1 \ \ln y & \quad \textrm{for }1 \leq y < e\ 1 & \quad \textrm{for } y \geq e \end{array} \right. \end{equation}

      2. The above CDF is a continuous function, so we can obtain the PDF of YY by taking its derivative. We have \begin{equation} \nonumber f_Y(y)=F'_Y(y) = \left{ \begin{array}{l l} \frac{1}{y} & \quad \textrm{for }1 \leq y \leq e\ 0 & \quad \textrm{otherwise} \end{array} \right. \end{equation} Note that the CDF is not technically differentiable at points $1$ and ee, but as we mentioned earlier we do not worry about this since this is a continuous random variable and changing the PDF at a finite number of points does not change probabilities.

      3. To find the EYEY, we can directly apply LOTUS,

        E[Y]=E[eX]E[Y]=E[e^X]=∫−∞∞exfX(x)dx=\int_{-\infty}^{\infty} e^x f_X(x) dx
        =∫01exdx=\int_{0}^{1} e^x dx
        =e−1.=e-1.

        For this problem, we could also find EYEY using the PDF of YY,

        E[Y]E[Y]=∫−∞∞yfY(y)dy=\int_{-\infty}^{\infty} y f_Y(y) dy
        =∫1ey1ydy=\int_{1}^{e} y \frac{1}{y} dy
        =e−1.=e-1.

        Note that since we have already found the PDF of YY it did not matter which method we used to find E[Y]E[Y]. However, if the problem only asked for E[Y]E[Y] without asking for the PDF of YY, then using LOTUS would be much easier.


Example

Let X∼Uniform(−1,1)X \sim Uniform(-1,1) and Y=X2Y=X^2. Find the CDF and PDF of YY.

  • Solution
    • First, we note that RY=[0,1]R_Y=[0,1]. As usual, we start with the CDF. For y∈[0,1]y \in [0,1], we have

      FY(y)F_Y(y)=P(Y≤y)=P(Y \leq y)
      =P(X2≤y)=P(X^2 \leq y)
      =P(−y≤X≤y)=P(-\sqrt{y} \leq X \leq \sqrt{y})
      =y−(−y)1−(−1)since X∼Uniform(−1,1)= \frac{\sqrt{y}-(-\sqrt{y})}{1-(-1)} \hspace{80pt} \textrm{since } X \sim Uniform(-1,1)
      =y.= \sqrt{y}.

      Thus, the CDF of YY is given by \begin{equation} \nonumber F_Y(y)= \left{ \begin{array}{l l} 0 & \quad \textrm{for } y < 0\ \sqrt{y} & \quad \textrm{for }0 \leq y \leq 1\ 1 & \textrm{for } y > 1 \end{array} \right. \end{equation} Note that the CDF is a continuous function of YY, so YY is a continuous random variable. Thus, we can find the PDF of YY by differentiating FY(y)F_Y(y), \begin{equation} \nonumber f_Y(y)=F'_Y(y) = \left{ \begin{array}{l l} \frac{1}{2\sqrt{y}} & \quad \textrm{for }0 \leq y \leq 1\ 0 & \quad \textrm{otherwise} \end{array} \right. \end{equation}


The Method of Transformations

So far, we have discussed how we can find the distribution of a function of a continuous random variable starting from finding the CDF. If we are interested in finding the PDF of Y=g(X)Y=g(X), and the function gg satisfies some properties, it might be easier to use a method called the method of transformations. Let's start with the case where gg is a function satisfying the following properties:

  • g(x)g(x) is differentiable;
  • g(x)g(x) is a strictly increasing function, that is, if x1<x2x_1 < x_2, then g(x1)<g(x2)g(x_1) < g(x_2).

Now, let XX be a continuous random variable and Y=g(X)Y=g(X). We will show that you can directly find the PDF of YY using the following formula. \begin{equation} \nonumber f_Y(y) = \left{ \begin{array}{l l} \frac{f_X(x_1)}{g'(x_1)}=f_X(x_1). \frac{dx_1}{dy} & \quad \textrm{where } g(x_1)=y\ 0 & \quad \textrm{if }g(x)=y \textrm{ does not have a solution} \end{array} \right. \end{equation} Note that since gg is strictly increasing, its inverse function g−1g^{-1} is well defined. That is, for each y∈RYy \in R_Y, there exists a unique x1x_1 such that g(x1)=yg(x_1)=y. We can write x1=g−1(y)x_1=g^{-1}(y).

FY(y)F_Y(y)=P(Y≤y)=P(Y \leq y)
=P(g(X)≤y)=P(g(X) \leq y)
$=P(X < g^{-1}(y)) \hspace{30pt} \textrm{ since gg is strictly increasing}$
=FX(g−1(y)).=F_X(g^{-1}(y)).

To find the PDF of YY, we differentiate

fY(y)f_Y(y)=ddyFX(x1)=\frac{d}{dy} F_X(x_1) \hspace{60pt} where g(x1)=y\textrm{ where } g(x_1)=y
=dx1dy⋅FX′(x1)=\frac{dx_1}{dy} \cdot F'_X(x_1)
=fX(x1)dx1dy=f_X(x_1) \frac{dx_1}{dy}
=fX(x1)g′(x1)=\frac{f_X(x_1)}{g'(x_1)}since dxdy=1dydx.\textrm{since } \frac{dx}{dy}=\frac{1}{\frac{dy}{dx}}.

We can repeat the same argument for the case where gg is strictly decreasing. In that case, g′(x1)g'(x_1) will be negative, so we need to use ∣g′(x1)∣|g'(x_1)|. Thus, we can state the following theorem for a strictly monotonic function. (A function g:R→Rg: \mathbb{R}\rightarrow \mathbb{R} is called strictly monotonic if it is strictly increasing or strictly decreasing.)

Theorem Suppose that XX is a continuous random variable and g:R→Rg: \mathbb{R}\rightarrow \mathbb{R} is a strictly monotonic differentiable function. Let Y=g(X)Y=g(X). Then the PDF of YY is given by \begin{equation} \nonumber f_Y(y)= \left{ \begin{array}{l l} \frac{f_X(x_1)}{|g'(x_1)|}=f_X(x_1). |\frac{dx_1}{dy}| & \quad \textrm{where } g(x_1)=y\ 0 & \quad \textrm{if }g(x)=y \textrm{ does not have a solution} \end{array} \right. \hspace{10pt} (4.5) \end{equation}

To see how to use the formula, let's look at an example.


Example

Let XX be a continuous random variable with PDF \begin{equation} \nonumber f_X(x) = \left{ \begin{array}{l l} 4x^3& \quad 0 < x \leq 1\ 0 & \quad \text{otherwise} \end{array} \right. \end{equation} and let Y=1XY=\frac{1}{X}. Find fY(y)f_Y(y).

  • Solution
    • First note that RY=[1,∞)R_Y=[1,\infty). Also, note that g(x)g(x) is a strictly decreasing and differentiable function on (0,1](0,1], so we may use Equation 4.5. We have g′(x)=−1x2g'(x)=-\frac{1}{x^2}. For any y∈[1,∞)y \in [1,\infty), x1=g−1(y)=1yx_1=g^{-1}(y)=\frac{1}{y}. So, for y∈[1,∞)y \in [1,\infty)

      fY(y)f_Y(y)=fX(x1)∣g′(x1)∣=\frac{f_X(x_1)}{|g'(x_1)|}
      =4x13∣−1x12∣= \frac{4 x_1^3}{|-\frac{1}{x_1^2}|}
      =4x15= 4x_1^5
      =4y5.=\frac{4}{y^5}.

      Thus, we conclude \begin{equation} \nonumber f_Y(y) = \left{ \begin{array}{l l} \frac{4}{y^5}& \quad y \geq 1\ 0 & \quad \text{otherwise} \end{array} \right. \end{equation}


Theorem 4.1 can be extended to a more general case. In particular, if gg is not monotonic, we can usually divide it into a finite number of monotonic differentiable functions. Figure 4.3 shows a function gg that has been divided into monotonic parts. We may state a more general form of Theorem 4.1.

Figure

Fig.4.3 - Partitioning a function to monotone parts.

Theorem Consider a continuous random variable XX with domain RXR_X, and let Y=g(X)Y=g(X). Suppose that we can partition RXR_X into a finite number of intervals such that g(x)g(x) is strictly monotone and differentiable on each partition. Then the PDF of YY is given by

fY(y)=∑i=1nfX(xi)∣g′(xi)∣=∑i=1nfX(xi).∣dxidy∣(4.6)\hspace{40pt} f_Y(y)= \sum_{i=1}^{n} \frac{f_X(x_i)}{|g'(x_i)|}= \sum_{i=1}^{n} f_X(x_i). \left|\frac{dx_i}{dy}\right| \hspace{40pt} (4.6)
where x1,x2,...,xnx_1, x_2,...,x_n are real solutions to g(x)=yg(x)=y.

Let us look at an example to see how we can use Theorem 4.2.


Example

Let XX be a continuous random variable with PDF

fX(x)=12πe−x22,for all x∈Rf_X(x) = \frac{1}{\sqrt{2 \pi}} e^{-\frac{x^2}{2}}, \hspace{20pt} \textrm{for all } x \in \mathbb{R}
and let Y=X2Y=X^2. Find fY(y)f_Y(y).

  • Solution
    • We note that the function g(x)=x2g(x)=x^2 is strictly decreasing on the interval (−∞,0)(-\infty,0), strictly increasing on the interval (0,∞)(0, \infty), and differentiable on both intervals, g′(x)=2xg'(x)=2x. Thus, we can use Equation 4.6. First, note that RY=(0,∞)R_Y=(0, \infty). Next, for any y∈(0,∞)y \in (0,\infty) we have two solutions for y=g(x)y=g(x), in particular,

      x1=y,x2=−yx_1=\sqrt{y}, \hspace{10pt} x_2=-\sqrt{y}
      Note that although $0 \in R_X$ it has not been included in our partition of RXR_X. This is not a problem, since P(X=0)=0P(X=0)=0. Indeed, in the statement of Theorem 4.2, we could replace RXR_X by RX−AR_X-A, where AA is any set for which P(X∈A)=0P(X \in A)=0. In particular, this is convenient when we exclude the endpoints of the intervals. Thus, we have

      fY(y)f_Y(y)=fX(x1)∣g′(x1)∣+fX(x2)∣g′(x2)∣= \frac{f_X(x_1)}{|g'(x_1)|}+\frac{f_X(x_2)}{|g'(x_2)|}
      =fX(y)∣2y∣+fX(−y)∣−2y∣= \frac{f_X(\sqrt{y})}{|2\sqrt{y}|}+\frac{f_X(-\sqrt{y})}{|-2\sqrt{y}|}
      =122πye−y2+122πye−y2= \frac{1}{2\sqrt{2 \pi y}} e^{-\frac{y}{2}}+\frac{1}{2\sqrt{2 \pi y}} e^{-\frac{y}{2}}
      =12πye−y2, for y∈(0,∞).= \frac{1}{\sqrt{2 \pi y}} e^{-\frac{y}{2}}, \textrm{ for } y \in (0,\infty).