From: "Paul C. Leopardi" <leopardi@physics.usyd.edu.au>
To: m-mat@math.sci.hiroshima-u.ac.jp, jrfsousa@esoterica.pt,
gsl-discuss@sourceware.org
Subject: "Mersenne Twister with improved initialization" (2002): default seed varies in different implementations
Date: Wed, 29 Nov 2006 02:32:00 -0000 [thread overview]
Message-ID: <200611291331.56193.leopardi@physics.usyd.edu.au> (raw)
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"
http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/VERSIONS/FORTRAN/fortran.html
to note the bug in mt19937ar.f90 (2002) and to list mt95.f90 (2003).
Best regards, Paul
Details:
GSL 1.8:
Function mt_set in gsl-1.8/rng/mt.c contains the code:
if (s == 0)
s = 4357; /* the default seed is 4357 */
The value 4357 is the default seed used in the 1998 version
http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/VERSIONS/C-LANG/980409/mt19937int.c
and the 1999 version
http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/VERSIONS/C-LANG/991029/mt19937int.c
but not in mt19937ar.c (2002).
mt19937ar (2002):
Function genrand_int32 in
http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/CODES/mt19937ar.c
contains the code:
if (mti == N+1) /* if init_genrand() has not been called, */
init_genrand(5489UL); /* a default initial seed is used */
Also, calling function init_genrand(s) with s == 0UL will use an initial seed
value of 0 rather than 5489UL or 4357.
mt19937ar.f90 (2002):
Function genrand_int32 in
http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/VERSIONS/FORTRAN/mt19937ar.f90
contains the code:
data seed_d /z'5489'/
! ...
if ( mti > n ) then ! generate N words at one time
if ( .not. mtinit ) call init_genrand( seed_d )
! if init_genrand() has not been called, a default initial seed is used
Here Josi Rui Faustino de Sousa has apparently made an error by using hex
instead of decimal, resulting in the default seed being 0x5489 == 21641
rather than 5489UL as used in mt19937ar.c (2002).
Also, calling subroutine init_genrand(s) with s == 0UL will use an initial
seed value of 0 rather than 0x5489 or 5489UL or 4357.
mt95.f90 (2003):
The web page "Mersenne Twister in FORTRAN"
http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/VERSIONS/FORTRAN/fortran.html
lists mt19937ar.f90 (2002) but does not list mt95.f90 (2003) which can be
found at http://homepage.esoterica.pt/~jrfsousa/files/mt95.htm
and http://homepage.esoterica.pt/~jrfsousa/files/mt95.zip
Module mt95 in mt95.f90 (2003) contains the code
integer(kind=wi), private, parameter :: default_seed = 5489_wi
so the default seed used in mt95.f90 (2003) matches the one used in
mt19937ar.c (2002). In other words, mt95.f90 (2003) fixes the default seed
bug in mt19937ar.f90 (2002).
--
Paul Leopardi, School of Physics, University of Sydney
next reply other threads:[~2006-11-29 2:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-29 2:32 Paul C. Leopardi [this message]
2006-11-29 22:51 ` Brian Gough
2006-12-01 4:11 ` "Mersenne Twister with improved initialization" (2002): another bug in mt19937ar.f90 Paul C. Leopardi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200611291331.56193.leopardi@physics.usyd.edu.au \
--to=leopardi@physics.usyd.edu.au \
--cc=gsl-discuss@sourceware.org \
--cc=jrfsousa@esoterica.pt \
--cc=m-mat@math.sci.hiroshima-u.ac.jp \
--cc=paul.leopardi@usyd.edu.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).