Repeatable pseudorandom sequences in Fortran |
|
Every time you call the Fortran function rand(0),
it returns a number between 0.0 and 1.0. Statistically,
these numbers are uniformly distributed, which means
that it is equally likely that the numbers will be anywhere in
this range.
If every call to rand() supplies an argument of 0,
your program will get exactly the same sequence of random numbers
every time. For example, here is a short program:
integer i
real rand
do i = 1, 4
print *, rand(0)
end do
stop
end
Every time it runs, it produces the same output:
0.968071
6.67306E-02
0.478281
0.909534