"Mersenne Twister with improved initialization" (2002): another bug in mt19937ar.f90

Paul C. Leopardi leopardi@physics.usyd.edu.au
Fri Dec 1 04:11:00 GMT 2006

To Makoto Matsumoto, Josi Rui Faustino de Sousa, gsl-discuss mailing list.

Hi all,
Further to my recent message, I have discovered another bug in mt19937ar.f90 

In mt19937ar.f90 (2002), in subroutine init_genrand, the value of mti should 
be reinitialized to n + 1_wi, but this is not done. The fix is to add the 
    mti = n + 1_wi
immdiately before 
    end subroutine init_genrand.

The other implementations, mt19937ar.c (2002), GSL 1.8 and mt95.f90 (2003) do 
not have the bug seen here in mt19937ar.f90 (2002).

In mt19937ar.c (2002), in function init_genrand, mti is set to N when the for 
loop completes.

In GSL 1.8, in function mt_set of in mt.c, the statement
state->mti = i;
correctly reinitializes state->mti.

In mt95.f90 (2003), in subroutine init_by_scalar, the statement
state%cnt = n + 1_wi
correctly reinitializes state%cnt.

Best, Paul

On Wednesday 29 November 2006 13:31, Paul C. Leopardi wrote:
> To Makoto Matsumoto, Josi Rui Faustino de Sousa, gsl-discuss mailing list.
> Hi all,
> The purpose of this email message is to document the different default
> seeds used by some of the different implementations of "Mersenne Twister
> with improved initialization" (2002).
> In summary, the value used by the original authors is 5489UL. GSL 1.8 uses
> the obsolete value 4357. Josi Rui Faustino de Sousa's mt19937ar.f90 uses
> the incorrect value 21641. This is fixed in mt95.f90. See details below.
> Some suggestions for various authors:
> 1. Document the reason for changing the default seed of mt19937ar.c from
> 4357 to 5489UL.
> 2. Update mt.c GSL to use the value 5489UL rather than 4357.
> 3. Document the default seed bug in mt19937ar.f90 (2002).
> 4. Update the web page "Mersenne Twister in FORTRAN"
> to note the bug in mt19937ar.f90 (2002) and to list mt95.f90 (2003). 

More information about the Gsl-discuss mailing list