Tiny Mersenne Twister

READ ME FIRST

There are two kinds of programs in this archive file. One is TinyMT and another is TinyMTDC. TinyMT is a pseudorandom number generator, while TinyMTDC is a parameter-set generator for TinyMT.

TinyMT

TinyMT is a small-sized pseudorandom number generator, compared with Mersenne Twister or WELL RNG. tinymt32 uses 16 bytes for its internal state vector and 12 bytes for its parameters, and tinymt64 uses 16 bytes for its internal state vector and 16 bytes for its parameters. Pseudorandom number sequences generated by TinyMT has a period of 2127-1.

Requirement

TinyMT is written in C language, and it uses stdint.h and inttypes.h of c99.

Compile and check

  1. cd tinymt
  2. make all
  3. Executable file check32 and check64 are made
  4. To check these programs:
    check32 8f7011ee fc78ff1f 3793fdff > tmp32.txt
    diff tmp32.txt check32.out.txt
    check64 fa051f40 ffd0fff4 58d02ffeffbfffbc > tmp64.txt
    diff tmp64.txt check64.out.txt
    O.K. if diff does not show differences

TinyMTDC

TinyMTDC is a parameter generator for TinyMT. A user specifies an ID and the number of sets of parameters to be generated. TinyMTDC can generate more than 216 distinct set of parameters (with ID embedded) to be used as parameters in TinyMT.

Required Library

TinyMTDC is written in C++ language using template features.

Compile

  1. change directory to dc/src
  2. make all
  3. tinymt32dc, tinymt64dc and getid are created

Programs and usage

tinymt32dc [-v] [-c count] [-s seed_string] [-f outputfile] ID
tinymt64dc [-v] [-c count] [-s seed_string] [-f outputfile] ID
These two programs create parameter sets for tinymt32 and tinymt64.
getid -b 32|64 mat1 mat2
getid -b 32|64 -r id seq
This program calculates the ID and the internal counter from parameter sets of TinyMTDC. -b option is used to distinguish parameters for tinymt32 or tinymt64. If omitted -b 32 is assumed. When -r is specified, conversely, the program calculates the parameters mat1 and mat2 from the ID and the internal counter.
This program may be used to resume parameter-set generation: from the last (mat1, mat2) generated by TinyMTDC, getid computes the corresponding (ID, seq). Then TinyMTDC with -s option for the value (seq-1) will resume the previous parameter-set generation, as follows.
$ tail -1 tinymt32dc.0.20.txt
9443129baa73b98c7b097ab82c074d03,32,0,65980cb3,eb38facf, cc3b75ff,59,0
$ ./getid 65980cb3 eb38facf
id:0(0x0)
seq:2147482983(0x7ffffd67)
$ ./tinymt32dc -s 2147482983 0
# charactristic, type, id, mat1, mat2, tmat, weight, delta
9443129baa73b98c7b097ab82c074d03,32,0,65980cb3,eb38facf,cc3b75ff,59,0

output format of TinyMTDC

output of TinyMTDC is Comma Separated Value. Here we explain each column.

Column or RowDescription
The first row
# charactristic, type, id, mat1, mat2, tmat1, weight, delta
The first row is always the same as above. Each column of the row shows title of columns of following rows.
1st column: charactristic The first column shows the characteristic polynomial of the state transition function. In TinyMT's case, the characteristic polynomial is an irreducible polynomial of degree 127, and its coefficients are 0 or 1. The corresponding hexadecimal number to the coefficients of the polynomial (by descending order, i.e. the constant term comes as LSB) is shown. The first digit of the hexadecimal number is greater than or equals to 8, because its degree is 127, and the last hexadecimal number is odd, because irreducible polynomial (over F2) has constant term 1.
2nd column: type The second column shows whether this parameter set is for tinymt32 or tinymt64.
3rd column: id Third column is the ID specified by user, in command line.
4th column: mat1 The fourth column shows mat1 parameter in the hexadecimal notation.
5th column: mat2 The fifth column shows mat2 parameter in the hexadecimal notation. The parameters mat1 and mat2 determine the state transition function of the generator.
6th column: tmat The sixth column shows tmat parameter in the hexadecimal notation. The parameter tmat determines the output function of the generator.
7th column: weight The seventh column shows Hamming weight of the characteristic polynomial. A thumb-nail rule says that the weight value not far from half of the degree of the characteristic polynomial is preferable.
8th column: delta The eighth column shows the total dimension defect, which measures the gap from the theoretical upper bounds on the dimensions of equidistribution. 0 is the best. TinyMTDC selects the parameter tmat for which delta is small.

LICENSE

Copyright (c) 2011 Mutsuo Saito, Makoto Matsumoto, Hiroshima
University and The University of Tokyo. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above
      copyright notice, this list of conditions and the following
      disclaimer in the documentation and/or other materials provided
      with the distribution.
    * Neither the name of the Hiroshima University nor the names of
      its contributors may be used to endorse or promote products
      derived from this software without specific prior written
      permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.