Draw any density f on a finite support with the mouse. Its cumulative distribution F is computed as you draw. Each draw takes u ~ U(0,1) on the vertical axis of F, runs across to the curve, and drops to x = F−1(u). The histogram of those x values converges to f.
How it works: Sketch a density f with the mouse (or pick a preset: bimodal, piecewise constant, triangular, truncated exponential, uniform). The page computes the CDF F as you draw. Each sample picks u ~ U(0,1) on the vertical axis of F, runs across to the curve, and drops to x = F−1(u). A histogram of the samples builds up beneath, and converges to f.
Try this: Draw one sample at a time to follow the path, then switch off animation and draw batches. Note how steep parts of F catch many values of u while flat parts catch almost none.
Why it works: for U ~ U(0,1), P(F−1(U) ≤ x) = P(U ≤ F(x)) = F(x). Steep parts of F (where f is large) catch a wide band of u values, so many samples land there; flat parts (where f ≈ 0) catch almost none. The drawn density is treated as piecewise constant on 240 cells, so F is piecewise linear and is inverted exactly.