arXiv:2608.20234cs.ITAug 2026

Manuscript Offprint

arXiv:2608.20234

Algorithms, Complexity, and Entropy of the Bernard-Letac Fair-Sampling Construction

Claude Gravel

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Bernard and Letac (1971) introduced a method for uniform random sampling among mm outcomes from an unknown biased source of independent and identically distributed symbols. The process terminates when the multinomial coefficient of the cumulative symbol counts equals zero modulo mm. This study extends the computational and information-theoretic analysis of their construction by presenting five algorithms with formal correctness guarantees and comprehensive complexity analyses. For prime m=pm=p, the Bernard–Letac framework is analyzed in greater detail. The Rényi entropies of the source yield an exact product formula for the expected number of draws. A first-order approximation consistently overestimates this value, and the entropy lower bound is never attained. As pp, treated as a continuous parameter, approaches 1, the expected cost converges to a constant greater than 1, determined by the entire source distribution. Furthermore, for every prime modulus pp and every finite alphabet II, an explicit automaton with p+∣I∣+3p+|I|+3 states computes the mod-pp first-passage kernel of the walk from the base-pp digits of its arguments, reducing the fair assignment cost from quadratic to nearly linear.

2020 Mathematics Subject Classification. Primary 60G40; Secondary 05A10, 11B65, 94A17, 68W20.

Keywords. Random number generation; stopping times; multinomial coefficients; Kummer’s theorem; Rényi entropy.

1 Introduction and Background

A central problem in probability and computation concerns the following question. Given access to a biased source of randomness, specifically a device producing independent and identically distributed (i.i.d.) draws from an unknown distribution π\boldsymbol{\pi} over a finite alphabet, can one generate a fair outcome that is uniform over mm possibilities using a finite, albeit random, number of draws? The procedure must succeed for every admissible π\boldsymbol{\pi}, without any prior knowledge of the underlying bias.

The earliest solution to this problem was proposed by von Neumann [21], who in 1951 demonstrated that a fair coin flip can be simulated using a biased coin through a simple rejection scheme. Letting π0\pi_{0} and π1\pi_{1} denote the probabilities of the two outcomes, each trial of this scheme consumes a pair of draws and succeeds with probability 2π0π12\pi_{0}\pi_{1}. Thus, the expected cost is 1/(2π0π1)1/(2\pi_{0}\pi_{1}) pairs, or equivalently, 1/(π0π1)1/(\pi_{0}\pi_{1}) draws. In 1970, Hoeffding and Simons [13] revisited the problem, developing improved procedures for the binary case that achieve a smaller expected stopping time and characterizing the class of all valid stopping rules. Notably, they introduced a walk on N2\mathbb{N}^{2} tracked by the parity of the binomial coefficient (tk)\binom{t}{k}, where tt is the number of draws made so far and kk is the number of those equal to one fixed outcome. This device served as a direct precursor to the Bernard–Letac construction.

In 1971, Bernard and Letac [4] extended both previous works in two significant directions. They allowed the alphabet II to be arbitrary, whether finite or countable, and aimed to produce an mm-way fair partition rather than only a fair binary split. Their principal contribution is a construction based on the set Hm={x∈M:c(x)≡0(modm)}H_{m}=\{x\in\mathfrak{M}:c(x)\equiv 0\pmod{m}\}, where M\mathfrak{M} denotes the free abelian monoid on II and c(x)c(x) represents the multinomial coefficient. The random walk defined by the cumulative draw counts terminates upon first reaching HmH_{m}. The authors demonstrate that the paths to any stopping state can be partitioned into exactly mm equiprobable classes, regardless of the bias π\boldsymbol{\pi}.

The results of the original paper are primarily combinatorial and number-theoretic, with no consideration of computational or information-theoretic perspectives. The present work addresses these gaps by (1) extracting from the original theorems a family of five distinct algorithms (Section 2), each presented formally with correctness guarantees, complexity analyses, and explicit pseudocode; (2) deriving new and precise results regarding the expected complexity of the central fair-sampling algorithm, expressed in terms of Rényi and Shannon entropy (Section 3); and (3) establishing a transfer theorem for the mod-pp first-passage kernel of the walk, for every prime pp and every finite alphabet (Section 4). Additionally, worked examples (Section 2.1) and numerical illustrations (Section 5) are provided to concretely demonstrate the construction.