Pseudo-random number generation library and tools. Part of the OneJoker project.

Project maintained by Lee Daniel Crocker
Lee's blog is etceterology.

onejoker
CC-0: To the extent possible under law, I, Lee Daniel Crocker waive all copyright and related or neighboring rights to all creative works original to me.

RandLib

This library serves two purposes: first it’s a free pseudo-random number generation library useful for gaming, simulations, Monte Carlo methods, and other work. Second, it can be used by people developing PRNGs to provide all the “filler” code needed around a PRNG algorithm: things like seed management, floating point conversions, access to hardware randomness, and so on.

Features

RandLib consists of a shared library (.so on Linux, .dll for Windows) with functions that can be linked directly into C programs, wrapper classes for C++ programs, Java classes and native methods for use by Java programs, and a Python module for use with Python 3.

RandLib currently comes with three built-in algorithms to choose from: Multiply with carry, JKISS, and Mersenne Twister. These are all state-of-the-art algorithms for many uses, and are implemented in fast low-level C code. It is expected that other algorithms will be added over time, especially for cyptographic use.

Each of these algorithms can be seeded by arrays to take advantage of the full range of random sequences available to each algorithm. Seeds can be provided by the user, or can be fetched from operating system randomness, or even from the network service random.org, which provides random bits produced from atmospheric noise.

Each of the algorithms can be used to produce random bits in various formats. You can get raw bits, uniformly-distributed integers over a given range, uniform floating point values in full double precision, and normally distributed or exponentially distributed floating point values using the fast Ziggurat algorithm.

Documentation

RandLib can be used from a pre-compiled binary, or for more flexibility you can build RandLib from source. There are APIs for C, C++, Java, and Python.

Credits and Copyrights

The library was created by Lee Daniel Crocker in 2013. To the extent possibile under law, Mr. Crocker has waived all copyright and related or neighboring rights to this work (CC0). Where the work of others has been included, this is noted, and such work may be licensed under different terms.