skip to main content
research-article

Sampling Exactly from the Normal Distribution

Published:29 January 2016Publication History
Skip Abstract Section

Abstract

An algorithm for sampling exactly from the normal distribution is given. The algorithm 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. Thereafter, uniform random digits are copied directly into the representation of the normal deviate. Thus, in contrast to existing methods, it is possible to generate normal deviates exactly rounded to any precision with a mean cost that scales linearly in the precision. The method performs no extended precision arithmetic, calls no transcendental functions, and uses no floating point arithmetic whatsoever; it uses only simple integer operations. It can easily be adapted to sample exactly from the discrete normal distribution whose parameters are rational numbers.

References

  1. Milton Abramowitz and Irene A. Stegun. 1964. Handbook of Mathematical Functions. National Bureau of Standards, Washington, DC. Retrieved December 29, 2015 from http://www.cs.bham.ac.uk/∼aps/research/projects/asGoogle ScholarGoogle Scholar
  2. Joachim H. L. Ahrens and Ulrich O. Dieter. 1973. Extensions of Forsythe's method for random sampling from the normal distribution. Mathematics of Computation 27, 124, 927--937. DOI:http://dx.doi.org/10.1090/S0025-5718-1973-0329190-8Google ScholarGoogle Scholar
  3. George E. P. Box and Mervin E. Muller. 1958. A note on the generation of random normal deviates. Annals of Mathematical Statistics 29, 2, 610--611. DOI:http://dx.doi.org/10.1214/aoms/1177706645Google ScholarGoogle ScholarCross RefCross Ref
  4. Richard P. Brent. 1974. Algorithm 488: A Gaussian pseudo-random number generator. Communications of the ACM 17, 12, 704--706. DOI:http://dx.doi.org/10.1145/361604.361629 Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Nagarjun C. Dwarakanath and Steven D. Galbraith. 2014. Sampling from discrete Gaussians for lattice-based cryptography on a constrained device. Applicable Algebra in Engineering, Communication and Computing 25, 3, 159--180. DOI:http://dx.doi.org/10.1007/s00200-014-0218-3 Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Philippe Flajolet, Maryse Pelletier, and Michèle Soria. 2011. On Buffon machines and numbers. In Proceedings of the 22nd ACM-SIAM Symposium on Discrete Algorithms, Dana Randall (Ed.). SIAM Publications, Philadelphia, PA, 172--183. http://arxiv.org/abs/0906.5560v2 Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Phillippe Flajolet and Nasser Saheb. 1986. The complexity of generating an exponentially distributed variate. Journal of Algorithms 7, 4, 463--488. DOI:http://dx.doi.org/10.1016/0196-6774(86)90014-3 Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. George E. Forsythe. 1972. Von Neumann's comparison method for random sampling from the normal and other distributions. Mathematics of Computation 26, 120, 817--826. DOI:http://dx.doi.org/10.1090/S0025-5718-1972-0315863-9Google ScholarGoogle Scholar
  9. Laurent Fousse, Guillaume Hanrot, Vincent Lefèvre, Patrick Pélissier, and Paul Zimmermann. 2007. MPFR: A multiple-precision binary floating-point library with correct rounding. ACM Transactions on Mathematical Software 33, 2, 13:1--15. DOI:http://dx.doi.org/10.1145/1236463.1236468 Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Herman Kahn. 1956. Applications of Monte Carlo. Technical Report RM-1237-AEC. RAND Corp., Santa Monica, CA. Retrieved December 29, 2015 from http://www.rand.org/pubs/research_memoranda/RM1237.html.Google ScholarGoogle Scholar
  11. Adrienne W. Kemp. 1997. Characterizations of a discrete normal distribution. Journal of Statistical Planning and Inference 63, 2, 223--229. DOI:http://dx.doi.org/10.1016/S0378-3758(97)00020-7Google ScholarGoogle ScholarCross RefCross Ref
  12. Albert J. Kinderman and John F. Monahan. 1977. Computer generation of random variables using the ratio of uniform deviates. ACM Transactions on Mathematical Software 3, 3, 257--260. DOI:http://dx.doi.org/10.1145/355744.355750 Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Donald E. Knuth. 1998. The Art of Computer Programming (3rd ed.). Vol. 2. Addison-Wesley, Reading, MA.Google ScholarGoogle Scholar
  14. Donald E. Knuth and Andrew C. Yao. 1976. The complexity of nonuniform random number generation. In Algorithms and Complexity, Joseph F. Traub (Ed.). Academic Press, New York, 357--428.Google ScholarGoogle Scholar
  15. Jérémie Lumbroso. 2013. Optimal Discrete Uniform Generation from Coin Flips, and Applications. Technical Report. LIP6. http://arxiv.org/abs/1304.1916v1Google ScholarGoogle Scholar
  16. George Marsaglia and Wai Wan Tsang. 2000. The ziggurat method for generating random variables. Journal of Statistical Software 5, 8, 1--7. DOI:http://dx.doi.org/10.18637/jss.v005.i08Google ScholarGoogle ScholarCross RefCross Ref
  17. Makoto Matsumoto and Takuji Nishimura. 1998. Mersenne twister: A 623-dimensionally equidistributed uniform pseudo-random number generator. ACM Transactions on Modeling and Computer Simulation 8, 1, 3--30. DOI:http://dx.doi.org/10.1145/272991.272995 Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. John F. Monahan. 1979. Extensions of von Neumann's method for generating random variables. Mathematics of Computation 33, 147, 1065--1069. DOI:http://dx.doi.org/10.1090/S0025-5718-1979-0528058-7Google ScholarGoogle Scholar
  19. John F. Monahan. 1985. Accuracy in random number generation. Mathematics of Computation 45, 172, 559--568. DOI:http://dx.doi.org/10.1090/S0025-5718-1985-0804945-XGoogle ScholarGoogle Scholar
  20. MPFR. 2016. The GNU MPFR library, Version 3.2.0. http://www.mpfr.orgGoogle ScholarGoogle Scholar
  21. RAND Corporation. 1955. A Million Random Digits with 100,000 Normal Deviates. The Free Press, Glencoe, IL. http://www.rand.org/pubs/monograph_reports/MR1418.htmlGoogle ScholarGoogle Scholar
  22. Oded Regev. 2009. On lattices, learning with errors, random linear codes, and cryptography. Journal of the ACM 56, 6, 34:1--40. DOI:http://dx.doi.org/10.1145/1568318.1568324 Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Bjarne Stroustrup. 2013. The C++ Programming Language (4th ed.). Addison-Wesley, Upper Saddle River, NJ. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. David B. Thomas, Wayne Luk, Philip H. W. Leong, and John D. Villasenor. 2007. Gaussian random number generators. Computing Surveys 39, 4, 11:1--38. DOI:http://dx.doi.org/10.1145/1287620.1287622Google ScholarGoogle Scholar
  25. John von Neumann. 1951. Various techniques used in connection with random digits. In Monte Carlo Method, Alston S. Householder, George E. Forsythe, and Hallett H. Germond (Eds.). Number 12 in Applied Mathematics Series. National Bureau of Standards, Washington, DC, 36--38. https://dornsifecms.usc.edu/assets/sites/520/docs/VonNeumann-ams12p36-38.pdfGoogle ScholarGoogle Scholar

Index Terms

  1. Sampling Exactly from the Normal Distribution

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in

    Full Access

    • Published in

      cover image ACM Transactions on Mathematical Software
      ACM Transactions on Mathematical Software  Volume 42, Issue 1
      February 2016
      181 pages
      ISSN:0098-3500
      EISSN:1557-7295
      DOI:10.1145/2888419
      Issue’s Table of Contents

      Copyright © 2016 ACM

      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 29 January 2016
      • Accepted: 1 December 2014
      • Revised: 1 June 2014
      • Received: 1 March 2013
      Published in toms Volume 42, Issue 1

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Qualifiers

      • research-article
      • Research
      • Refereed

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader