MakarovSuites
English
EnglishDeutschРусскийУкраїнськаFrançaisEspañolItalianoPolski
Contact & licences

Math

Every distribution from the uniform

There are only a few ways to make a random number with a given distribution, and all of them start from a uniform. Push it through the inverse of the CDF (exponential, Cauchy, triangular). Take two and turn them into a pair of normals (Box-Muller). Throw darts at a box around the density and keep the ones under the curve (rejection - and the share kept is π/4 for the semicircle). Count exponential waits in a unit of time (Poisson) or heads in ten coins (binomial). Follow one numbered token through the machine, then hold the whole sample against its exact curve.

Every distribution from the uniform — Actual application image
Actual application image

What happens

A computer makes one kind of random number, a uniform between 0 and 1; every other distribution has to be manufactured from it. Inversion feeds the uniform through the inverse of the target's cumulative curve. Box-Muller turns two uniforms into a normal with a square root, a log and a cosine. Rejection throws darts at a box and keeps the ones under the curve - and pays for it in wasted darts. Counting exponential gaps yields Poisson. Each recipe is drawn twenty thousand times and held against the exact curve. Pick a distribution, watch the recipe run, and read the distance to the truth.

Equations used in the module
Equations
inversion: x = F^(−1)(u), u uniform on (0,1);  exponential −ln u;  Cauchy tan π(u − ½)
Box-Muller: x = √(−2 ln u₁) cos 2πu₂
rejection: keep (x, y) uniform under the graph of f
Poisson(λ): the count of exponential gaps in unit time

Related experiments

Back to catalogue
L-systems — Actual application image

Math

L-systems

A grammar of a few rules, grown into a plant: rewrite, walk, rewrite deeper.

Grover's search — Actual application image

Math

Grover's search

Explore amplitude amplification in an unstructured search. A phase oracle changes the sign of the marked amplitude without changing probabilities in the computational basis. The diffusion step turns relative phase into a higher success probability. Too many iterations reduce that probability again.

Gates, phase and what a basis is for — Actual application image

Math

Gates, phase and what a basis is for

Four small circuits with one turnable phase in them, read in the Z, X or Y basis. The phase is a real, located property of the state - the Bloch vector walks the equator with it - and in the wrong basis it is completely invisible: over a whole turn the largest change in any outcome probability is 1e-16. Put a second Hadamard at the end and the same phase decides the answer with certainty. That is interference, and it is the whole difference between a quantum computer and a coin.