Transformations of random variables
You rarely get to work with the variable you were given: prices are exponentials of returns, risk is a maximum over desks, a portfolio is a sum. This chapter builds the complete toolkit for finding the distribution of — the CDF method as universal fallback, the change-of-variables formula and its Jacobian, convolutions for sums, product CDFs for extremes, and the probability integral transform that turns uniform noise into any distribution you like. The recurring picture is conservation of mass: a transformation moves probability around without creating or destroying it, and every formula here is an accounting identity for where the mass went.
Picture the distribution of as a unit of sand spread along the line with local thickness . The map picks up every grain at and drops it at : no sand is created or lost, but compression piles the same sand higher and stretching thins it out. Every formula in this chapter — the Jacobian factor, the convolution integral, the chi-square density blowing up at zero — is this one picture written in calculus. When in doubt, forget densities entirely and track the mass directly through the CDF: that method never fails.
The CDF method: the universal fallback#
To find the distribution of , compute by expressing the event as a set of -values, reading its probability off , and differentiating. This works for any — monotone or not — because it manipulates probabilities (honest numbers) rather than densities (rates). Every fancier formula below is a shortcut through this computation.
Uniform. Let , . For , , so
The density is unbounded near 0 — more on why in a moment — yet integrates to 1: ; and since , half the mass lands below .
Normal. Let , . Now the map is two-to-one, and the CDF method handles it without blinking: for . Differentiating with the chain rule,
This is the chi-square distribution with 1 degree of freedom — the building block of every variance estimate. Both densities blow up at 0 for the same reason: squaring compresses the whole neighbourhood of (where the parent density is largest) into a tiny sliver near , and the sand piles up.
Change of variables: the Jacobian factor#
When is strictly monotone and differentiable, the CDF method can be run once and packaged as a formula. For increasing , and the chain rule differentiates it; for decreasing a minus sign appears, and the absolute value covers both cases:
Read the factor as a local exchange rate between lengths: a small interval of output is the image of an input interval of length , whose mass is exactly what lands on . Equate that mass to , cancel the , and the formula appears. Where the map stretches, the same mass covers more ground and the density is diluted; where it compresses, the density is concentrated.
A density carries units: probability per unit length of . Measure a waiting time in seconds instead of hours and the density changes by a factor of 3600 while every actual probability stays fixed. That is why densities can exceed 1 (the above is 5 at ) and even diverge, and why : forgetting the Jacobian silently asserts that the map neither stretches nor compresses anything — true only for shifts. Probabilities are invariant under the flow; densities are not.

For : , Jacobian , so . This is why the density carries a out front, and why an density is : stretching a standard exponential by dilutes its density by the same factor. Sanity-check every transformation against the linear case — a formula that gets wrong is missing its Jacobian.
Log and exp: the lognormal#
The most important nonlinear map in finance is the exponential. If and , then with Jacobian , and the change-of-variables formula gives the lognormal density
Asset prices are modelled lognormal for a structural reason: prices compound multiplicatively, so the log price is a sum of many small log returns, approximately normal by the CLT (LLN & CLT). Exponentiating yields a lognormal price — automatically positive, skewed right, fat upper tail. The applied consequences of working in logs are developed in returns & compounding.
The median of is — monotone maps carry quantiles across exactly. The mean is strictly larger:
The convex function amplifies upside deviations more than it damps downside ones, so averaging after the map beats mapping the average — a first sighting of Jensen’s inequality, proved properly in inequalities & bounds. With (an ordinary annual equity vol) the factor is — a 2% gap between mean and median, every year, from curvature alone.
A strategy whose log return has mean and variance per period grows wealth at median rate but expected rate ; equivalently, a simple return with mean compounds at roughly in log terms. That is volatility drag: two strategies with identical average returns but different vols end at different wealth, and the arithmetic-mean backtest column overstates what you will compound — the median outcome, not the mean, is what a single account experiences (position sizing). When a backtest metric and your account balance disagree, suspect a transformation applied on the wrong side of the expectation.
Min and max: extremes via CDFs#
For extremes of independent variables the CDF method is the natural tool, because max and min turn into intersections of independent events:
The maximum is small only if everyone is small; the minimum is large only if everyone is large. For i.i.d. variables these become and . The full machinery of ranked values — every intermediate rank, not just the two ends — is the subject of order statistics.
Let be independent, so . Then
so : exponential with the summed rates. Servers failing at rates 1, 2, and 3 per year produce a first failure at rate 6 — expected wait two months; moreover . This pair of facts is the engine room of Poisson processes: merging independent streams adds their rates because the next arrival is a minimum of exponential waits.
Sums: convolution#
For independent and , the density of is the convolution
Read it as a sweep over the ways to land on : whatever the first variable contributes, the second must supply exactly the rest, and independence multiplies the densities. The discrete version is how two dice make 7 more often than 12 — more ways to split it.
Let independent, . The integrand equals 1 exactly on the overlap of and , so the density of is the length of that overlap:
A triangle peaking at 1: slide a unit window across a unit block and record the overlap — maximal when centred, shrinking linearly toward the ends. There are simply more ways to make 1 than to make 0.1 (both variables must be tiny). Add a third uniform and the density turns piecewise quadratic and bell-ish; add thirty and it is visually indistinguishable from a normal — convolution smooths, and iterated convolution is the CLT in the making (LLN & CLT).
One closure fact to keep loaded — normal + normal = normal: for independent and , . Grinding the convolution integral proves it, but the civilised route is through transforms: generating functionsturn convolution into multiplication — whenever a convolution integral looks painful, that chapter’s machinery is the shortcut.
Ratios: the Cauchy distribution#
Let be independent and . Given , has density (the linear-map rule again); averaging over :
(The last integral is elementary after substituting .) This is the Cauchy distribution — bell-shaped near the centre, pathological in the tails: , so diverges and the Cauchy has no mean — not a large mean, no mean. The mechanism is visible in the construction: the denominator spends real time near zero, and dividing by a near-zero produces occasional enormous outputs.
The consequence for averages is brutal: if are i.i.d. Cauchy, their sample mean is exactly Cauchy again— averaging a million observations leaves you precisely as uncertain as one. The LLN’s hypothesis fails and its conclusion fails with it, the canonical fat-tail failure dissected in LLN & CLT. Any pipeline that averages ratios of noisy quantities — hedge ratios from short windows, statistics with tiny denominators — is flirting with this regime, and the symptom is sample means that never settle down.
The probability integral transform#
One transformation is so useful it gets its own name. Let have a continuous, strictly increasing CDF :
- Forward: — any continuous variable, pushed through its own CDF, becomes uniform.
- Backward: if , then — a uniform, pushed through any inverse CDF, acquires that distribution.
Forward: for , — the uniform CDF. Backward: . ■ Both lines are one move — is monotone, so applying it to both sides of an inequality preserves the event. Intuitively, is the rank of within its own distribution, and your rank in your own distribution is uniform by construction.
The backward direction is inverse-transform sampling, the foundation of simulation: a generator that only produces uniforms can produce anything with a computable inverse CDF — for the exponential, , verified in code below. This is how Monte Carlo methodsmanufacture their raw material; the forward direction is how models are audited (a correct model’s CDF applied to real data must be uniform), and why order statistics of any continuous distribution reduce to those of uniforms (order statistics) — rank first, transform later.
Several variables at once: the multivariate Jacobian#
The one-dimensional formula generalises verbatim, the derivative promoted to a determinant: if is a differentiable bijection and , then
where is the matrix of partial derivatives of the inverse map. The determinant is the volume exchange rate: a small box of output pulls back to a parallelepiped of volume , and mass conservation does the rest — the same sand-pile argument, one dimension up.
Let be independent and set
Claim: are independent standard normals. Sketch: the joint density of two standard normals, , becomes in polar coordinates (area element , Jacobian ) the product : a uniform angle, independent of a radius whose square is . Box-Muller builds exactly that pair from two uniforms — is the uniform angle, and is by inverse-transform sampling — then converts back to Cartesian. ■ Note the miracle: the outputs share one and one yet come out independent — a rotational-symmetry fingerprint unique to the Gaussian, and a workhorse of Monte Carlo methods.
Simulation check: triangle density and inverse-transform sampling#
Two claims verified numerically: the triangle density, and inverse-transform exponentials vs numpy.
import numpy as np
rng = np.random.default_rng(23)
n = 1_000_000
# --- 1. Triangle density of U1 + U2 ---------------------------------
s = rng.random(n) + rng.random(n)
tri = lambda x: np.where(x <= 1, x, 2 - x) # theoretical density
for lo, hi in [(0.4, 0.5), (0.95, 1.05), (1.7, 1.8)]:
emp = np.mean((s >= lo) & (s < hi)) / (hi - lo) # empirical density
mid = (lo + hi) / 2
print(f"density near s={mid:.2f}: empirical {emp:.4f} theory {tri(mid):.4f}")
# --- 2. Inverse-transform exponential vs numpy's exponential --------
lam = 1.5
u = rng.random(n)
x_inv = -np.log(1 - u) / lam # F^{-1}(U) = -ln(1-U)/lambda
x_np = rng.exponential(1 / lam, n) # numpy's own sampler
print(f"\nmean: inverse {x_inv.mean():.4f} numpy {x_np.mean():.4f} theory {1/lam:.4f}")
print(f"var: inverse {x_inv.var():.4f} numpy {x_np.var():.4f} theory {1/lam**2:.4f}")
for q in [0.5, 0.95]:
th = -np.log(1 - q) / lam
print(f"q={q}: inverse {np.quantile(x_inv, q):.4f} "
f"numpy {np.quantile(x_np, q):.4f} theory {th:.4f}")
# The two samplers agree to Monte Carlo error: F^{-1}(U) IS the exponential.Practice problems#
Five problems testing whether the mass-conservation picture is really installed — each a one-transformation question with a standard trap.
, . Find the density of and check it integrates to 1.
Solution. lives on . CDF method with a decreasing map: , using . Differentiate: on . Check: . ✓ The density is 4 at and 1 at : inversion compresses the far end of into a sliver near , so mass piles up there. The naive answer “uniform on ” is the missing-Jacobian error: nonlinear maps do not preserve uniformity.
i.i.d., . Find the distribution of and its expectation.
Solution. Product of CDFs: on , so , piling up against 1 as grows. Expectation: — with , ; with , ; the gap to 1 shrinks like . The best backtest among random strategies behaves the same way — the running maximum drifts up mechanically, edge or no edge, the selection-bias engine quantified in multiple testing & paradoxes.
, . Find the density and mean of .
Solution. The map is two-to-one, so use the CDF: for , , giving — the half-normal: the two symmetric branches of mass fold onto one side and the density doubles. Mean: , since the integrand is . Takeaway: mean absolute deviation for Gaussians — a quick fat-tail diagnostic when the observed ratio drifts from 0.8.
independent. Find the density of by convolution.
Solution. Both densities vanish on negatives, so the integral runs over :
The integrand is constant because the exponents recombine into whatever the split — every division of the total wait is equally likely. The result is the Gamma density: zero at 0 (two waits are rarely both tiny), peak at ; iterating gives Gamma — the arrival times of a Poisson process.
Given , construct a random variable with density on .
Solution. Inverse transform. The target CDF is , whose inverse is . So does it — check directly: . ✓ A pleasing duality with the chapter’s opening example: squaring a uniform piles mass toward 0; square-rooting piles it toward 1 — and is also the distribution of from Problem 2. Lesson: if you can write the CDF and invert it, you can simulate the distribution — no rejection, no special functions, one line of code.
Next: convolution integrals were the hard way — transforms turn sums into products and distributional identities into algebra: Generating functions.
