Transformations of a Random Variable
When you push a random variable through a function, its density stretches or compresses — you'll learn the Jacobian rule that tells you by how much.
By the end you'll be able to transform a density using the change-of-variables (Jacobian) formula for a monotone \(g\), and switch to the CDF method when \(g\) isn't monotone.
Predict: before you draw a sample, guess the shape of Y's density for Y = −ln(X)/λ — does it peak at 0 or somewhere in the middle? Then draw and check.
Draws of X ~ Uniform(0,1) flow down through a transform Y = g(X). Watch the flat input density get reshaped into the output density below — empirical bars from your draws vs. the theoretical curve, which is exactly f_X(g⁻¹(y))·|d/dy g⁻¹(y)|. Hover a bar for exact numbers.
For a monotone transformation \(Y = g(X)\), the density transforms by \(f_Y(y) = f_X(g^{-1}(y)) \cdot \left| \dfrac{d}{dy} g^{-1}(y) \right|\); the CDF method handles non-monotone cases.
This is called change of variables. For monotone \(g\): \(f_Y(y) = f_X(g^{-1}(y)) \cdot \left| \dfrac{d}{dy} g^{-1}(y) \right|\) — the derivative term (the Jacobian) corrects for how \(g\) stretches or compresses intervals. You take the absolute value so the density stays non-negative whether \(g\) is increasing or decreasing. Non-monotone \(g\) — or whenever you're not sure — fall back on the CDF method: write \(F_Y(y) = P(g(X) \le y)\), re-express the event in terms of \(X\), evaluate with \(F_X\), then differentiate.
Say you're writing simulation software: you can generate Uniform(0,1) draws easily, but you need Exponential losses for your model. The transform \(Y = -\ln(X)/\lambda\) (with \(X\) uniform) gives you exactly that — this "inverse transform method" is what underlies most Monte Carlo loss simulations you'll see in pricing and reserving. It's the same transform driving the interactive above.
Same setup, but now \(Y = -2\ln(X)\) — that's λ = ½ in the interactive above. You know \(g^{-1}(y) = e^{-y/2}\). Fill in the missing step:
\(\left| dg^{-1}/dy \right| = \) ____, so \(f_Y(y) = \) ____
Reveal the missing steps
\(\left| dg^{-1}/dy \right| = \tfrac12 e^{-y/2}\), so \(f_Y(y) = 1 \cdot \tfrac12 e^{-y/2} = \tfrac12 e^{-y/2}\) for \(y>0\) — Y ~ Exponential(1/2). Set λ = 0.5 in the interactive and compare the dashed theoretical curve to this density.
More info — why the CDF method always works
The Jacobian formula is really just a shortcut for the CDF method when \(g\) is monotone — differentiating \(F_Y(y) = F_X(g^{-1}(y))\) with the chain rule gives you the same \(f_X(g^{-1}(y)) \cdot |dg^{-1}/dy|\). When \(g\) isn't monotone (like \(Y=X^2\) above), you can't write a single \(g^{-1}\), so you go back to the CDF definition itself — which is why the CDF method is the safe fallback whenever you're unsure a transform is monotone. See the jbstatistics link in Dive deeper below for another worked derivation.
Check your understanding
X ~ Uniform(0,1) and Y = −ln(X). Using the change-of-variables formula, what is the distribution of Y?
Why can't the single-branch Jacobian formula \(f_Y(y)=f_X(g^{-1}(y))|d/dy\, g^{-1}(y)|\) be used directly for Y = X² with X ~ Normal(0,1)?
The interactive's Y = −ln(X)/λ transform is exactly the technique used to simulate losses from a named continuous family. Which family, and what's its rate parameter?
In \(f_Y(y) = f_X(g^{-1}(y)) \cdot |d/dy\, g^{-1}(y)|\), why take the absolute value of the derivative instead of just multiplying by it directly?
Recap
- Monotone \(g\): \(f_Y(y) = f_X(g^{-1}(y)) \cdot |dg^{-1}/dy|\) — the Jacobian rescales the density; always take the absolute value.
- Non-monotone \(g\) (or whenever you're unsure): use the CDF method — write \(F_Y(y) = P(g(X) \le y)\) in terms of \(F_X\), then differentiate.
- \(Y = -\ln(X)/\lambda\) turns a Uniform(0,1) draw into Exponential(λ) — the inverse-transform method used to simulate from named distributions.
- The Jacobian formula is a shortcut for the CDF method under monotonicity — when that assumption breaks, fall back to the CDF definition itself.
Dive deeper
- Harvard Stat 110 — Lecture 22: Transformations and Convolutions The change-of-variables method derived carefully.
- jbstatistics — One-Variable Jacobian Transformation Method Work a one-variable Jacobian density transformation step by step.
- MIT 9.07 — Transformations of Random Variables Lecture notes on transforming random variables.
Sources
- Transformations of a Random Variable