This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: what to do about random numbers?
Hi, I am VERY gratefull for this work :-) ... and I was actually unaware that it was the sign bit causing problems in the get and put !
I have been trying to get and put to work as expected for a while, ( my put gives a segfault ... which it used not to ), and have been putting in snippets of spare time but not enough continous effort to get anywhere.
btw. whe sign bits shouldnt be that much of a problem, since the only important part is that it's the same binary sequence, however for the time beeing the important part is to have a complete lib !
Anything that runs is fine with me !
but , if we could put something in the build system to select the RNG it would be nice, perhaps we vould prefix the code I wrote with MT_ and your with SGK_ and then do a define in the build for the symbols to resolve to the correct routine ? ( also this way we would have one 'standard' generator, and the other's available as external subroutines ?
I will also have a good look at your code :-) ... ( perhaps I can fix mine with it ? ).
/ Lars Segerlund.
On Sun, 23 May 2004 22:31:40 -0700
Steve Kargl <sgk@troutmask.apl.washington.edu> wrote:
> 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