RandomLib is a C++ interface to the Mersenne Twister random number generator, MT19937 and to the SIMD-oriented Fast Mersenne Twister random number generator, SFMT19937. It provides convenient access to random integers and reals at a variety of precisions. RandomLib also contains new algorithms which permit exact sampling from the normal and discrete normal distributions (provided that the underlying generator is perfect). The emphasis in this implementation is on providing a reliable source of random numbers for scientific applications where there's a premium on accuracy, repeatability, portability, and ease of use. By default, this library uses SFMT's improved method for seeding the generator and it allows access to both the 32-bit and 64-bit versions of MT19937 and SFMT19937 and includes implementations of the SFMT19937 using SSE2 and AltiVec instructions.
IMPORTANT NOTE: The original motivation for this library was to provide a robust and portable library for random numbers of C++ applications. Now that C++11 is widely available, you should transition to using the
<random> header for most applications. On Linux and Mac OSX, supply the
-std=c++11 flag to the compiler. On Windows, use Visual Studio 11 (2012) and later. Exact sampling from the normal and discrete normal distributions is now available with the exrandom package which is built on the C++11 random number facilities.
The main project page is at
The code is available for download at
as either a compressed tar file (tar.gz) or a zip file. (The two archives have identical contents, except that the zip file has DOS line endings.) Alternatively you can get the latest release using git
git clone -b r1.10 git://git.code.sf.net/p/randomlib/code randomlib