What is AdaMT19937?

UPDATE June 11, 2012: This project is now hosted at GitHub.

AdaMT19937 is an Ada implementation of Mersenne Twister (MT19937) pseudo random number generator. MT19937 was originally proposed and implemented in C by Makoto Matsumoto and Takuji Nishimura. You can find their paper and other resources about MT19937 at this url:

AdaMT19937 implements the latest Makoto’s revision (2002/1/26). This revision has improved initialization using array of keys and also allows zero as seed. AdaMT19937 follows the standards of the GNAT Run-Time Component Package Ada.Numerics.Float_Random (a-nuflra.adb) as close as possible. Many other features are also included. For example:

  1. Reset the generator by using system time which contains Ada code adapted from a-nuflra.adb.
  2. Reset by saved generator.
  3. Reset by saved generator string.
  4. Restart the generator to initial state.
  5. AdaMT19937.Random_Float to generate Uniformly_Distributed float random numbers.

AdaMT19937 was originally released with GNU General Public License (GPL). This latest AdaMT19937 is released under GMGPL (GNAT-Modified GPL). Makoto and Takuji has released their work under Artistic License for commercial use. Please refer to their web site.

Why AdaMT19937

I need an uniform PRNG (Pseudo Random Number Generator) which has larger period and more dimensional equidistribution property for my research in solving traveling salesmen problem using simulated annealing techniques. MT19937 has both the period of 2**19937 – 1 and 623-dimensional equidistribution property. My research is to enhance problem-solving in my company latest software, ERP (Enterprise Resource Planning) for Furniture Industries.

I also use AdaMT19937 in my gadasl (GNU Ada Scientific Library) project which supports the ERP software.


If you find AdaMT19937 useful in your project, please e-mail Makoto about your use and it certainly would be nice if you cc your message to me. The source was developed on Linux with GNAT 3.13p. It should work on other platforms as well. Latest version is 1.2

[Download AdaMT19937 source]


History Log

  • Mar 8, 2002 – In version 1.2, a new child package AdaMT19937.Integer_Utilities has been added. Function Random_Short_Integer returns positive short_integer and function Random_4_Digit returns positive short_integer within 0 and 9999. The overloaded function Random return Long_Integer in main package has been moved to this new package and has been renamed to Random_Long_Integer. Child package AdaMT19937.Random_Float has been renamed to AdaMT19937.Float_Utilities.
  • Mar 7, 2002 – Version 1.1 has subtype Uniformly_Distributed moved from the main package ( to child package (AdaMT19937.Random_Float). The version number in Gen_Tag string has been removed in order to maintain compatibility when version number is incremented. The original Matsumoto’s C source (mt19937ar.c) is also included for verification of correctness of AdaMT19937 as requested by post in CLA. See README for details.
  • Mar 1, 2002 – Version 1.0 (AdaMT19937-1.0-2002-1-26) is a nice package of improved version of the Feb 5 release. This package follows closely the Ada.Numeric.Float_Random package ( Several initialization and reset features including time seed (code is adapted from a-nuflra.adb) are added. This release allows multiple generators. The package is released with GNAT-Modified GPL (GMGPL) license.
  • Feb 5, 2002 – This is an Ada implementation of Matsumoto’s 2002/1/26 revision with initialization improved intialization. Generator is initialized with an array of keys and allows zero for seed. This is a simple implementation and is released with GPL license.
  • Jan 28, 2002 – This is an Ada implementation of Matsumoto’s old generator (before Jan 26, 2002 revision). The Ada package is a simple implementation and is released with GPL license.

Leave a Reply