Alberto Fasso' <[log in to unmask]> wrote:
...
>I don't know if the standard requires the range of tmp_ran to include 1,
>but it would be reasonable to be so. Including 0 is dangerous, because
>it can be a source of exceptions (it is quite common to sample from
>an exponential distribution by taking the log of a random number).
...
>From the F90 standard:
RANDOM_NUMBER(HARVEST)
Description. Returns one pseudorandom number or an array
of pseudorandom numbers from the uniform distribution over
the range 0 <= x < 1.
This is what most generators have traditionally produced.
The usual generator is implemented using integer arithmetic
and then placing P leading bits of the integer seed into the
significand of a float (by, some operation equivalent to division
by 2^P).
My suspicion is that the random generator in question actually
does the division, divides the entire integer seed (rather than the
leading P bits of it), and uses a rounding mode other than
round-toward-minus. Probably, the easiest way for them to
fix it is to mask the integer to the right number of bits before
the divide. That way they don't have to worry about rounding
mode.
--
J. Giles
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|