Optimal Discrete Uniform Generation from Coin Flips, and Applications
Abstract
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 perspectiveallowing for faster and more efficient MonteCarlo 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 extensions and applications, in particular to the optimal random generation of permutations.
 Publication:

arXiv eprints
 Pub Date:
 April 2013
 arXiv:
 arXiv:1304.1916
 Bibcode:
 2013arXiv1304.1916L
 Keywords:

 Computer Science  Data Structures and Algorithms;
 Mathematics  Probability;
 Physics  Computational Physics;
 Physics  Data Analysis;
 Statistics and Probability
 EPrint:
 first draft, 22 pages, 5 figures, C code implementation of algorithm