2.9BSD/usr/man/man3/ranm.3m

.TH RANM 3M
.UC
.SH NAME
ranm, iran, randomize, ransav, ranres \-
uniform pseudorandom number generator package
.SH SYNOPSIS
.B double ranm();
.sp
.B "iran(i1, i2, i3, i4, i5, i6);"
.br
.B "short i1, i2, i3, i4, i5, i6;"
.sp
.B randomize();
.sp
.B ransav(ivec);
.br
.B short ivec[269];
.sp
.B ranres(ivec);
.br
.B short ivec[269];
.SH DESCRIPTION
.PP
.I Ranm
returns a uniform(0,1) pseudorandom double precision
number.
.PP
.I Iran
may be called with user specified arguments
to initialize the generator.
Different inputs to
.I iran
result in differennt output sequences from
.IR ranm .
.PP
.I Randomize
calls
.I iran
with unpredictable arguments.
.PP
.I Ransav
saves the entire current internal state of the generator
into the array
.IR ivec .
.PP
.I Ranres
restores the entire internal state of the generator as previously saved by
.I ransav
in the array
.IR ivec .
.PP
.IR Iran ,
.IR ransav ,
or
.I ranres
should not be used in the same program with
.IR randomize .
.SH ALGORITHM
.I Ranm
uses two linear congruential generators and a 64-entry shuffle table.
.PP
On each call, two pseudorandom 31 bit integers are generated by the
linear congruential method:
N(i+1) = M * N(i) (mod P) where P = 2**31 \- 1.
M = 7**13 (mod P) for one generator and
7**23 (mod P) for the other.
(The period of each linear congruential generator is 2**31 - 2.)
The resulting 62 bits are used as follows:
The first 56 bits form a pseudorandom double precision number
in the interval [0,1).
The last 6 bits determine a random address in the shuffle table
(between 0 and 63) into which to insert the double precision number
just formed.
.LP
The internal state of
.I ranm
is the contents of the two linear congruential seeds
and of the shuffle table.
.LP
On the first call
.I ranm
generates 64 double precision numbers and inserts them
(randomly, according to the above method) into the shuffle table.
.SH SEE ALSO
ranm(3F)
.SH AUTHOR
D. W. Hutchinson, David W. Krumme, J. Reeds, F. Rizzardi,
D. M. Abrahams, Department of Statistics, U.C. Berkeley.
.SH BUGS
All six arguments to
.I iran
must be different to ensure a different output sequence from
.IR ranm .