7. Transformations#
Often, the random variable we want to analyze does not exactly follow one of the named distributions we’ve analyzed in this class, but is a closely related transformation of one of these RVs. In this section, we will learn how to analyze these transformations of RVs.
7.1. Change of variables#
We begin with a motivating example. Given a Normal RV \(X \sim N(0, 1)\), suppose we define a new random variable \(Y = e^X\). This transformation is often used to model the evolution of stock prices. In this section, we will develop tools to analyze the distribution of \(Y\).
Change of variables for a continuous RV
Let \(X\) be a continuous RV, and define \(Y = g(X)\), where \(g\) is a differentiable and increasing function. The probability density function (PDF) of \(Y\) is given by:
If \(g\) is a decreasing function, the PDF of \(Y\) is modified to account for the absolute value of the derivative:
We now return to our motivating example.
Log-Normal PDF
This is Example 8.1.3 from [BH19].
For \(X \sim N(0, 1)\), we determine the PDF of \(Y = e^X\) step by step.
Step 1: Identify the transformation \(g\). The transformation \(g(x) = e^x\) is both differentiable and strictly increasing.
Step 2: Compute the inverse of \(g\). The inverse function \(g^{-1}(y)\) satisfies \(g(g^{-1}(y)) = y\). For \(g(x) = e^x\), the inverse is:
Step 3: Compute the derivative of \(g\). The derivative of \(g(x) = e^x\) is:
Step 4: Identify the PDF of \(X\). Since \(X \sim N(0, 1)\), its PDF is the standard normal density function:
Step 5: Derive the PDF of \(Y\). Substituting into the formula for \(f_Y(y)\), we have:
For \(y > 0\), substituting \(g^{-1}(y) = \ln y\) and \(g'(\ln y) = e^{\ln y} = y\), we find:
Explicitly:
7.2. Convolutions#
This section will provide tools for determining the distribution of the sum of two independent random variables. Let \(T = X + Y\), where \(X\) and \(Y\) are independent. The process for deriving the distribution of \(T\) depends on whether \(X\) and \(Y\) are discrete or continuous.
For Discrete RVs
If \(X\) and \(Y\) are discrete, the probability mass function of \(T\) is given by:
\[\begin{equation*} \mathbb{P}[T = t] = \sum_x \mathbb{P}[X = x \text{ and } Y = t - x] = \sum_x \mathbb{P}[X = x] \mathbb{P}[Y = t - x]. \end{equation*}\]For Continuous RVs
If \(X\) and \(Y\) are continuous, the probability density function (PDF) of \(T\) is obtained through convolution:
\[\begin{equation*} f_T(t) = \int_{-\infty}^\infty f_X(x) f_Y(t - x) \, dx. \end{equation*}\]
Swim race
Suppose a swimmer swims two laps. Let \(X\) represent the time taken to complete the first lap and \(Y\) the time for the second lap. Assume both times are independent and follow an exponential distribution with rate parameter \(\lambda\), i.e., \(X, Y \sim \text{Expo}(\lambda)\). The PDF of \(X\) and \(Y\) is:
Now, let \(T = X + Y\) represent the total time to complete both laps. We aim to find the PDF of \(T\).
Step 1: Set up the convolution. For \(t > 0\), the PDF of \(T\) is given by:
Since \(f_X(x) = 0\) for \(x < 0\) and \(f_Y(t - x) = 0\) for \(t - x < 0\) (i.e., \(x > t\)), the product \(f_X(x)f_Y(t - x)\) is nonzero only when \(0 \leq x \leq t\). Thus, the integral simplifies to:
Step 2: Substitute the PDFs of \(X\) and \(Y\). Substituting \(f_X(x) = \lambda e^{-\lambda x}\) and \(f_Y(t - x) = \lambda e^{-\lambda (t - x)}\), we get:
Combining terms, we find:
Step 3: Evaluate the integral. The integral of 1 over \([0, t]\) is simply \(t\), so:
Thus, the total time \(T = X + Y\) follows a distribution with PDF:
7.3. Gamma#
We will begin this section with a review of Poisson processes in the context of the 2014 FIFA World Cup. During the World Cup, the average number of soccer goals scored per 90-minute game was approximately 2.7. Let \(X_{90}\) represent the total number of goals scored in a game, with \(\mathbb{E}[X_{90}] = 2.7\). The sequence of goals over continuous time can be modeled as a Poisson process with a rate parameter \(\lambda\). In a Poisson process with rate \(\lambda\), the random variable \(X_t\), representing the number of goals scored in an interval of \(t\) minutes, follows a Poisson distribution:
Given that the expected number of goals in a 90-minute game is \(\mathbb{E}[X_{90}] = 2.7\), and using the property \(\mathbb{E}[X_t] = \lambda t\), we have:
Thus, the rate of goals is \(\lambda = 0.03\) goals per minute.
Here are a few example questions we might ask about this Poisson process:
What is the probability of exactly 4 goals before halftime? The interval from the start of the game to halftime (45 minutes) is modeled by \(X_{45} \sim \text{Pois}(\lambda t = 0.03 \cdot 45 = 1.35)\). The probability of exactly 4 goals is:
What is the probability the first goal is scored within the first 10 minutes? Let \(T_1\) represent the time until the first goal. In a Poisson process, \(T_1\) follows an exponential distribution with rate \(\lambda = 0.03\), i.e., \(T_1 \sim \text{Expo}(\lambda)\). The cumulative distribution function (CDF) of \(T_1\) is:
Substituting \(t = 10\) and \(\lambda = 0.03\):
Thus, there is approximately a 26% chance the first goal is scored within the first 10 minutes.
Next, let \(T_5\) represent the time until the 5th goal is scored in a soccer game. In the remainder of this section, our goal will be to determine the PDF of \(T_5\). Doing so will rely on the Gamma function, defined as:
Key properties of the Gamma function include:
\(\Gamma(a + 1) = a \Gamma(a)\),
\(\Gamma(n) = (n-1)!\) for positive integers \(n\).
Gamma distribution
A random variable \(Y\) is said to have a Gamma distribution with shape parameter \(a > 0\) and rate parameter \(\lambda > 0\) if its probability density function (PDF) is:
This is written as \(Y \sim \text{Gamma}(a, \lambda)\).
Let’s return back to the World Cup example, where we aim to find the PDF of \(T_5\), the time until the 5th goal is scored in a soccer game. Let \(X_t\) denote the number of goals scored within the first \(t\) minutes of the game. The time \(T_5 \leq t\) if and only if at least 5 goals are scored by time \(t\), i.e., \(X_t \geq 5\). The cumulative distribution function (CDF) of \(T_5\) is:
where \(X_t \sim \text{Pois}(\lambda t)\) and \(\mathbb{P}[X_t = k] = \frac{e^{-\lambda t}(\lambda t)^k}{k!}\).
To find the PDF of \(T_5\), we differentiate the CDF:
Differentiating term by term:
Thus, \(T_5 \sim \text{Gamma}(5, \lambda)\), meaning the time until the 5th goal follows a Gamma distribution with shape parameter \(5\) and rate parameter \(\lambda\). For example, to find the probability of scoring 5 goals in the first 45 minutes, we compute:
Substituting \(\lambda = 0.03\):
Evaluating this integral gives approximately \(0.01\), meaning there is about a 1% chance of scoring 5 goals within 45 minutes.
Generalizing beyond this example, the Gamma distribution has a close relationship with the Poisson process, summarized as follows.
Connection between the Gamma and Exponential distributions
If \(Y_1, Y_2, \dots, Y_j \sim \text{Expo}(\lambda)\) are independent, then their sum \(Y_1 + Y_2 + \cdots + Y_j\) follows a Gamma distribution:
To summarize, for a Poisson process with rate \(\lambda\):
The number of arrivals in an interval of length \(t\) follows the \(\text{Pois}(\lambda t)\) distribution,
The time between consecutive arrivals follows the \(\text{Expo}(\lambda)\) distribution,
The time of the \(j^{\text{th}}\) arrival follows the \(\text{Gamma}(j, \lambda)\) distribution.