From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19145 invoked by alias); 29 Nov 2006 02:32:48 -0000 Received: (qmail 19130 invoked by uid 22791); 29 Nov 2006 02:32:46 -0000 X-Spam-Check-By: sourceware.org Received: from enlil.physics.usyd.edu.au (HELO enlil.physics.usyd.edu.au) (129.78.129.112) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 29 Nov 2006 02:32:41 +0000 Received: from enlil.physics.usyd.edu.au (localhost.physics.usyd.edu.au [127.0.0.1]) by enlil.physics.usyd.edu.au (8.13.1/8.13.1) with ESMTP id kAT2WEhh014653; Wed, 29 Nov 2006 13:32:14 +1100 Received: from localhost (localhost [[UNIX: localhost]]) by enlil.physics.usyd.edu.au (8.13.1/8.13.1/Submit) id kAT2VvR6014624; Wed, 29 Nov 2006 13:31:57 +1100 From: "Paul C. Leopardi" Reply-To: paul.leopardi@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 User-Agent: KMail/1.7.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200611291331.56193.leopardi@physics.usyd.edu.au> Mailing-List: contact gsl-discuss-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gsl-discuss-owner@sourceware.org X-SW-Source: 2006-q4/txt/msg00014.txt.bz2 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