This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
what to do about random numbers?
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: fortran at gcc dot gnu dot org
- Date: Sun, 23 May 2004 22:31:40 -0700
- Subject: what to do about random numbers?
Gang,
First, this is not a slam against Lars' implementation of
RANDOM_NUMBER and RANDOM_SEED. Indeed, I like the mersenne
twister, but I could not work out a way of fixing the
current implementation of RANDOM_NUMBER and RANDOM_SEED.
Part of the the problem is the mersenne twister used
unsigned integers, which have no corresponding Fortran
type. This was causing problems with the PUT and GET
arguments to RANDOM_SEED. I suppose we could use the
mersenne twister where we mask the sign bit for the seed,
but that would be a kludge.
So, I took Marsaglia's KISS RNG and implemented new
versions of RANDOM_NUMBER and RANDOM_SEED. My version
appears to work with regards to the Fortran standard.
Note, I used Lars' implementation of the array versions
of RANDOM_NUMBER where only very minor modifications
were needed.
I have not run any tests to ensure my implementation
produces "good" random numbers. But, it is an straight
forward implementation of KISS and Marsaglia has tested
the goodness of the algorithm.
At the momemt, I have named the algorithms SGK_RANDOM_NUMBER
and SGK_RANDOM_SEED for testing. If anyone wants a diff
of my algorithms, just ask.
Note, if we decide to go with the simpler KISS RNG, I'll
contact George Marsaglia to ensure there are no problems
with my implemention and copyright issues.
Paul, if you've read this far, my versions of RANDOM_NUMBER
and RANDOM_SEED fix PR 15619.
--
Steve