Lune

SODA2026Top-tier venue

Efficient Online Random Sampling via Randomness Recycling

Thomas L. Draper, Feras A. Saad

Abstract

This article studies the fundamental problem of using i.i.d. coin tosses from an entropy source to efficiently generate random variables X i ∼ P i (i ≥ 1), where (P 1 , P 2 , . . . ) is a random sequence of rational discrete probability distributions subject to an arbitrary stochastic process. Our method achieves an amortized expected entropy cost within ε > 0 bits of the information-theoretically optimal Shannon lower bound using O(log(1/ε)) space. This result holds both pointwise in terms of the Shannon information content conditioned on X i and P i , and in expectation to obtain a rate of E[H(P 1 ) + • • • + H(P n )]/n + ε bits per sample as n → ∞ (where H is the Shannon entropy). The combination of space, time, and entropy properties of our method improves upon the Knuth and Yao (1976) entropy-optimal algorithm and Han and Hoshi (1997) interval algorithm for online sampling, which require unbounded space. It also uses exponentially less space than the more specialized methods of Kozen and Soloviev (2022) and Shao and Wang (2025) that generate i.i.d. samples from a fixed distribution. Our online sampling algorithm rests on a powerful algorithmic technique called randomness recycling, which reuses a fraction of the random information consumed by a probabilistic algorithm to reduce its amortized entropy cost.

On the practical side, we develop randomness recycling techniques to accelerate a variety of prominent sampling algorithms, which include uniform sampling, inverse transform sampling, lookup-table sampling, alias sampling, and discrete distribution generating (DDG) tree sampling. We show that randomness recycling enables state-of-the-art runtime performance on the Fisher-Yates shuffle when using a cryptographically secure pseudorandom number generator, and that it reduces the entropy cost of discrete Gaussian sampling. Accompanying the manuscript is a performant software library in the C programming language.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

Questions to start from

Lune can draw on

the full paper · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Random Variate Generation with Formal Guarantees cites The Discrete Gaussian for Differential Privacy
  • Random Variate Generation with Formal Guarantees cites Optimal approximate sampling from discrete probability distributions
Builds onCited byLeft to right by year; the more cited, the higher.

Builds on3

  1. The Discrete Gaussian for Differential PrivacyClément L. Canonne, Gautam Kamath, Thomas SteinkeNeurIPS 2020 · 355 citations
  2. Optimal approximate sampling from discrete probability distributionsFeras A. Saad, Cameron E. Freer, Martin C. Rinard, Vikash K. MansinghkaPOPL 2020 · 3 citations
  3. Random Variate Generation with Formal GuaranteesFeras A. Saad, Wonyeol LeePLDI 2025

Related papers

  1. Energy-Efficient Random Variate Generation via Compressed Lookup TablesJohann Ukrow, Anna Kazachkova, Nicolas Alder, Sven Köhler et al.ICLR 2026
  2. Pseudorandom Hashing for Space-bounded Computation with Applications in StreamingPraneeth Kacham, Rasmus Pagh, Mikkel Thorup, David P. WoodruffFOCS 2023
  3. Online Weighted Paging with Unknown WeightsOrin Levy, Noam Touitou, Aviv RosenbergNeurIPS 2024 · 1 citation
  4. Perfect Lp Sampling with Polylogarithmic Update TimeWilliam Swartworth, David P. Woodruff, Samson ZhouFOCS 2025 · 1 citation
  5. Nearly Optimal Bounds for Stochastic Online SortingYang HuSODA 2026
Dusk over the sea between two cliffs drawn in fine vertical lines