Saved in:
Bibliographic Details
Main Authors: Draper, Thomas L., Saad, Feras A.
Format: Preprint
Published: 2025
Subjects:
Online Access:https://arxiv.org/abs/2504.04267
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866913059374628864
author Draper, Thomas L.
Saad, Feras A.
author_facet Draper, Thomas L.
Saad, Feras A.
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2504_04267
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Efficient Rejection Sampling in the Entropy-Optimal Range
Draper, Thomas L.
Saad, Feras A.
Data Structures and Algorithms
Discrete Mathematics
Information Theory
Probability
Computation
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.
title Efficient Rejection Sampling in the Entropy-Optimal Range
topic Data Structures and Algorithms
Discrete Mathematics
Information Theory
Probability
Computation
url https://arxiv.org/abs/2504.04267