Skip to content
Huon Wilson edited this page May 15, 2013 · 31 revisions

Generating random numbers, and sampling from random distributions.

1. Announcement to mailing list

  • Proposed editor: Huon Wilson (@huonw)
  • Date proposed: date of proposal
  • Link: link to email

Notes from discussion on mailing list

2. Research of standards and techniques

  1. Standard: standard - link to docs - ...

  2. Standard: standard - link to docs - ...

  3. Technique: Generating random bits/numbers (i.e u32 or u64) - http://en.wikipedia.org/wiki/List_of_random_number_generators - http://en.wikipedia.org/wiki/Cryptographically_secure_pseudorandom_number_generator - ISAAC/ISAAC-64 RNG

  4. Technique: Testing quality of random numbers - Very important! Extremely hard to tell if random numbers are "random enough" (a bug in an implementation, or a bad algorithm, can produce numbers that look random but aren't random enough for many purposes). - Overview wikipedia article - Diehard tests (e.g. dieharder) - TestU01 including "Small crush", "Crush" and "Big crush" - tests written by the creator of ISAAC - ENT - NIST - Add a new make target "check-rngs" with a testsuite?

  5. Technique: sampling from distributions - Converting ints to floats:

Summary of research on standards and leading techniques

Relevant standards and techniques exist?

Those intended to follow (and why)

Those intended to ignore (and why)

3. Research of libraries from other languages

  1. Language: C++11 - http://www.cplusplus.com/reference/random/
  2. Language: Python - http://docs.python.org/3.3/library/random.html
  3. Language: R (statistical language, so much broader random number support than necessary) - http://stat.ethz.ch/R-manual/R-patched/library/base/html/Random.html - http://stat.ethz.ch/R-manual/R-patched/library/stats/html/Distributions.html - Parallel random numbers (section 6): http://stat.ethz.ch/R-manual/R-devel/library/parallel/doc/parallel.pdf
  4. Language: Julia (also a statistical language) - https://github.com/JuliaStats/Distributions.jl
  5. Language: D - http://dlang.org/phobos/std_random.html (no support for sampling from distributions other than uniform, but many RNGs)
  6. Language: Go - http://golang.org/pkg/math/rand/
  7. Language: Erlang - https://mail.mozilla.org/pipermail/rust-dev/2013-April/003881.html
  8. Library: GSL - https://www.gnu.org/software/gsl/manual/html_node/Random-Number-Generation.html - https://www.gnu.org/software/gsl/manual/html_node/Random-Number-Distributions.html
  9. Library: Numpy/Scipy - http://docs.scipy.org/doc/numpy/reference/routines.random.html - http://docs.scipy.org/doc/scipy/reference/stats.html
  10. Library: Boost - http://www.boost.org/doc/libs/1_53_0/doc/html/boost_random/reference.html
  11. Library: RandomKit
  12. Library: Tina's Random Number Generator Library - Includes many distributions, also support for/discussion about parallel RNGs.
  13. Misc: - http://tommd.github.io/posts/RNG-Bench.html - http://hackage.haskell.org/package/crypto-api (An example of a generic interface for cryptographic things, not in the scope of lib-rand, but it'd be good to not make things hard to fit into an api like this.)

Summary of research from other languages:

Structures and functions commonly appearing

Distributions:

Very common/important:

  • Normal
  • Exponential
  • Uniform (discrete and continuous)
  • Gamma (many distributions are special cases/functions of this, e.g. Chi^2, F, t, beta, even uniform.)

Variations on implementation seen

Pitfalls and hazards associated with each variant

Relationship to other libraries and/or abstract interfaces

4. Module writing

Additional implementation notes

  • Rng should take &mut self, instead of forcing the use of mutable fields
  • Generating many random numbers at once: methods that fill vectors, or iterators?
  • note

All Categories:

Clone this wiki locally