HP MLIB User's Guide Vol. 2 7th Ed.

610 HP MLIB User’s Guide
RAN VAX-compatible random numbers
Name RAN
VAX-compatible random numbers
Purpose This subprogram produces uniform [0,1) pseudorandom numbers identical to
those generated by the VAX random-number generator, RAN. RAN is identical
in usage to its VAX counterpart. RAN returns one random number per call,
while the companion subroutine RANV returns an array of random numbers
per call. For details about RANV, refer to “RANV” on page 612.
These generators are based on the linear congruent method introduced by D. H.
Lehmer in 1949; refer to The Art of Computer Programming (1973). Given a
starting seed, S
0
, with 0 S
0
< 2
32
, they obtain a sequence of seeds { S
n
} by
setting
This is generator 25 in Table 1 on page 102 of The Art of Computer
Programming (1973). Uniformly distributed numbers X
n
between 0 (inclusive)
and 1 (exclusive) are produced by the scaling
The period of these generators is 2
32
, that is, they repeat the same sequence of
pseudorandom numbers after about 4.3 billion numbers. Subprograms SRAN
and DRAN, documented elsewhere in this chapter, are random number
generators with a much longer period.
Usage VECLIB and VECLIB8:
INTEGER*4 iseed
REAL*4 RAN, x
x = RAN(iseed)
INTEGER*8 iseed
REAL*4 RAN, x
x = RAN(iseed)
Input iseed An initial seed to start a pseudorandom sequence, or
the iseed returned by the previous call to RAN to
continue a sequence.
Output iseed The seed that produces the next pseudorandom
number in the sequence replaces the input seed.
x The next pseudorandom number in the sequence.
S
n
69069S
n 1
()mod 2
32
n 0.>,=
X
n
2
32
S
n
.=