"The generation of random numbers is too important to be left to chance." – Robert R. Coveyou
An alternate random number generator built around four principles:
Statistical Quality. If you use any seed less than 53,668 and generate one bool, it will be
True – if you're
Random module. More sophisticated statistical tests spot patterns in the "random" numbers almost
immediately. Would you want to trust the accuracy of your fuzz
tests to such a flawed algorithm? This library
produces far less predictable and biased output, especially if you use thousands of random numbers. See
test/dieharder for more details.
Useful features. This library exports
andMap, which are conspicuously absent from core, along
with other helpful functions for composing generators. Particularly interesting is
independentSeed, which allows for
lazy lists and isolated components to generate as much randomness as they need, when they need it.
Performance. This library will generate floats about 3.5 times faster than core, and ints do not regress. These figures stand to improve pending some optimizations to the compiler. You can see the full benchmark results.
Compatibility. This library is a drop-in replacement for core's Random module. Specifically, you
import Random with
import Random.Pcg as Random and everything will continue to work. (The one exception is third party
libraries like elm-random-extra.)
This is an implementation of PCG by M. E. O'Neil. The generator is not cryptographically secure.
Please report bugs, feature requests, and other issues on GitHub.
initialSeed2, since there are now only 32 bits of state.
Random.Pcg.Interop.fissionhas been changed to a (core) generator of (PCG) seeds.
generateto match core 4.x API. Implemented by Richard Feldman.
stepto match core 4.x API.
splithas been removed; use
maxIntvalues changed to match core.