ranm(3m)
NAME
ranm, iran, randomize, ransav, ranres − uniform pseudorandom number generator package
SYNTAX
double ranm();
iran(i1, i2, i3, i4, i5, i6);
short i1, i2, i3P, i4, i5, i6;
randomize();
ransav(ivec);
short ivec[269];
ranres(ivec);
short ivec[269];
DESCRIPTION
The ranm function returns a uniform(0,1) pseudorandom double precision number.
The iran function may be called with user specified arguments to initialize the generator. Different inputs to iran result in different output sequences from ranm.
The randomize function calls iran with unpredictable arguments.
The ransav function saves the entire current internal state of the generator into the array ivec.
The ranres function restores the entire internal state of the generator as previously saved by ransav in the array ivec.
Either iran, ransav, or ranres should not be used in the same program with randomize.
ALGORITHM
The ranm function uses two linear congruential generators and a 64-entry shuffle table.
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.
The internal state of ranm is the contents of the two linear congruential seeds and of the shuffle table.
On the first call ranm generates 64 double precision numbers and inserts them (randomly, according to the above method) into the shuffle table.
RESTRICTIONS
All six arguments to iran must be different to ensure a different output sequence from ranm.