Memoized random number generation

Latest on Hackage:0.0.3

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow to host generated Haddocks.

MIT licensed and maintained by Johan Kiviniemi



A library for generating random numbers in a memoized manner. Implemented as a lazy table indexed by serialized StdGen. Monomorphism is used to facilitate memoization, users should adapt their design to work with random Int values only.

In a benchmark, the initial generation of 100000 random Ints took 10.30 seconds and consumed 2.5 gigabytes of memory. Generating the 100000 Ints again from the same seed only took 2.06 seconds, a 5-fold speedup thanks to memoization!

Incidentally, generating the 100000 Ints with the non-memoized function took 0.12 seconds, but that of course lacks all the benefits of memoization.


0.0.3 (2015-05-16)

  • Rename System.Random.MemoRandom as System.Random.Memoized.
  • Re-export System.Random from System.Random.Memoized.
  • Add benchmarking results to the documentation.

0.0.2 (2015-05-15)

  • Implement memoized randomRs', randoms', randomRIO', randomIO'.

0.0.1 (2015-05-14)

  • Initial release.
Depends on 3 packages:
Used by 1 package:
comments powered byDisqus