Algorithms for Almost-Uniform Generation with an Unbiased Binary Source

  • Ömer Eğecioğlu
  • Marcus Peinado
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 1449)


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 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. $$
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.


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


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    A. Aho, J. Hopcroft, and J. Ullman. Design and Analysis of Computer Algorithms. Addison-Wesley Publishing Company, 1974.Google Scholar
  2. 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. 3.
    N. Alon and Y. Roichman. Random Cayley graphs and expanders, 1996. Manuscript.Google Scholar
  4. 4.
    N. Biggs. Algebraic Graph Theory, page 16. Cambridge University Press, 1974.Google Scholar
  5. 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. 6.
    E. Çınlar. Introduction to Stochastic Processes. Prentice-Hall Inc., 1975.Google Scholar
  7. 7.
    P.J. Davis. Circulant matrices. Wiley, 1979.Google Scholar
  8. 8.
    P. Diaconis and D. Strook. Geometric bounds for eigenvalues of Markov chains. Annals of Applied Probability, 1:36–61, 1991.zbMATHMathSciNetCrossRefGoogle Scholar
  9. 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, (
  10. 10.
    L. Goldschlager, E.W. Mayr, and J. Ullman. Theory of parallel computation. Unpublished Notes, 1989.Google Scholar
  11. 11.
    I.S. Gradshteyn and I.M. Ryzhik. Table of Integrals, Series, and Products, page 30. Academic Press Inc., 1980.Google Scholar
  12. 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. 13.
    J.G. Kemeny and J.L. Snell. Finite Markov Chains. Springer-Verlag, 1976.Google Scholar
  14. 14.
    R. Motwani. Lecture notes on approximation algorithms. Technical report, Stanford University, 1994.Google Scholar
  15. 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. 16.
    A. Schönhage and V. Strassen. “Schnelle Multiplikation großer Zahlen”, Computing, No. 7 (1971), 281–292.zbMATHCrossRefGoogle Scholar
  17. 17.
    A. Sinclair. Improved bounds for mixing rates of Markov chains and multicommodity flow. Combinatorics, Probability & Computing, 1:351–370, 1992.zbMATHMathSciNetGoogle Scholar
  18. 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

Authors and Affiliations

  • Ömer Eğecioğlu
    • 1
  • Marcus Peinado
    • 2
  1. 1.Department of Computer ScienceUniversity of CaliforniaSanta BarbaraUSA
  2. 2.Institute for Algorithms and Scientific ConputingGMD National Research CenterSankt AugustinGermany

Personalised recommendations