Skip to content
Tiny Mersenne Twister (TinyMT) for Erlang
Erlang Elixir Makefile Awk
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

tinymt-erlang: Tiny Mersenne Twister (TinyMT) for Erlang

  • Release date: 10-SEP-2012
  • Edited and written by Kenji Rikitake (Kyoto University)
  • Email contact:

Copyright (c) 2012 Kenji Rikitake and Kyoto University. All rights reserved.

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

See LICENSE.txt for the license (new/simplified BSD license). (Note: license of rebar is Apache 2.0 License.)

This software is based on Tiny Mersenne Twister (TinyMT) Version 1.0.1 by Mutsuo Saito (Hiroshima University) and Makoto Matsumoto (The University of Tokyo).

Details of TinyMT algorithm


  • Minimal NIF functions added as tinymt32_nif.
  • List output version of uniform_s as uniform_s_list/{2,3} added to NIFs.


  • In versions released previously before 31-MAY-2012 (inclusive), seed0/0 had a wrong value in the #status2 member of the record which exceeded the limit of 2^32. This has been fixed by the corresponding 32-bit value.

  • tinymt32_nif.el and tinymt32_nif_tests.erl will cause compilation errors when building with HiPE options in rebar.config; move the source files out of the src/ directory when testing HiPE.

On execution speed

  • The HiPE version is about two to three times faster than non-HiPE-non-NIF version, measured in overall execution time, on x86_64/amd64 architectures. (see test-scripts/testspeed.escript) If you need a fast execution, compile with the HiPE option. (see rebar.config)

  • The non-HiPE-non-NIF version is about six times slower than random module on x86_64/amd64, measured by fprof. This is presumably due to increased computational complexity of the algorithm.

  • The NIF version is about six times faster than non-HiPE-non-NIF version on x86_64/amd64, measured by fprof. The bottleneck is presumably function calls and memory allocation themselves than the computational work for TinyMT internal state recursion.

  • The list generation NIF functions uniform_n_list/{2,3} is about six to seven times faster than non-list NIFs on wall clock, and by fprof they are about 13 times faster. Use these functions for generating a long (length >= 100) list of random numbers.

Tested platforms

  • FreeBSD/amd64 9.0-STABLE with Erlang/OTP R15B01
  • FreeBSD/i386 8.3-RELEASE with Erlang/OTP R15B01
  • Windows 7 64bit with Erlang/OTP R15B01 (no rebar support)
  • Ubuntu Linux 12.04 with Erlang/OTP R15B01
  • RedHat Enterprise Linux 6 with Erlang/OTP R15B01


  • Use BSD/GNU make and then


The build script is Basho's rebar at, which will be automatically fetched under the directory support/.

Unit testing

  • Use BSD/GNU make and then

    make eunit


  • Splitting NIFs from the main module
    • List-generation functions only?
  • More documentation and code
  • More evaluation and refactoring

Code authors

  • Kenji Rikitake
  • Mutsuo Saito
  • Makoto Matsumoto


  • Dave "dizzyd" Smith
  • Tuncer Ayaz
  • Ryosuke "Voluntas" Nakai


  • Kenji Rikitake used the supercomputer service provided by Academic Center for Computing and Media Studies (ACCMS), Kyoto University, for testing this program and fundamental studies of TinyMT generation parameters.

  • Kenji Rikitake thanks the Program Committee of ACM Erlang Workshop 2012 to give him a chance to present this work as a Practice and Application paper.

Something went wrong with that request. Please try again.