Instant TravelLuminary Oddities — Enter the Portal
Explore
Shop
← Luminary Oddities

Research explained · Exact sampling

Can a Computer Roll Perfect Dice Without Wasting Coin Flips?

Computers simulate chance from a stream of fair coin flips. This paper settles exactly when that can be done with no wasted randomness using a fixed amount of memory, proving a 2026 conjecture of Draper and Saad.

The problem in everyday terms

Almost every simulation, game, randomised algorithm and statistical method needs random choices with particular probabilities: an outcome that happens one time in three, a die with unequal faces, a weighted lottery. The raw material a computer actually has is simpler: a stream of fair random bits, each 0 or 1 with equal chance. An exact sampler is a procedure that turns those bits into outcomes with exactly the right probabilities, with no approximation.

Bits are a resource, and the natural question is how few you can use. Information theory gives a floor. Each outcome carries a certain amount of information, and the average, the Shannon entropy, is the least number of bits any exact sampler can use per outcome.

What was already known

In the 1970s Knuth and Yao found the optimal way to draw a single sample. It always uses fewer than two bits more than the entropy. It hits the entropy exactly only when every probability is a power of one half, such as 1/2, 1/4 or 1/8. Such distributions are called dyadic. For example, choosing between outcomes with probabilities 1/2, 1/4 and 1/4 takes one bit, and a second bit half the time: exactly the entropy.

A simple non-dyadic case is a coin that lands heads one time in three. Its entropy is about 0.918 bits, but the best single-sample method uses 2 bits on average.

When many samples are needed, the gap can be closed by recycling: bits that were read but not needed for the current outcome are saved and used for the next one. Known methods can drive the waste per sample as low as desired, but the saved randomness has to be stored, and that memory becomes a second cost. Draper and Saad made the trade-off precise in 2026. They showed that, for many distributions, getting the waste below a small amount ε requires memory that grows like log(1/ε), and they conjectured that for any non-dyadic distribution, no sampler with a fixed, finite memory can make the waste per sample go all the way to zero.

The result

The paper proves their conjecture, for distributions with finitely many outcomes and also for those with countably infinitely many. A finite-state exact sampler has zero asymptotic waste per sample if and only if every probability is a power of one half.

In other words, perfect efficiency with bounded memory is available only in the dyadic case, where it was already easy. For anything else, such as the one-in-three coin, some waste is unavoidable unless memory is allowed to grow without limit.

The paper also adds a quantitative companion. For non-dyadic distributions whose probabilities are algebraic numbers, a broad class that includes all rational probabilities, the waste per sample is at least a fixed negative power of the number of memory states. Together with the known constructions, this shows that for these distributions memory of order log(1/ε) bits is both necessary and sufficient to reach waste ε.

The idea of the proof

The paper explains its argument with two images. The first is spare randomness as a wallet. A recycling sampler carries leftover randomness from round to round in its state, like change in a wallet. If the sampler is perfectly efficient over the long run, nothing can leak out of the wallet on average.

The second is weights as tags. Zero long-run loss forces the transitions the sampler keeps returning to to have a rigid integer structure: each step's probabilities must be balanced exactly by powers of two. That rigidity reduces the whole question to a single finite equation, and only powers of two satisfy it. If any probability is not a power of one half, the equation fails, and some waste must remain.

The quantitative bound for algebraic probabilities draws on a deep tool from number theory, lower bounds for linear forms in logarithms, which limit how close combinations of logarithms of algebraic numbers can come to zero.

Why it matters

Randomness is cheap in most everyday software, but not everywhere. Hardware random-number generators, cryptographic systems, large Monte Carlo simulations and low-power devices all have reasons to care about how many random bits and how much memory a sampler uses. The result draws a clean boundary: it tells designers that pursuing zero waste with fixed memory is pointless outside the dyadic case, and that the known log(1/ε) memory cost cannot be beaten in general.

It also settles a conjecture posed in 2026 by the researchers who built the leading randomness-recycling samplers.

Status of the paper

This paper is in its seventh edition in the Luminary Research Archive, published under a CC BY 4.0 licence. The sixth edition added the plain-language picture of the proof used above, spare randomness as a wallet and weights as tags; the seventh states precisely how the wallet is measured.

By Scott Schubr, Luminary Oddities. Explainer published 5 December 2026; mathematical statements checked against the cited Archive edition by our Math Lab. Paper: https://research.luminaryoddities.org/finite-persistent-memory-exact-sampling-countable-rigidity-algebraic-memory-bounds/v/7 · DOI 10.5281/zenodo.24850755

Read the paper

The full paper, its edition history and supporting files are in the Luminary Research Archive.

Curiosities of the living and natural world