Inverse Transform Sampling
A method for generating random samples from any distribution you can invert the CDF of, by feeding a uniform random number through that inverse CDF.
Prerequisites: The Law of Large Numbers
Every computer's random number generator, at its core, only produces uniform random numbers between 0 and 1 — equally likely to land anywhere in that range. But a Monte Carlo simulation of default times, trade sizes, or asset returns needs samples from far more specific distributions: exponential waiting times, fat-tailed return distributions, or an empirical distribution read off historical data. Inverse transform sampling is the basic recipe for turning that one uniform generator into a generator for almost any distribution you want.
An analogy: a lottery wheel mapped onto a ruler
Picture a spinner that lands uniformly anywhere between 0 and 1, and a ruler laid out where each point on the ruler corresponds to a possible outcome — but the ruler's markings are squeezed together where outcomes are common and stretched apart where outcomes are rare, exactly matching how likely each region is. Spin the uniform spinner, read off where it lands on the squeezed-and-stretched ruler, and the outcome you read out follows the target distribution automatically — dense regions of the ruler get hit often because they occupy more of the 0-to-1 spinner range. That ruler is precisely the inverse of the cumulative distribution function (CDF).
The method, one symbol at a time
Let be the CDF of the target distribution — the probability the random variable is at most , which rises monotonically from 0 to 1. Its inverse, , answers "what value has cumulative probability ?" The method: draw uniformly on , and set . The resulting has exactly the target distribution. Why this works in plain terms: stretches the x-axis so that equal slices of probability become equal slices of the 0-to-1 range — inverting it undoes that stretch, so a uniform draw on the 0-to-1 range maps back to -values with exactly the right density of landing points.
Worked example 1: sampling an exponential distribution
The exponential distribution with rate has CDF . Setting and solving for gives the inverse:
Take (mean waiting time of 2, say, minutes between order arrivals) and a uniform draw . Then minutes. Draw instead: minutes. Notice most uniform draws land in the middle of , which the steep part of near maps to short waits and the flatter part near maps to occasional long waits — exactly the shape of an exponential distribution.
Worked example 2: a discrete three-outcome distribution
Suppose a trade outcome is "loss" with probability 0.5, "small gain" with probability 0.3, "big gain" with probability 0.2. There's no formula to invert, but the same logic applies with a lookup: build cumulative bins → loss, → small gain, → big gain. A draw falls in the second bin, so the sampled outcome is "small gain"; falls in the third bin, "big gain." Over many draws, exactly 50% land in the first bin, 30% in the second, 20% in the third, because that's how much of the range each bin occupies — reproducing the target probabilities without ever writing a closed-form CDF.
Drag the parameters above and picture the CDF as the running-total area under this curve from left to right — inverse transform sampling is exactly the operation of reading that cumulative curve backward, from a probability level on the vertical axis to a value on the horizontal axis.
What this means in practice
Inverse transform sampling underlies simulation of default times in credit models, waiting times in queueing and market-microstructure models, and — via the empirical CDF — bootstrap resampling from historical data when no clean parametric form exists. Its main limitation is that must be computable, either in closed form (exponential, uniform, and a handful of others) or numerically (root-finding on ); for distributions like the normal, where has no elementary closed form, practitioners either use a fast numerical approximation to the inverse or switch to a different sampling method such as acceptance-rejection.
To sample from any distribution, invert its CDF and plug in a uniform random number: automatically produces with the target distribution because stretches probability-space into a uniform 0-to-1 scale, and undoes that stretch.
A common error is applying the formula with drawn from the wrong range or forgetting that must be the true inverse of the target CDF, not an approximation borrowed from a similar-looking distribution — using the wrong inverse silently produces samples from the wrong distribution while still looking plausible on a quick histogram check. Always verify by comparing a large simulated sample's histogram against the target density before trusting downstream results.
Related concepts
Practice in interviews
Further reading
- Glasserman, Monte Carlo Methods in Financial Engineering, ch. 2
- Ross, Simulation, ch. 5