HP MLIB User's Guide Vol. 2 7th Ed.
612 HP MLIB User’s Guide
RANV VAX-compatible random numbers
Name RANV
VAX-compatible random numbers
Purpose This subprogram produces uniform [0,1) pseudorandom numbers identical to
those generated by the VAX random-number generator, RAN. RANV returns an
array of random numbers per call while the companion subroutine RAN
returns one random number per call. For details about RAN, refer to “RAN” on
page 610.
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 SRANV
and DRANV, documented elsewhere in this chapter, are vectorized random
number generators with a much longer period.
Usage VECLIB:
INTEGER*4 iseed, n
REAL*4 x(n)
CALL RANV(iseed, n, x)
VECLIB8:
INTEGER*8 iseed, n
REAL*4 x(n)
CALL RANV(iseed, n, x)
Input iseed An initial seed to start a pseudorandom sequence, or
the iseed returned by the previous call to RANV to
continue a sequence.
n The number of pseudorandom numbers to place in
array x.
S
n
69069S
n 1–
1+()mod 2
32
n 0>,=
X
n
2
32–
S
n
=