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

Chapter 7 Miscellaneous Routines 615
Scalar long period random number generator SRAN/DRAN
Name SRAN/DRAN
Scalar long period random number generator
Purpose These subprograms produce a sequence of uniformly-distributed [0,1)
pseudorandom numbers with a period of 2
48
. Functions SRAN and DRAN
return one random number per call, while companion subprograms SRANV
and DRANV, also documented in this chapter, return an array of random
numbers per call.
These generators are based on the linear congruential 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
REAL*4 SRAN, x
x = SRAN(iseed)
INTEGER*8 iseed
REAL*8 DRAN, x
x = DRAN(iseed)
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.
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
31167285S
n 1
1+()mod 2
48
n 0.>,=
X
n
2
48
S
n
.=