Labs · Randomness
Paint Your Own Distribution
The accept–reject method can sample any shape you like. Draw a curve in the top panel with the mouse. That curve is a probability density. Each sample picks a random x and a random height, and keeps x only if the height falls under your curve.
The histogram below slowly reproduces your drawing. The white outline shows the shape it should converge to. Rejected samples are wasted work, which is why spiky curves sample more slowly.
Draw two separate humps for a bimodal distribution, then watch the acceptance rate.
Controls
- Samples per frame
- Histogram bins
- Curve colour
- Histogram colour
Evolved from Distributions.