English

Efficient Rejection Sampling in the Entropy-Optimal Range

Data Structures and Algorithms 2026-04-28 v2 Discrete Mathematics Information Theory math.IT Probability Computation

Abstract

We study the problem of generating a random variate XX from a finite discrete probability distribution PP using an entropy source of independent fair coin flips. A classic result from Knuth and Yao shows that the optimal expected number of input coin flips per output sample lies between H(P)H(P) and H(P)+2H(P)\,{+}\,2, where HH is the Shannon entropy function. However, implementing the Knuth and Yao ``entropy-optimal'' sampler entails a tradeoff between using either exponential space with low runtime per sample, or linear space with high runtime per sample. We introduce a new sampling algorithm that avoids this tradeoff: it requires linearithmic space, incurs negligible runtime overhead per sample, and uses an expected number of coin flips that lies in the entropy-optimal range [H(P),H(P)+2)[H(P), H(P)\,{+}\,2). No previous sampler for discrete distributions simultaneously achieves these space, time, and entropy characteristics. Numerical experiments demonstrate improvements in runtime and entropy of the proposed method compared to the celebrated alias method.

Keywords

Cite

@article{arxiv.2504.04267,
  title  = {Efficient Rejection Sampling in the Entropy-Optimal Range},
  author = {Thomas L. Draper and Feras A. Saad},
  journal= {arXiv preprint arXiv:2504.04267},
  year   = {2026}
}
R2 v1 2026-06-28T22:48:15.042Z