This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Random number generators in gfortran


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."


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]