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


RANM(3M)            UNIX Programmer's Manual             RANM(3M)

NAME
     ranm, iran, randomize, ransav, ranres - uniform pseudorandom
     number generator package

SYNOPSIS
     double ranm();

     iran(i1, i2, i3, i4, i5, i6);
     short i1, i2, i3, i4, i5, i6;

     randomize();

     ransav(ivec);
     short ivec[269];

     ranres(ivec);
     short ivec[269];

DESCRIPTION
     _R_a_n_m returns a uniform(0,1) pseudorandom double precision
     number.

     _I_r_a_n may be called with user specified arguments to initial-
     ize the generator.  Different inputs to _i_r_a_n result in dif-
     ferennt output sequences from _r_a_n_m.

     _R_a_n_d_o_m_i_z_e calls _i_r_a_n with unpredictable arguments.

     _R_a_n_s_a_v saves the entire current internal state of the gen-
     erator into the array _i_v_e_c.

     _R_a_n_r_e_s restores the entire internal state of the generator
     as previously saved by _r_a_n_s_a_v in the array _i_v_e_c.

     _I_r_a_n, _r_a_n_s_a_v, or _r_a_n_r_e_s should not be used in the same pro-
     gram with _r_a_n_d_o_m_i_z_e.

ALGORITHM
     _R_a_n_m 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.

Printed 8/5/83                                                  1

RANM(3M)            UNIX Programmer's Manual             RANM(3M)

     The internal state of _r_a_n_m is the contents of the two linear
     congruential seeds and of the shuffle table.

     On the first call _r_a_n_m generates 64 double precision numbers
     and inserts them (randomly, according to the above method)
     into the shuffle table.

SEE ALSO
     ranm(3F)

AUTHOR
     D. W. Hutchinson, David W. Krumme, J. Reeds, F. Rizzardi, D.
     M. Abrahams, Department of Statistics, U.C. Berkeley.

BUGS
     All six arguments to _i_r_a_n must be different to ensure a dif-
     ferent output sequence from _r_a_n_m.

Printed 8/5/83                                                  2