Skip to content

ThomasCluzel/mt-correlation-tests

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mersenne Twister: Correlation of Sub-sequences

Motivation

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.

How do we determinate this?

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").

Description of the repository

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

How to compile

This project uses CMake to offer the largest possible compatibility.

  1. To install CMake have a look at this page https://cmake.org/download/
  2. Set current directory to the root of this project(cd path/to/folder/)
  3. Then run cmake -G "Unix Makefiles" to use linux make or cmake -G "MinGW Makefiles" to use MinGW make (if you want to use an IDE look for its generator in the list of generators)
  4. Compile the project either with the tool you are used to or by running cmake --build .
  5. Finally you can run the binary

If you are familiar with CMake, it is advised to do an out-of-source build.

How to run the unit tests

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.

How to run the statistical tests

Run the program ./prog (linux) or prog.exe (windows).

"What if I don't want to install cmake?"

"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

⚠️ It is mandatory to have an internet connection the first time you build the container because it needs to download the base image namely the one containing gcc and cmake.

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

About

ZZ2 F2 Project on the Mersenne Twister RNG

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages