#libRNG
libRNG is a public domain collection of pseudo-random number generators for C++. It provides several efficient and statistically robust generators.
- Build using
make
. - Link against individual objects, or use
build/librng.so
.
split()
returns a new generator, seeded from this
. There is no guarantee that the generators will be independent in any robust sense, but the implementations of split()
make a good faith effort to do something reasonable.
seed_with(uint32_t)
constructs a linear-congrugential generator (LCG), which is then used as the argument to seed(RNG*)
. LCGs have some bad properties: correlation between sequential outputs, and distribution of outputs in a few hyperplanes. This will be replaced with a 32-bit Xorshift generator, or a complementary multiply with carry generator.
get_geometric()
relies on __builtin_ctz
. A version of this function should be provided for users of non-GNU compilers.
The generators presented here are largely adapted from the public domain C sources in David Jones's manuscript Good
Practice in (Pseudo) Random Number Generation for Bioinformatics Applications (pdf).
The interface is inspired by Haskell's System.Random.