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

Chapter 7 Miscellaneous Routines 617
Vector long period random number generator SRANV/DRANV
Name SRANV/DRANV
Vector long period random number generator
Purpose These subprograms produce a sequence of uniformly-distributed [0,1)
pseudorandom numbers with a period of 2
48
. Subroutines SRANV and DRANV
return an array of random numbers per call, while companion functions SRAN
and DRAN return one random number per call.
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
48
, they obtain a sequence of seeds { S
n
} by
setting
This is generator 29 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
48
: that is, they repeat the same sequence of
pseudorandom numbers after about 281 trillion numbers.
Usage VECLIB:
INTEGER*8 iseed
INTEGER*4 n, incx
REAL*4 x(lenx)
CALL SRANV(iseed, n, x, incx)
INTEGER*8 iseed
INTEGER*4 n, incx
REAL*8 x(lenx)
CALL DRANV(iseed, n, x, incx)
Input iseed An initial seed to start a pseudorandom sequence, or
the iseed returned by the previous call to the
subprogram to continue a sequence.
n The number of pseudorandom numbers to place in
array x.
S
n
31167285S
n 1
1+()mod 2
48
n 0.>,=
X
n
2
48
S
n
.=