Is the Mersenne Twister Random Number Generator a good RNG for multi-threaded applications?
The goal of this project is to determinate if one may use Mersenne Twister in order to generate non-correlated sequences of random numbers.
We test sub-sequences generated by Mersenne Twister with inter-streams correlation tests of C. Ismay (described in his PhD thesis "Testing Independence of Parallel Pseudorandom Number Streams Incorporating the Data’s Multivariate Nature").
This repository contains:
- an external folder containing:
- a libmt folder: it contains the Mersenne Twister PRNG as a library
- a libmultivartest folder: it contains C. Ismay's correlation tests
- a mersenne_twister_states folder: it contains status of the PRNG separated by 1000 billion numbers.
- a tests folder: it contains unit tests that validate the implementation of Mersenne Twister
- files that use the tests to test the existence of correlations in sequences of Mersenne Twister
This project uses CMake to offer the largest possible compatibility.
- To install CMake have a look at this page https://cmake.org/download/
- Set current directory to the root of this project(
cd path/to/folder/
) - Then run
cmake -G "Unix Makefiles"
to use linux make orcmake -G "MinGW Makefiles"
to use MinGW make (if you want to use an IDE look for its generator in the list of generators) - Compile the project either with the tool you are used to or by running
cmake --build .
- Finally you can run the binary
If you are familiar with CMake, it is advised to do an out-of-source build.
After having compiled the project, go in the "tests" folder
(cd tests
) and run the command ctest -V
.
Take note that you may want to disable the unit test that check the gap between two status because it is very long. However you should not trust us and run the test to verify that the status are separated by enough numbers.
Run the program ./prog
(linux) or prog.exe
(windows).
"No problem", for an easier reproducibility, you can use docker. However, if you don't know anything about docker or virtualisation, you may want to compile the project yourself rather than using docker.
To compile and run the code with docker:
- Compile the code (and run the unit tests) by building the image:
docker build -t mt-correlation-tests .
- Run the statistical tests by running a container:
docker run --rm mt-correlation-tests
If you neither want to install cmake nor docker, we also provide
a singularity definition file (mt.def
) to build and run the
tests in an isolated environment.
# Create the image
sudo singularity build mt.sif mt.def
# Build
singularity exec mt.sif cmake -G "Unix Makefiles"
singularity exec mt.sif cmake --build .
# Run the statistical tests
singularity exec mt.sif ./prog
Bruno Jousse & Thomas Cluzel