2.3 Transformation of random variables

A change of variable is a technique used in calculus and statistics to simplify integrals or PDFs by introducing a new variable. This change is often made to simplify the form of an expression, make calculations more manageable, or reveal underlying patterns.

In calculus, a change of variable involves substituting a new variable in place of the original one. This substitution is typically chosen to simplify the integral, making it easier to integrate.

In statistics, change of variable is often used in the context of probability density functions. If you have a random variable \(X\) with a known distribution and you want to find the distribution of a function of \(X\), you can use the change of variable formula for PDFs. This involves finding the derivative of the transformation function and using it to adjust the PDF of the original random variable.

2.3.1 Discrete r.v. transformation

Assume \(X\) is a known r.v., let \(Y=g(X)\) is a transformation of r.v. \(X\). Then we can calculate the PMF of \(Y\) by the following formula: \[ p_Y(a) = P(Y=a) = P(g(X)=a) = P(X=g^{-1}(a)) = p_X(g^{-1}(a)) \]

Note that sometimes \(g^{-1}(\cdot)\) may be difficult to calculate or does not exist. In this case, you can make a table to calculate PMF of \(Y\) or discuss by different cases.

Example:

Let \(X\) be a r.v. with PMF: \(p_X(x) = \frac{x}{10}, \quad x=1,2,3,4\). Find the PMF of the r.v. \(Y=3X-2\).

  • Method 1:

    \(p_Y(y) = P(Y=y) = P(3X-2=y) = P(X=\frac{y+2}{3}) = p_X(\frac{y+2}{3}) = \frac{y+2}{30}, \quad y=1,4,7,10\)

  • Method 2:

Prob. \(X\) \(Y=3X-2\)
1/10 1 1
2/10 2 4
3/10 3 7
4/10 4 10

Hence \[ p_Y(y)= \begin{cases} \frac{1}{10} &, y=1\\ \frac{1}{5} &, y=4\\ \frac{3}{10} &, y=7\\ \frac{2}{5} &, y=10\\ \end{cases} \]


Example:

Let \(X\) be a r.v. with PMF: \(p_X(x) = \frac{x^2}{10}, \quad x=-2,-1,1,2\). Find the PMF of the r.v. \(Y=|X|\).

  • Method 1:

    Since \(Y=|X|\) does not have inverse function on \([-2,2]\). Discuss by different cases:

    • Case 1: \(X\geq0\)

      \(p_Y(a) = P(Y=a) = P(|X|=a) = P(X=a) = p_X(a) = \frac{a^2}{10}, \quad a=|1|,|2|\)

    • Case 2: \(X<0\)

      \(p_Y(a) = P(Y=a) = P(|X|=a) = P(X=-a) = p_X(-a) = \frac{(-a)^2}{10}, \quad a=|-1|,|-2|\)

    Hence, \(p_Y(y) = \frac{y^2}{5}, \quad y=1,2\)

  • Method 2:

Prob. \(X\) \(Y=|X|\)
4/10 -2 2
1/10 -1 1
1/10 1 1
4/10 2 2

Hence \[ p_Y(y)= \begin{cases} \frac{1}{5} &, y=1\\ \frac{4}{5} &, y=2\\ \end{cases} \]

2.3.2 Continuous r.v. transformation

For continuous r.v., suppose a continuous r.v. has PDF \(f_X(x)\), let \(Y=g(X)\) is a transformation of r.v. \(X\). Then we have the following two methods to find PDF of \(Y\), \(f_Y(y)\):

  • Calculate from CDF:

\[ F_Y(a) = P(Y \leq a) = P(g(X)\leq a) = \begin{cases} P(X \leq g^{-1}(a)) = F_X(g^{-1}(a)) &, \mbox{if } g(\cdot) \mbox{ is increasing}\\ P(X \geq g^{-1}(a)) = 1-F_X(g^{-1}(a)) &, \mbox{if } g(\cdot) \mbox{ is decreasing} \end{cases} \] Hence, \(f_Y(y)=\frac{dF_Y(y)}{dy}\).

  • Use Jacobian:

If \(g(\cdot)\) is one-to-one (\(g^{-1}(\cdot)\) exists), then \(f_Y(y)=f_X(g^{-1}(y)) \left|\frac{dg^{-1}(y)}{dy}\right|\)

Example:

Let \(Z\) be a r.v. with PDF \(f_Z(z)=\frac{1}{\sqrt{2\pi}}e^{-\frac{z^2}{2}}, \quad z \in \mathbb{R}\), find the PDF of \(Y=X^2\)

\(F_Y(y) = P(Y \leq y) = P(Z^2 \leq y) = P(-\sqrt{y} \leq Z \leq \sqrt{y}) = F_Z(\sqrt{y})-F_Z(-\sqrt{y})\)

Therefore, \[ \begin{align} f_Y(y) &= F_Y^{'}(y) \\ &= f_Z(\sqrt{y})\frac{1}{2\sqrt{y}}-f_Z(-\sqrt{y})\frac{-1}{2\sqrt{y}} \\ &= \frac{1}{\sqrt{2\pi}}e^{-\frac{(\sqrt{y})^2}{2}}\frac{1}{2\sqrt{y}}+\frac{1}{\sqrt{2\pi}}e^{-\frac{(-\sqrt{y})^2}{2}}\frac{1}{2\sqrt{y}} \\ &= \frac{1}{\sqrt{2\pi y}}e^{-\frac{y}{2}}, \quad y>0 \end{align} \]