# Algorithms for Almost-Uniform Generation with an Unbiased Binary Source

Conference paper

First Online:

## Abstract

We consider the problem of uniform generation of random integers in the range [1, *n*] given only a binary source of randomness. Standard models of randomized algorithms (e.g. probabilistic Turing machines) assume the availability of a random binary source that can generate independent random bits in unit time with uniform probability. This makes the task trivial if *n* is a power of 2. However, exact uniform generation algorithms with bounded run time do not exist if *n* is not a power of 2.

We analyze several
This rate of convergence is superior to the estimates obtainable by commonly used methods of bounding the mixing rate of Markov chains such as conductance, direct canonical paths, and couplings.

*almost-uniform*generation algorithms and discuss the tradeoff between the distance of the generated distribution from the uniform distribution, and the number of operations required per random number generated. In particular, we present a new algorithm which is based on a circulant, symmetric, rapidly mixing Markov chain. For a given positive integer*N*, the algorithm produces an integer*i*in the range [1,*n*] with probability*p*_{i}=*p*_{i}(*N*) using*O*(*N*log*n*) bit operations such that |*p*_{i}− 1/*n*| <*c*β^{N}, for some constant*c*, where$$
\beta = \frac{{2^{\frac{1}
{4}} }}
{\pi }\left( {\sqrt {2\sqrt 2 - \sqrt {5 - \sqrt 5 } } } \right) \approx 0.4087.
$$

## Keywords

Random number generation uniform distribution Markov chain rapid mixing eigenvalue circulant matrix## Preview

Unable to display preview. Download preview PDF.

## References

- 1.A. Aho, J. Hopcroft, and J. Ullman.
*Design and Analysis of Computer Algorithms*. Addison-Wesley Publishing Company, 1974.Google Scholar - 2.D. Aldous. Random walks on finite groups and rapidly mixing Markov chains. In
*Séminaire de Probabilités XVII*, Lecture Notes in Mathematics 986, pages 243–297. Springer-Verlag, 1982.Google Scholar - 3.N. Alon and Y. Roichman. Random Cayley graphs and expanders, 1996. Manuscript.Google Scholar
- 4.N. Biggs.
*Algebraic Graph Theory*, page 16. Cambridge University Press, 1974.Google Scholar - 5.R. Bubley, M. Dyer, and C. Greenhill. Beating the 2
*Δ*bound for approximately counting colourings: A computer-assisted proof of rapid mixing. In*Proceedings of the Ninth Annual ACM-SIAM Symposium on Discrete Algorithms*, San Francisco, California, 1998.Google Scholar - 6.E. Çınlar.
*Introduction to Stochastic Processes*. Prentice-Hall Inc., 1975.Google Scholar - 7.P.J. Davis.
*Circulant matrices*. Wiley, 1979.Google Scholar - 8.P. Diaconis and D. Strook. Geometric bounds for eigenvalues of Markov chains.
*Annals of Applied Probability*, 1:36–61, 1991.zbMATHMathSciNetCrossRefGoogle Scholar - 9.Ö. Eğecioğlu and M. Peinado. Algorithms for Almost-uniform Generation with an Unbiased Binary Source. Technical Report TRCS98-04, University of California at Santa Barbara, 1998, (http://www.cs.ucsb.edu/TRs/).
- 10.L. Goldschlager, E.W. Mayr, and J. Ullman. Theory of parallel computation. Unpublished Notes, 1989.Google Scholar
- 11.I.S. Gradshteyn and I.M. Ryzhik.
*Table of Integrals, Series, and Products*, page 30. Academic Press Inc., 1980.Google Scholar - 12.M. Jerrum, L. Valiant, and V. Vazirani. Random generation of combinatorial structures from a uniform distribution.
*Theoretical Computer Science*, 43:169–188, 1986.zbMATHCrossRefMathSciNetGoogle Scholar - 13.J.G. Kemeny and J.L. Snell.
*Finite Markov Chains*. Springer-Verlag, 1976.Google Scholar - 14.R. Motwani. Lecture notes on approximation algorithms. Technical report, Stanford University, 1994.Google Scholar
- 15.M. Peinado. Random generation of embedded graphs and an extension to Dobrushin uniqueness. In
*Proceedings of the 30th Annual ACM Symposium on Theory of Computing (STOC’98)*, Dallas, Texas, 1998.Google Scholar - 16.A. Schönhage and V. Strassen. “Schnelle Multiplikation großer Zahlen”,
*Computing*, No. 7 (1971), 281–292.zbMATHCrossRefGoogle Scholar - 17.A. Sinclair. Improved bounds for mixing rates of Markov chains and multicommodity flow.
*Combinatorics, Probability & Computing*, 1:351–370, 1992.zbMATHMathSciNetGoogle Scholar - 18.A. Sinclair.
*Algorithms For Random Generation And Counting*. Progress In Theoretical Computer Science. Birkhauser, Boston, 1993.Google Scholar

## Copyright information

© Springer-Verlag Berlin Heidelberg 1998