Algorithms, Complexity, and Entropy of the Bernard-Letac Fair-Sampling Construction
This paper extends the computational and information-theoretic analysis of the Bernard-Letac fair-sampling construction by presenting five formally verified algorithms, deriving exact and approximate formulas for expected sampling costs using Rényi entropies, and optimizing the binary case via a seven-state automaton to reduce complexity from quadratic to nearly linear.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Imagine a world where every coin you flip is weighted, perhaps landing on heads more often than tails, or perhaps favoring one side so heavily that the other seems to almost never appear. For decades, mathematicians and computer scientists have asked a deceptively simple question: if you only have access to such a broken, biased source of randomness, can you still generate a perfectly fair outcome? Can you force a fair coin flip, or a fair choice among many options, using nothing but a stream of these flawed, unpredictable signals? The answer is yes, but the path to fairness is not straightforward. It requires a method that knows nothing about the bias, works for any kind of bias, and stops at just the right moment to ensure the result is truly random. This is the problem of fair sampling, a challenge that sits at the intersection of probability, number theory, and the very nature of information.
In a recent study, Claude Gravel, a researcher at Toronto Metropolitan University, has taken a deep dive into a specific solution to this problem, originally proposed in 1971 by Bernard and Letac. While the original work provided a clever mathematical recipe for fairness, it left many practical questions unanswered. Gravel's paper transforms that abstract recipe into a set of concrete, working algorithms, rigorously proving that they work and analyzing exactly how much effort they require. The study reveals that the cost of generating a fair result is not just a simple number but is deeply tied to the hidden structure of the biased source itself. By treating the problem through the lens of modern information theory, the research uncovers precise formulas for how long the process takes and shows that the most efficient way to use these biased signals depends on a specific type of mathematical "temperature" known as entropy.
The core of the Bernard–Letac method is a process of accumulation. Imagine a traveler walking through a grid, taking steps based on the symbols drawn from the biased source. If the source is a coin, the traveler moves right for heads and up for tails. The traveler keeps walking, recording the total number of steps in each direction, until they reach a specific stopping point. This stopping point is not chosen arbitrarily; it is a location where a complex counting rule, involving how many different ways the traveler could have arrived there, results in a number that is perfectly divisible by the number of outcomes you want to generate. For example, if you want a fair choice between five options, the process stops the moment the number of possible paths to the current location is a multiple of five. The magic of the method is that no matter how the coin is weighted, the paths leading to this stopping point can be divided into five groups of exactly equal size. This ensures that when the process stops, the final outcome is perfectly fair, even though the input was heavily biased.
Gravel's work begins by turning this elegant mathematical idea into five distinct, step-by-step computer algorithms. Each algorithm is designed to handle the task with formal guarantees of correctness. The study provides detailed instructions on how to compute the necessary counts efficiently, showing that the process can be carried out without needing to know the bias in advance. One of the most significant contributions is the analysis of how long this process takes. The researchers found that the average number of draws required to stop is not a fixed value but depends on the specific distribution of the biased source. They derived an exact formula for this average time, which involves an infinite product of terms related to the source's probabilities. This formula reveals that the cost is governed by a family of measures called Rényi entropies, which capture different aspects of the source's randomness.
A surprising finding in the paper is that a simple, intuitive guess for the cost of the process is always wrong. Many might assume that the cost is roughly determined by the most basic measure of randomness, known as Shannon entropy. However, the study proves that this simple approximation consistently overestimates the true cost. The actual cost is always lower than the simple guess, but the difference is not trivial. The researchers showed that as the number of desired outcomes grows very large, the cost does not shrink to the theoretical minimum predicted by basic information theory. Instead, it settles at a value that is strictly higher than the theoretical limit. This means that while the Bernard–Letac method is fair, it is not perfectly efficient; it inevitably wastes some of the randomness available in the source. The amount of waste depends on the entire distribution of the source, not just its overall entropy.
The paper also tackles the question of how to make the process faster on a computer. The original method requires a significant amount of calculation to determine which group a specific path belongs to, a step that can become very slow as the number of draws increases. For the specific case of generating a single fair bit (a choice between two options) from a binary source, Gravel discovered a way to bypass the heavy calculation entirely. By analyzing the structure of the paths, the researcher constructed a simple machine with just seven states that can determine the outcome by reading the binary digits of the path coordinates. This machine reduces the computational effort from a quadratic growth, which becomes unmanageable for large numbers, to a nearly linear growth, making the process vastly more practical for real-world applications.
The study further explores what happens when the number of outcomes is not a prime number but a composite one, such as six or ten. In these cases, the mathematical structure becomes much more irregular. The researchers found that for composite numbers, the process can get stuck in situations where certain stopping points are unreachable, and the groups of paths are not always of equal size. This irregularity prevents the researchers from finding a simple, closed-form formula for the cost in these cases, leaving it as an open question for future work. The paper suggests that for practical purposes, it might be better to round up to the nearest prime number to avoid these complications, though this has not been rigorously proven.
Ultimately, this research provides a comprehensive map of the terrain for fair sampling from biased sources. It confirms that the Bernard–Letac construction is a robust and correct method, but it also highlights its limitations and the precise mathematical reasons behind them. The work demonstrates that the cost of fairness is a complex quantity, shaped by the intricate details of the source's distribution. By providing exact formulas, efficient algorithms, and a clear understanding of the trade-offs involved, the study moves the field from abstract possibility to concrete implementation, offering a deeper understanding of how randomness can be extracted and purified from imperfect sources. The findings suggest that while we can achieve perfect fairness, the price we pay is a subtle and unavoidable inefficiency that is intrinsic to the nature of the biased source itself.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.