the inverse-transform method
A computer can hand you uniform random numbers between 0 and 1 all day. But what if you need draws from an exponential, or a custom distribution from a model? The inverse-transform method turns a single uniform number into a draw from any distribution whose cdf you can invert. It is the probability integral transform run backwards.
The recipe is two lines. Generate U uniform on (0, 1). Return X = F^{-1}(U), where F^{-1} is the quantile function — the inverse of the target cdf. That is the whole algorithm. It works because of the same flattening logic in reverse: if F flattens X into a uniform, then F^{-1} unflattens a uniform back into something with cdf F. The intuition is geometric: U picks a height on the vertical probability axis between 0 and 1, and F^{-1} reads across to the x-value sitting at that cumulative probability, so x-regions where the distribution is dense get hit more often.
Its great virtues are exactness and monotonicity (it preserves order, which helps in simulation tricks like common random numbers). Its limitation is that you must be able to invert F, in closed form or numerically. When F has no easy inverse — like the normal cdf — people often turn to specialised tricks instead, such as Box-Muller. For discrete distributions there is a matching version: walk up the cumulative probabilities and return the first value whose cumulative total exceeds U.
To draw from an exponential with rate lambda: its cdf is F(x) = 1 - e^(-lambda x), so F^{-1}(u) = -ln(1 - u) / lambda. Generate U uniform on (0, 1) and return X = -ln(1 - U) / lambda. (Since 1 - U is also uniform, -ln(U)/lambda works too.) Each uniform draw becomes one exponential draw.
Plug a uniform into the inverse cdf and you get a draw from the target distribution.
It needs an invertible cdf. When F^{-1} has no closed form (e.g. the normal), it is slow or impossible analytically, and methods like Box-Muller or rejection sampling are used instead.