arXiv · 2504.04267
Efficient Rejection Sampling in the Entropy-Optimal Range
Abstract
We study the problem of generating a random variate $X$ from a finite discrete probability distribution $P$ 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)$ and $H(P)\,{+}\,2$, where $H$ 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)$. 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.
Explore related subjects
Keep this discovery
Explore connections, maps & timelines
Thomas L. Draper, Feras A. Saad. 2025-04-05. Efficient Rejection Sampling in the Entropy-Optimal Range. https://doi.org/10.1109/tit.2026.3658044
Cite the original work for its findings. Save a collection to share your selection of sources.