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

Research explained · Exact sampling

Random Bits or Retries? Pricing Both in Exact Sampling

A sampler that saves random bits may have to try more often. This paper treats bits and attempts as two separate costs, and solves the resulting control problem exactly for one of the leading randomness-recycling samplers.

Two costs, not one

Exact sampling turns fair random bits into outcomes with exactly the right probabilities. Much of the research on it counts one cost: how many random bits are used per outcome. But the computation that turns bits into outcomes also costs something. Many exact samplers work by rejection: they draw a candidate, and if it falls outside the usable range, they reject it and try again. Each attempt takes time.

Saving bits and saving attempts can pull in opposite directions. A sampler that tops up its randomness frugally may reject more often. A sampler that adds more fresh bits each time may reject less. Optimising only bits can therefore favour a different strategy from the one you would choose if attempts were also charged.

The setting

Draper and Saad, in a paper at SODA 2026, developed randomness recycling, which reduces the bits that exact sampling consumes by carrying unused randomness forward from one sample to the next. One of their constructions, the inversion recycler, keeps a hidden random integer that is uniformly distributed over a known range. Before each attempt, a controller decides how many fresh bits to append, which enlarges the range. The enlarged range must stay below a fixed cap. The attempt then either produces an outcome, keeping some leftover randomness, or rejects, also keeping some.

The controller can see the size of the range and the history of the process, but not the hidden integer itself. That restriction is what keeps the outcomes exactly correct.

The question

Charge one unit for each new random bit and a price λ for each attempt. What is the lowest possible long-run cost per completed outcome, over every allowed controller, and how does it change as λ varies?

The problem of pricing bits and attempts together for this recycler was posed in the paper itself; the recycler and the general theory of finite control problems come from earlier work, which the paper credits.

The result

For every target distribution given by positive integer weights with at least two outcomes, and every cap at least twice the total weight minus two, the paper proves:

• At every price, some simple controller is optimal: one that makes the same deterministic choice every time it is in the same state.

• The best achievable cost, as a function of the attempt price, is a concave, piecewise-linear curve with rational breakpoints.

• A finite exact algorithm constructs the whole curve, together with certificates that prove each piece optimal.

The certificates are an important part of the result. They are exact rational numbers that anyone can check, and they work even when the optimal controller has several separate long-run behaviours with different costs, a situation the paper's certificates handle directly.

Worked cases

The paper computes two cases in full, with a cap of 255. For a target of (3/4, 1/4), the optimal strategy changes twice as attempts become more expensive, giving a curve with three straight pieces. For three equally likely outcomes, it changes once, giving two pieces. All breakpoints are given as explicit fractions.

The calculations also show something a bit-only table would hide. Controllers that react to the current range use strictly fewer bits than any fixed-threshold rule. But once attempts are priced high enough, certain fixed thresholds become exactly optimal. At this cap the bit savings from the smarter controllers are small, below 0.06 percent, which is itself a useful practical finding.

An independent program, described in the paper, recomputes the state spaces, rates, curves and breakpoints from scratch.

The idea of the proof

The method is a version of a classical tool for long-run average-cost control, gain and bias equations, adapted so that costs are counted per completed outcome rather than per step. A certificate consists of a gain, the claimed optimal cost, and a potential that assigns a value to each state. If every possible action satisfies an inequality relative to this potential, no controller can beat the gain; if a controller uses only actions that meet it with equality, it achieves the gain. Because the state space is finite, the inequalities can be checked exhaustively with exact arithmetic.

Why it matters

In hardware and high-throughput settings, random bits and computation have real and different costs. This paper shows how to choose a recycling strategy when both matter, and supplies portable, checkable evidence for the answer rather than numerical estimates.

Status of the paper

This paper is in its third edition in the Luminary Research Archive, published under a CC BY 4.0 licence. Its exact rational certificates and the independent program that reproduces the frontiers are part of the archive record.

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/exact-bit-and-attempt-tradeoffs-for-a-bounded-inversion-recycler/v/3 · DOI 10.5281/zenodo.24801031

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