RAN(3F)RAN(3F)NAME
ran - return a random number between 0 and 1
SYNOPSIS
real function ran (i)
integer*4 i
DESCRIPTION
Repeated calls to ran generate random numbers with a uniform distribu‐
tion.
NOTES
See lcrans(3m).
The range includes 0.0 and excludes 1.0. The algorithm is a multi‐
plicative, congruential type, general random number generator. In gen‐
eral, the value of i is set once during execution of the calling pro‐
gram. The initial value of i should be a large odd integer. Each call
to ran returns the next random number in the sequence.
To get a different sequence of random numbers each time you run the
calling program, you must set the argument i to a different initial
value for each run.
Usage:
real r, ran
integer*4 i
i = ...
...
r = ran(i)
Example:
demo% cat ran1.f
* ran1.f <-- Generate random numbers
integer*4 i, n
real r(10)
i = 760013
do n = 1, 10
r(n) = ran ( i )
end do
write ( *, "( 5 f11.6 )" ) r
end
demo% f77 -silent ran1.f
demo% a.out
0.222058 0.299851 0.390777 0.607055 0.653188
0.060174 0.149466 0.444353 0.002982 0.976519
demo%
FILES
libfui.a
SEE ALSO
lcrans, addrans, and shufrans in the Numerical Computation Guide
07 July 1995 RAN(3F)