This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: Random number generators in gfortran
- From: "Daniel Franke" <franke dot daniel at gmail dot com>
- To: Mark dot Miller at usu dot edu
- Cc: fortran at gcc dot gnu dot org
- Date: Tue, 24 Jul 2007 16:49:49 +0200
- Subject: Re: Random number generators in gfortran
- Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=iVuFTLYvtUp1LIN2sIlgXJYLslOVXo4h4k/+kRiIVW0GChgj4iMz38WUzEpRM1oKxK+Kxwbw1HiVtusiNw1cu4xuH1aEejgwMRYKVbVLLaih1Gwctz0BFQyK1GS8hrWev+v3MZpluQ8E7GXD3qU29jpovP8MphufU+ahZ+GsdMA=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=MYiyINlYF+q9Fy1QxiDuNA1KgxOfxFyl2h5QHMp41/+Q9+HDtaTVdH/dKx4tGt6D0Dakr/HjM0XuAM/iG7wHm8vJvPCOgCFc3WqxoM1wRaHCeALO4PSmudUlRymmWULq9eKg6BiXQUHwmsiQr36jW0u6sy+IcrLUHczAKDLeXFE=
- References: <46A60ED8.8020408@cc.usu.edu>
2007/7/24, Mark.Miller <mpmusu@cc.usu.edu>:
What algorithms are used in gfortran for generating random numbers? Is
it the Mersenne Twister? Or is it something with a much shorter period?
The following is shamelessly copied from gcc/libgfortran/intrinsics/random.c:
" libgfortran previously had a Mersenne Twister, taken from the paper:
Mersenne Twister: 623-dimensionally equidistributed
uniform pseudorandom generator.
by Makoto Matsumoto & Takuji Nishimura
which appeared in the: ACM Transactions on Modelling and Computer
Simulations: Special Issue on Uniform Random Number
Generation. ( Early in 1998 ).
The Mersenne Twister code was replaced due to
(1) Simple user specified seeds lead to really bad sequences for
nearly 100000 random numbers.
(2) open(), read(), and close() were not properly declared via header
files.
(3) The global index i was abused and caused unexpected behavior with
GET and PUT.
(4) See PR 15619.
libgfortran currently uses George Marsaglia's KISS (Keep It Simple Stupid)
random number generator. This PRNG combines:
(1) The congruential generator x(n)=69069*x(n-1)+1327217885 with a period
of 2^32,
(2) A 3-shift shift-register generator with a period of 2^32-1,
(3) Two 16-bit multiply-with-carry generators with a period of
597273182964842497 > 2^59.
The overall period exceeds 2^123."