# Optimal Discrete Uniform Generation from Coin Flips, and Applications

@article{Lumbroso2013OptimalDU, title={Optimal Discrete Uniform Generation from Coin Flips, and Applications}, author={J{\'e}r{\'e}mie O. Lumbroso}, journal={ArXiv}, year={2013}, volume={abs/1304.1916} }

This article introduces an algorithm to draw random discrete uniform variables within a given range of size n from a source of random bits. The algorithm aims to be simple to implement and optimal both with regards to the amount of random bits consumed, and from a computational perspective---allowing for faster and more efficient Monte-Carlo simulations in computational physics and biology. I also provide a detailed analysis of the number of bits that are spent per variate, and offer some…

## 28 Citations

### Generating random permutations by coin-tossing: classical algorithms, new analysis and modern implementation

- Computer Science, Mathematics
- 2016

Several simple, classical, little-known algorithms for generating random permutations by coin-tossing are examined, analyzed and implemented, and asymptotic approximations to the expected complexity are clarified.

### Generating Random Permutations by Coin Tossing

- Computer Science, MathematicsACM Trans. Algorithms
- 2017

Several simple, classical, little-known algorithms for generating random permutations by coin tossing are examined, analyzed, and implemented, and asymptotically optimal approximations to the expected complexity are made.

### Random-Bit Optimal Uniform Sampling for Rooted Planar Trees with Given Sequence of Degrees and Applications

- Computer Science, MathematicsCALDAM
- 2016

This paper redesign and simplify an algorithm due to Remy et al. for the generation of rooted planar trees that satisfy a given partition of degrees and applies a natural process "simulate-guess-and-proof" to analyze the height of a random Motzkin in function of its frequency of unary nodes.

### Binary decompositions of probability densities and random-bit simulation

- Computer Science, MathematicsMonte Carlo Methods Appl.
- 2020

The method is based on the so-called binary decomposition of the density and comes down to simulation of a special discrete distribution to get several principal bits of output, while furtherbits of output are produced by “flipping a coin”.

### A Very Fast , Parallel Random Permutation Algorithm

- Computer Science
- 2018

This article introduces an algorithm, MERGESHUFFLE, which is an extremely efficient algorithm to generate random permutations (or to randomly permute an existing array). It is easy to implement, runs…

### Optimal approximate sampling from discrete probability distributions

- Computer ScienceProc. ACM Program. Lang.
- 2020

This paper addresses a fundamental problem in random variate generation: given access to a random source that emits a stream of independent fair bits, what is the most accurate and entropy-efficient…

### MergeShuffle: a very fast, parallel random permutation algorithm

- Computer ScienceGASCom
- 2018

This article introduces an algorithm, MergeShuffle, which is an extremely efficient algorithm to generate random permutations (or to randomly permute an existing array), and suggests it is more efficient than the Rao-Sandelius algorithm, one of the fastest existing random permutation algorithms.

### Sampling Exactly from the Normal Distribution

- MathematicsACM Trans. Math. Softw.
- 2016

An algorithm for sampling exactly from the normal distribution that reads some number of uniformly distributed random digits in a given base and generates an initial portion of the representation of a normal deviate in the same base with mean cost that scales linearly in the precision.

### On Rejection Sampling Algorithms for Centered Discrete Gaussian Distribution over Integers

- Computer Science, MathematicsIACR Cryptol. ePrint Arch.
- 2017

Three alternative rejection sampling algorithms for centered discrete Gaussian distributions with parameter σ in two specific forms are proposed, designed for the case where σ is an positive integer, and it requires neither pre-computation storage nor floating-point arithmetic.

### A Model Counter's Guide to Probabilistic Systems

- Computer Science, MathematicsArXiv
- 2019

This work provides a conceptual framework for deriving #SAT encodings for probabilistic inference by modeling sequential systems, such as Markov chains, and revisiting the relationship between weighted and unweighted model counting.

## References

SHOWING 1-10 OF 21 REFERENCES

### Boltzmann Samplers for the Random Generation of Combinatorial Structures

- Mathematics, Computer ScienceCombinatorics, Probability and Computing
- 2004

A surprisingly simple framework for the random generation of combinatorial configurations based on what the authors call Boltzmann models is proposed, which can be implemented easily, be analysed mathematically with great precision, and, when suitably tuned, tend to be very efficient in practice.

### Interval algorithm for random number generation

- Computer ScienceIEEE Trans. Inf. Theory
- 1997

An efficient and very simple algorithm based on the successive refinement of partitions of the unit interval (0, 1), which is called the interval algorithm, is proposed and a fairly tight evaluation on the efficiency is given.

### Sample-based non-uniform random variate generation

- MathematicsWSC '86
- 1986

Several issues related to the problem or generating a new sample of lid random variables with almost the same density are discussed, including sample independence, consistency, sample indistinguishability, moment matching and generator efficiency.

### A new random-number generator for multispin Monte Carlo algorithms

- Computer Science
- 1987

A novel multispin coded random number generator algorithm to compute bits equal to 1 with probabilityp that is at least equally fast and allows for an arbitrary accuracy of the computed probability without any significant increase in time.

### A Calculus for the Random Generation of Labelled Combinatorial Structures

- Computer Science, MathematicsTheor. Comput. Sci.
- 1994

### Non-Uniform Random Variate Generation

- Computer Science, Mathematics
- 1986

This chapter reviews the main methods for generating random variables, vectors and processes in non-uniform random variate generation, and provides information on the expected time complexity of various algorithms before addressing modern topics such as indirectly specified distributions, random processes, and Markov chain methods.

### On Buffon machines and numbers

- Mathematics, Computer ScienceSODA '11
- 2011

This work provides human-accessible Buffon machines, which require a dozen coin flips or less, on average, and produces experiments whose probabilities of success are expressible in terms of numbers such as π, exp(−1), log2, √3, cos(1/4), ζ(5).

### An Efficient Method for Weighted Sampling Without Replacement

- MathematicsSIAM J. Comput.
- 1980

An efficient method for weighted sampling of K objects without replacement from a population of n objects is proposed, which requires fewer additions and comparisons than the method proposed by Fagin and Price.