# Change of Variables

Previously we studied transformations of a single random variable and how to compute the distribution of a transformed random variable. Here we are primarily considered with situations when the function of the random variables, sometimes called a change of variables, has a (joint) cumulative distribution or (joint) density function that can be computed simply in terms of the corresponding cumulative distribution function or joint density function of the random variables that it depends on.

## The Setup

We let $X_1,\ldots,X_n$ denote a sequence of random variables and let

[$] \mathbf{Y} = [Y_1,\ldots,Y_m] = T(X_1,\ldots,X_n) = T(\mathbf{X}) [$]

denote the change of variables.

## Monotone One-to-One Transformations

A transformation $T$ is one-to-one when $T(\mathbf{x}) = T( \mathbf{y})$ implies that $\mathbf{x} = \mathbf{y}$: $T$ maps two distinct points to two distinct points. If $T$ is one-to-one then $T$ has a left-inverse $T^{-1}$:

[$] T^{-1}(T(\mathbf{x})) = \mathbf{x}. [$]

### Strictly Increasing

If $T$ is strictly increasing,

[$] x_i \leq y_i \,\text{for all}\,\,i \Leftrightarrow \mathbf{x} \leq \mathbf{y} \implies T(\mathbf{x}) \leq T(\mathbf{y}) [$]

, then

[] \begin{align} \operatorname{P}[T(\mathbf{X}) \leq y ] = \operatorname{P}[X \leq T^{-1}(y)] = f_{\textbf{X}}[T^{-1}(y)] \end{align} []

and we obtain the simple relation

[$] $$\label{transform-rel-up} \mathbf{X} \mapsto T(\mathbf{X})=\textbf{Y} \implies F_{\textbf{Y}} = f_{\textbf{X}} \circ T^{-1}.$$ [$]

### Example

Suppose that $\mathbf{X} = [X_1,X_2]$ and let

[$] \mathbf{Y} = [Y_1,Y_2]=T(x_1,x_2) = [e^{2x_1 + x_2},e^{x_1 + 2x_2}] = \exp[A(\mathbf{X})] [$]

with $A$ the linear transformation

[$] A(x_1,X_2) = [x_1 + x_2, x_1 + 2x_2]. [$]

The inverse of the transformation, $T^{-1}$, equals

[$] A^{-1} \circ \log \, , \quad A^{-1}(\mathbf{y}) = [(y_1 - y_2)/3,(2y_2 - y_1)/3]. [$]

By \ref{transform-rel-up}, the cumulative distribution function of $\textbf{Y}$ equals $F_{\textbf{Y}} = f_{\textbf{X}} \circ A^{-1} \circ \log.$

### Strictly Decreasing

If the transformation $T$ is strictly decreasing and the distribution function of $X$, $F_{\textbf{X}}$, is continuous then

[$] \operatorname{P}[T(\mathbf{X})\leq y ] = \operatorname{P}[\mathbf{X} \geq T^{-1}(y)] = 1 - f_{\textbf{X}}[T^{-1}(y)] [$]

and the distribution funtion of $\textbf{Y}$ equals $1 - f_{\textbf{X}} \circ T^{-1}$.

## Smooth One-to-One Transformations

We assume the following:

1. $X_1,\ldots,X_n$ have a joint density.
2. The transformation $T$ is one-to-one.
3. The transformation $T$ is differentiable almost surely: the set of points where $T$ is not differentiable has probability 0.

To illustrate condition 3, suppose that $X_1$ and $X_2$ are uniformly distributed on [0,1] and $T(X_1,X_2) = [X_2,X_1]$. Then $T$ is defined on the square region [0,1] x [0,1] and the points where it's differentiable has probability 1:

[$] \operatorname{P}(\{0 \lt X_1 \lt 1\} \cap \{0 \lt X_2 \lt 1\}) = 1. [$]

If the conditions above are met, we can actually compute the joint density of $\textbf{Y}$:

[$] f_{\textbf{Y}}(\mathbf{y}) = \frac{ f_{\textbf{X}}(T^{-1}(\mathbf{y}))}{|\operatorname{det}[J_T(T^{-1}(\mathbf{y}))]|}\,, \mathbf{y} = [y_1,\ldots,y_n]. [$]

Here $J_T$ denotes the Jacobian matrix of $T$ and $\textrm{det}[J_T]$ its determinant. We can express the density of $Y$ more succinctly (recall that $\circ$ denotes function composition):

[$] $$\label{transform-density} f_{\textbf{Y}} = \left(f_{\textbf{X}} \cdot |\operatorname{det}[J_T]|^{-1}\right) \circ T^{-1}$$ [$]

### Example

Let $\textbf{U}$ denote a uniform on the square [0,1]x[0,1] and let

[$] \textbf{Y} = [\exp(U_1 + U_2),\exp(U_1 - U_2)] = \exp[A(\mathbf{U})] [$]

with $A$ the linear transformation $A(x_1,x_2) = [x_1 + x+2,x_1 - x_2]$. The inverse of the transformation, $T^{-1}$, equals

[$] A^{-1} \circ \log\, , \quad A^{-1}(\mathbf{y}) =1/2 [y_1 + y_2,y_1-y_2]. [$]

We compute the determinant of the Jacobian of the transformation

[] \begin{align} J_T &= \left(\begin{matrix} \frac{\partial}{\partial x_1} e^{x_1 + x_2} & \frac{\partial}{\partial x_2} e^{x_1 + x_2} \\ \frac{\partial}{\partial x_1}e^{x_1 - x_2} & \frac{\partial}{\partial x_2} e^{x_1 - x_2}\\ \end{matrix}\right) \\ & = \left(\begin{matrix} e^{x_1 + x_2} & e^{x_1 + x_2} \\ e^{x_1 - x_2} & - e^{x_1 - x_2} \\ \end{matrix}\right) \end{align} []

and its corresponding determinant equals $-2e^{2x_1}$. Recalling \ref{transform-density}, the density function of $\textbf{Y}$ equals

[$] \begin{cases}\frac{1}{2}\exp[-\log(y_1) -\log(y_2)] = \frac{1}{2y_1y_2} \ & \mathbf{y} \in D \\ 0 & \text{otherwise} \end{cases} [$]

with $D$ equal to the region $T([0,1] \times [0,1])$ (the image of the unit square under the transformation). Expressing $x_1$ and $x_2$ in terms of $y_1$ and $y_2$, the region $D$ can be described as follows:

[] \begin{align*} 0 \lt \frac{\log(y_1) + \log(y_2)}{2} \lt 1 &\Leftrightarrow 1 \lt y_1y_2 \lt e^2 \\ 0 \lt \frac{\log(y_1) - \log(y_2)}{2} \lt 1 &\Leftrightarrow 1 \lt \frac{y_1}{y_2} \lt e^2 \\ \end{align*} []

## Other Methods

We present other ways of calculating the cumulative distribution function of transformed random variables or the probability of events associated with said variables.

### Direct Evaluation

The most direct way to compute probabilities such as $\operatorname{P}[\textbf{Y} \in A]$ is to express them in terms of events associated with the initial random variable $\textbf{X}$:

[$] \operatorname{P}[\textbf{Y} \in A ] = \operatorname{P}[\textbf{X} \in B]\,, \quad B = \{x \,:\, T(x) \in A\}. [$]

#### Example 1

If $Y = X_1 + X_2= T(\mathbf{X})$, then $\operatorname{P}[Y_1 \leq y] = \operatorname{P}[X \in B ]$ with $B$ the set of points

[$] B = \{[x_1,x_2] \, : \, x_1 + x_2 \leq y \}. [$]

#### Example 2

If $\textbf{Y} = [X_1 + X_2,X_1 - X_2] = T(\mathbf{X})$, then $\operatorname{P}[Y_1 \leq y_1,Y_2 \leq y_2] = \operatorname{P}[\textbf{X} \in B ]$ with $B$ the set of points

[$] B = \{[x_1,x_2] \, : \, x_1 + x_2 \leq y_1\,, x_1 - x_2 \leq y_2\}. [$]

### Conditioning

We limit ourselves to the case when we only have two variables: $\mathbf{X} = [X_1,X_2]$. The conditioning method to computing probabilities associated with $\textbf{Y}$ is to condition on $X_1$ or $X_2$:

[$] $$\label{cond-method-eqn} \operatorname{P}(\textbf{Y} \in A) = \operatorname{E}[\operatorname{P}(A \mid X_i)]\,, i=1,2.$$ [$]

$\mathbf{X}$ typically has a joint density function and then \ref{cond-method-eqn} also equals

[$] \int_{-\infty}^{\infty}\operatorname{P}(\textbf{Y} \in A \mid X_i = x) \, f_{X_i}(x) \, dx \,, i=1,2 [$]

with $f_{X_i}$ the marginal density of $X_i$.

#### Example 1

Suppose $X_1$ and $X_2$ are mutually independent. Suppose further that $X_1$ has density function

[$] f_{X_1}(x) = \begin{cases} \frac{\alpha}{x^{\alpha + 1}} & x \geq 1 \\ 0 & x \lt 1 \end{cases} [$]

and $X_2$ is uniformly distributed on [0,1]. We consider the random variable $Y = X_1 X_2$. Conditioning on $X_2$, we have

[$] f_Y(y\mid X_2 = \theta) = \begin{cases} \frac{\alpha \theta^{\alpha}}{x^{\alpha + 1}} & x \geq \theta \\ 0 & x \lt \theta \end{cases} [$]

and thus the density function of $Y$ equals

[$] \alpha x^{-(\alpha + 1)} \, \int_0^{\min(x,1)} \theta^{\alpha} \, d\theta = \begin{cases} \frac{\alpha}{\alpha +1 } & x \lt 1 \\ \frac{\alpha}{\alpha + 1} \cdot x^{-(\alpha + 1)} & x \geq 1 \end{cases} [$]

#### Example 2

Suppose $X$ is uniform on the square [0,1]x[0,1] and let

[$] Y = X_1/X_2. [$]

Conditional on $X_2$, $Y$ is uniformly distributed on the interval $X_2$. Furthermore, $X_2$ is uniformly distributed on [0,1]. By \ref{cond-method-eqn}, we have

[] \begin{align*} \operatorname{P}(Y \leq y) &= \int_0^1 x\,\min(y,1/x)\, dx \\ &= \int_0^{1/y} xy \,dx + \int_{1/y}^1 \, dx \\ &= \begin{cases} 1/2y & y \lt 1 \\ 1 - 1/2y & y \geq 1. \end{cases} \end{align*} []

## Sums of Independent Random Variables

The probability distribution of the sum of two or more independent random variables is the convolution of their individual distributions. The term is motivated by the fact that the probability mass function or probability density function of a sum of random variables is the convolution of their corresponding probability mass functions or probability density functions respectively.

### Convolutions

#### Continuous

The convolution of $f$ and $g$ is written $f*g$, using an asterisk or star. It is defined as the integral of the product of the two functions after one is reversed and shifted. As such, it is a particular kind of integral transform:

[] \begin{align} (f * g )(t) &\stackrel{\mathrm{def}}{=}\ \int_{-\infty}^\infty f(\tau)\, g(t - \tau)\, d\tau \\ &= \int_{-\infty}^\infty f(t-\tau)\, g(\tau)\, d\tau \\ &= (g * f)(t). \end{align} []

While the symbol $t$ is used above, it need not represent the time domain. But in that context, the convolution formula can be described as a weighted average of the function $f(\tau)$ at the moment $t$ where the weighting is given by $g(-\tau)$ simply shifted by amount $t$. As $t$ changes, the weighting function emphasizes different parts of the input function.

For functions $f$, $g$ supported on only $[0, \infty)$ (i.e., zero for negative arguments), the integration limits can be truncated, resulting in

[$] (f * g )(t) = \int_{0}^{t} f(\tau)\, g(t - \tau)\, d\tau \ \ \ \mathrm{for} \ \ f, g : [0, \infty) \to \mathbb{R} [$]

#### Discrete

For functions $f$, $g$ defined on the set $Z$ of integers, the discrete convolution of $f$ and $g$ is given by:[1]

[] \begin{align} (f * g)[n]\, & \stackrel{\mathrm{def}}{=}\ \sum_{m=-\infty}^\infty f[m]\, g[n - m] \\ &= \sum_{m=-\infty}^\infty f[n-m]\, g[m] \\ &= (g * f)[n]. \end{align} []

When $g$ has finite support in the set $\{-M,-M+1,\dots,M-1,M\}$ (representing, for instance, a finite impulse response), a finite summation may be used:[2]

[$](f*g)[n]=\sum_{m=-M}^M f[n-m]g[m].[$]

### Continuous Distributions

If $X_1,\ldots,X_n$ denotes a sequence of mutually independent continuous random variables each having a probability density function, then the sum $Y = \sum_{i=1}^n X_i$ has probability density function $f_{X_1} * \cdots * f_{X_n}$. Here is a table giving the distribution for sums of well-known discrete distributions:

$X_i$

$Y$

$\textrm{Normal}(\mu_i, \sigma^2_i)$ $\textrm{Normal}(\mu_1 + ... + \mu_n, \sigma_1^2 + \ldots + \sigma^2_n)$
$\textrm{Cauchy}(a_i,γ_i)$ $\textrm{Cauchy}(a_1+...+a_n,γ_1 +...+γ_n)$
$\textrm{Exponential}(\theta)$ $\textrm{Gamma}(n, \theta)$
$\textrm{Chi-Square}(r_i)$ $\textrm{Chi-Square}(r_1 +...+ r_n)$

To demonstrate the convolution technique, we will give a derivation of the result described in the third row in the table above (sum of exponentials). The proof is by induction on $n$. For $n = 1$, there is nothing to show. If

[$] Y_n = X_1 + \ldots + X_n [$]

then we need to show that $Y_{n+1}$ is $\textrm{Gamma}(n+1, \theta)$ given that $Y_n$ is $\textrm{Gamma}(n,\theta)$. It suffices to show the result for $\theta = 1$ since the general case then follows by scaling. Using the convolution technique, the density of $Y_{n+1}$ equals:

[] \begin{align} f_{Y_n}*f_{X_{n+1}}(y) & \propto \int_0^y x^{-n} e^{-x} e^{x-y} dx \\ & \propto e^{-y} \cdot \int_0^y x^{n-1} dx \\ & \propto e^{-y} \, y^{n}. \\ \end{align} []

This is the density function of a $\textrm{Gamma}(n+1,1)$ and thus, by induction, we have completed the derivation.

The symbol $\propto$ means proportional to and is used to signify that the expression to the left of it is proportional to the expression to the right of it.

### Discrete Distributions

Similarly, if $X_1, \ldots, X_n$ denotes a sequence of mutually independent integer valued random variables, then the sum

[$] Y = \sum_{i=1}^n X_i [$]

has probability mass function $p_{Y} = p_{X_1} * \cdots * p_{X_n}.$. Here is a table giving the distribution for sums of well-known discrete distributions:

$X_i$

$Y$

$\textrm{Bernouilli}(p)$ $\textrm{Binomial}(n,p)$
$\textrm{Binomial}(n_i,p)$ $\textrm{Binomial}(n_1 +...+n_n,p)$
$\textrm{NegativeBinomial}(n_i,p)$ $\textrm{NegativeBinomial}(n_1 + \cdots + n_n, p)$
$\textrm{Geometric}(p)$ $\textrm{NegativeBinomial}(n,p)$
$\textrm{Poisson}(\lambda_i)$ $\textrm{Poisson}(\lambda_1 + \ldots + \lambda_n)$

To demonstrate the convolution technique, we will give a derivation of the result described in the second row in the table above (sum of binomials). The proof is by induction on $n$. For $n = 1$ there is nothing to show. If $Y_n = \sum_{i=1}^n X_i$, $s_n = \sum_{i=1}^n n_i$, and we set $q= 1-p$ and $\operatorname{P}[Y_{n+1} = y] = p(y)$, then

[] \begin{align} p(y) &= \sum_{m=0}^{y} \binom{s_n}{m} p^m q^{s_n-m} \binom{n_{n+1}}{y-m} p^{m-y}q^{n_{n+1}-(m-y)} \\ \label{conv-bin-1} &= p^{y} q^{s_{n+1} -y} \sum_{m=0}^y \left[\binom{s_{n}}{m} + \binom{n_{n+1}}{y-m} \right] \\ \label{conv-bin-2} &= p^{y} q^{s_{n+1} -y} \binom{s_{n+1}}{y}. \end{align} []

To go from \ref{conv-bin-1} to \ref{conv-bin-2}, we have used the combinatorial identity

[$] \sum_{m=0}^y \left[\binom{N_1}{m} + \binom{N_2}{y-m} \right] = \binom{N_1 + N_2}{y}. [$]

\ref{conv-bin-2} indicates that $Y_{n+1}$ is a binomial with parameters $s_{n+1}$ and $p$. By induction, we have completed the derivation.

## Notes

1. Damelin & Miller 2011, p. 232
2. Press, William H.; Flannery, Brian P.; Teukolsky, Saul A.; Vetterling, William T. (1989). Numerical Recipes in Pascal. Cambridge University Press. p. 450. ISBN 0-521-37516-9.