Week 3 Lecture Notes

This week we will focus on transformations of random variables.

Wednesday, January 29

We started today with the following warm-up problem:

  1. Most programming languages have a built in random number generator function that will generate (psuedo)random numbers between 0 and 1. How could you use a random number generator like that to generate a number between 50 and 100?

If UU is a Unif(0,1)\operatorname{Unif}(0,1) random variable, then 50+50U50+50U will be a Unif(50,100)\text{Unif}(50,100) random variable. What about other transformations of random variables? For situations like that, we have the following change of variables theorem.

Theorem (Change of Variables)

If XX is a continuous random variable with density fXf_X and Y=g(X)Y = g(X) where gg is a strictly increasing (or decreasing) differentiable function, then fY(y)=fX(x)|dxdy|.f_Y(y) = f_X(x) \left| \frac{dx}{dy} \right|. The support of YY is the interval from g(xmin)g(x_\text{min}) to g(xmax)g(x_\text{max}) where (xmin,xmax)(x_\text{min},x_\text{max}) is the support of XX.

  1. According to the Change of Variables Theorem, what is the density function for 50+50U50+50U?

  2. Suppose Y=ln(X)Y = -\ln(X) where XUnif(0,1)X \sim \operatorname{Unif}(0,1). What is the probability distribution of YY?

  3. What is the density function for a linear tranformation a+bXa+bX of an Exp(λ)\operatorname{Exp}(\lambda) r.v. XX? What is the support of the density function?

So why does this work?

Proof of Change of Variables Theorem

Let’s assume gg is a strictly increasing function. (Showing that the theorem is true when gg is strictly decreasing is Homework 2, Problem 4). Strictly increasing means that a<ba < b iff g(a)<g(b)g(a) < g(b). To find the density function for YY, first we’ll write down the CDF for YY: $$\begin{align*}F_Y(y) &= P(Y \le y) \hspace{0.85in} \text{(definition of CDF)} \\ &= P(g(X) \le y) ~~~~ ~~~~ ~~~ \text{(substitution)} \\ &= P(X \le g^{-1}(y)) \hspace{0.4in} \text{(since }g\text{ is strictly increasing)} \\ &= F_X(g^{-1}(y)). \end{align*}$$ To get the PDF from the CDF, take the derivative of both sides with respect to yy. Then by the chain rule, this is: fY(y)=fX(g1(y))dxdy.f_Y(y) = f_X(g^{-1}(y)) \frac{dx}{dy}. Since gg is increasing, so is g1g^{-1} and therefore dx/dydx/dy is nonnegative. \square

Study Question

  1. We saw in class today that if you randomly generate a number XX uniformly between 0 and 1, then Y=ln(X)Y = -\ln(X) will have an Exp(1)\text{Exp}(1) distribution. What if you wanted a random number with an Exp(λ)\text{Exp}(\lambda) distribution where λ1\lambda \ne 1? How could you generate a random number with that distribution?

Friday, January 31

Today we covered multivariate transformations of random variables. But first, we looked at an example where the Change of Basis theorem didn’t apply directly, but we were able to use the idea of the proof to make things work.

Let Y=X2Y = X^2 where XNorm(0,1)X \sim \operatorname{Norm}(0,1).

  1. Why doesn’t the change of basis theorem apply to YY and XX?

  2. Write the CDF for YY (FY(y)=P(Yy)F_Y(y) = P(Y \le y)) in terms of the CDF for XX.

  3. Differentiate both sides with respect to yy to find the density function fYf_Y.

Once we worked out that example, we moved on to the main result of today:

Theorem (Multivariate Change of Variables)

Suppose X=(X1,X2,,Xn)X = (X_1, X_2, \ldots, X_n) is a continuous random vector with joint density fX(x)f_X(x) and Y=g(X)Y = g(X) where g:nng: \mathbb{R}^n \rightarrow \mathbb{R}^n is function that satisfies the following assumptions:

  1. gg is invertible.
  2. All partial derivative xi/yj\partial x_i/\partial y_j of g1g^{-1} exist and are continuous, and
  3. The Jacobian matrix xy=(x1/y1x1/ynxn/y1xn/yn)\frac{\partial x}{\partial y} = \begin{pmatrix} \partial x_1/\partial y_1 & \ldots & \partial x_1/\partial y_n \\ \vdots & & \vdots \\ \partial x_n/\partial y_1 & \ldots & \partial x_n/\partial y_n \end{pmatrix} has nonzero determinant.

Then fY(y)=fX(x)|xy|f_Y(y) = f_X(x) \left| \frac{\partial x}{\partial y} \right| where |xy|\displaystyle \left| \frac{\partial x}{\partial y} \right| is the absolute value of the determinant of the Jacobian matrix.

Example: Box-Muller Transformation

Suppose that UUnif(0,2π)U \sim \text{Unif}(0,2\pi) and TExp(1)T \sim \text{Exp}(1) are independent random variables. Let X=2TcosUY=2TsinU.\begin{align*} X &= \sqrt{2T} \cos U \\ Y &= \sqrt{2T} \sin U. \\ \end{align*}

  1. Show that T=12(X2+Y2)T = \frac{1}{2}(X^2+Y^2).

  2. Find a formula for UU (Hint: what is Y/XY/X?).

  3. Find the Jacobian matrix (t,u)(x,y)=(t/xt/yu/xu/y),\frac{\partial (t, u)}{\partial (x, y)} = \begin{pmatrix} \partial t/\partial x & \partial t/\partial y \\ \partial u/\partial x & \partial u/\partial y \end{pmatrix}, and show that the determinant is always 1.

  4. Use the Multivariate Change of Variables Theorem to show that the joint density for (X,Y)(X,Y) is f(X,Y)(x,y)=12πe(x2+y2)/2.f_{(X,Y)}(x,y) = \frac{1}{2\pi} e^{-(x^2+y^2)/2}.

  5. Observe that XX and YY are independent Norm(0,1)\text{Norm}(0,1) random variables since f(X,Y)(x,y)f_{(X,Y)}(x,y) factors into (12πex2/2)(12πey2/2).\left(\frac{1}{\sqrt{2\pi}} e^{-x^2/2} \right)\left(\frac{1}{\sqrt{2\pi}} e^{-y^2/2} \right).