UW STAT 512: Introduction to Statistical Inference (2022 Autumn)
Lecture 2: Transforming continuous random variables

Yen-Chi Chen (University of Washington)

Reference: Casella and Berger Chapter 2.1.

In the previous lecture, we examined several distributions with useful properties. In data analysis, we often apply transformations to random variables. If the distribution of a random variable prior to transformation is known, how can we determine the distribution of the transformed variable?

One function of one random variable

Let \(X\) be a continuous random variable with a known probability density function (PDF) \(p_X(x)\). Consider a measurable function \(f\) and define a new random variable \(Y = f(X)\). We aim to derive the probability distribution of \(Y\).

When \(f\) is continuously differentiable, the following theorem is applicable.

Theorem 1. Assume that the support of \(X\) is \([a,b]\) and \(f\) is strictly increasing with \(f'(x)>0\) for all \(x\in(a,b)\). Then the PDF of \(Y\) is given by \[p_Y(y) = \begin{cases} \frac{p_X(f^{-1}(y))}{f'(f^{-1}(y))},\quad &f(a)\leq y\leq f(b)\\ 0,\quad&\mbox{otherwise}. \end{cases}\]

To start with, we consider the cumulative distribution function (CDF) of \(Y\): \[\begin{align*} P(Y\leq y) & = P(f(X)\leq y)\\ & = P(X\leq f^{-1}(y)). \end{align*}\] The PDF is obtained by differentiating the CDF with respect to \(y\): \[\begin{align*} p_Y(y) & = \frac{d}{dy} P(Y\leq y)\\ & = \frac{d}{dy}P(X\leq f^{-1}(y))\\ & = p_X(f^{-1}(y)) \frac{d}{dy} f^{-1}(y)\\ & = \frac{p_X(f^{-1}(y))}{f'(f^{-1}(y))}, \end{align*}\] which completes the proof.


Example. Suppose \(f(x) = x^2\) and \(X\sim {\sf Uniform}[0,1]\). And we are interested in the PDF of \(Y = f(X) = X^2\). Because \(f'(x) = 2x\) and \(X\geq 0\) so \(f^{-1}(y) = \sqrt{y}\), we have \[\begin{align*} p_Y(y) = \frac{1}{2\sqrt{y}}I(0\leq y\leq 1). \end{align*}\]

Example. Assume \(X\sim {\sf Uniform}[0,1]\) and consider \(f(x) = -2\log X\) and let \(Y = -2\log X\). In this case, \(f'(x) = -\frac{2}{X}\) and \(f^{-1}(y) = e^{-\frac{1}{2}y}\). However, \(f'(x)\) is strictly negative, so TheoremĀ 1 does not apply directly. A straightforward modification establishes that an analogous formula holds provided we replace \(f'(f^{-1}(y))\) by \(|f'(f^{-1}(y))|\).

Then the PDF of \(Y\) will be \[\begin{align*} p_Y(y) = \frac{1}{2}e^{-\frac{1}{2}y}I(0\leq y) \end{align*}\] which is the Exponential distribution with parameter \(\lambda = \frac{1}{2}\).

Example. Suppose that \(Y\) is a continuous random variable with CDF \(F_Y\) and \(X\) is a uniform random variable within \([0,1]\). Then one can show that \(Z = F_Y^{-1}(X)\) has the CDF \(F_Z(z) = F_Y(z)\).

Example. Consider \(X\sim N(0,1)\) and \(Y = X^2\). What is the distribution of \(Y\)? Note that the transformation \(f(x) = x^2\) is not strictly monotone over \(\mathbb{R}\). In such cases, a general and robust strategy is to first derive the CDF: \[\begin{align*} F_Y(y) &= P(Y\leq y)\\ & = P(X^2\leq y) \\ & = P(-\sqrt{y}\leq X\leq \sqrt{y})\\ & = F_X(\sqrt{y})-F_X(-\sqrt{y}). \end{align*}\] Thus, \[\begin{align*} p_Y(y) &= \frac{d}{dy}[F_X(\sqrt{y})-F_X(-\sqrt{y})]\\ & = \frac{1}{2\sqrt{y}}(p_X(\sqrt{y}) + p_X(-\sqrt{y})). \end{align*}\] In this case, because \(X\sim N(0,1)\), it is symmetric so we further have \[p_Y(y) = \frac{1}{\sqrt{y}}p_X(\sqrt{y}).\] Putting \(p_X(x) = \frac{1}{\sqrt{2\pi}}e^{-x^2/2}\) into the above equation, we obtain \[p_Y(y) = \frac{1}{\sqrt{y}}\frac{1}{\sqrt{2\pi}}e^{-y/2} = \frac{1}{\sqrt{2\pi}}y^{-\frac{1}{2}}e^{-\frac{1}{2}y},\] which is Gamma \((\frac{1}{2},\frac{1}{2})\). Note: The Gamma \((\frac{1}{2},\frac{1}{2})\) distribution corresponds exactly to the \(\chi^2_1\) distribution, which is the chi-squared distribution with \(1\) degree of freedom.

One function of two or more random variables

In practice, one frequently encounters functions of multiple random variables. Let \(X\) and \(Y\) be two random variables with a known joint PDF \(p(x,y)\). We seek the distribution of a new random variable \(U = f(X,Y)\) for a given measurable function \(f\). A general strategy is to first derive the CDF of \(U\) and subsequently differentiate it to obtain the PDF. Here we will illustrate the idea via a few examples.

Example. Consider \((X,Y)\) to be a uniform distribution over \([0,1]\times [0,1]\). Note that in this case, they are from two independent uniform distributions.

Example (minimum of many uniforms). Now consider \(X_1,\cdots, X_n\) that are IID from a uniform distribution over \([0,1]\). Define \(U = n \min\{X_1,\cdots, X_n\}\). What is the asymptotic distribution of \(U\) as \(n \to \infty\)? Using the technique that we have discussed, \[\{\min\{X_1,\cdots,X_n\}> u\} \equiv \{X_1> u,\cdots, X_n> u\},\] so \[1-F_U(u) = P\left(\min\{X_1,\cdots,X_n\}> \frac{u}{n}\right) = \prod_{i=1}^n P\left(X_i>\frac{u}{n}\right) = \left(1-\frac{u}{n}\right)^n \rightarrow e^{-u}.\] As a result, \(F_U(u) \rightarrow 1-e^{-u}\) and \(p_U(u)\rightarrow e^{-u}\), so as \(n \to \infty\), \(U\) converges in distribution to a standard exponential random variable.

Example (exponential distributions). Consider \(X,Y\) are IID from exponential distribution with parameter \(1\).

Useful properties of the normal distribution (left as an exercise).