NAME
drand48, erand48, lrand48, nrand48, mrand48, jrand48, srand48, seed48,
lcong48 - generate uniformly distributed pseudo-random numbers
SYNOPSIS
#include <stdlib.h>
double drand48(void);
I double erand48(unsigned short xsubi [3]);
long int lrand48(void);
I long int nrand48(unsigned short xsubi [3]);
long int mrand48(void);
I long int jrand48(unsigned short xsubi [3]);
I void srand48(long int seedval );
I unsigned short *seed48(unsigned short seed16v [3]);
I void lcong48(unsigned short param [7]);
DESCRIPTION
These functions generate pseudo-random numbers using the linear congruential
algorithm and 48-bit integer arithmetic.
The
R drand48 ()
and
R erand48 ()
functions return non-negative
double-precision floating-point values uniformly distributed between
[0.0, 1.0).
The
R lrand48 ()
and
R nrand48 ()
functions return non-negative
long integers uniformly distributed between 0 and 2^31.
The
R mrand48 ()
and
R jrand48 ()
functions return signed long
integers uniformly distributed between -2^31 and 2^31.
The
R srand48 (),
R seed48 ()
and
R lcong48 ()
functions are
initialization functions, one of which should be called before using
R drand48 (),
R lrand48 ()
or
R mrand48 ().
The functions
R erand48 (),
R nrand48 ()
and
R jrand48 ()
do not require
an initialization function to be called first.
All the functions work by generating a sequence of 48-bit integers,
Xi, according to the linear congruential formula:
Xn+1 = (aXn + c) mod m, where n >= 0
The parameter
m = 2^48, hence 48-bit integer arithmetic is performed.
Unless
R lcong48 ()
is called,
a and
c are given by:
a = 0x5DEECE66D
c = 0xB
The value returned by any of the functions
R drand48 (),
R erand48 (),
R lrand48 (),
R nrand48 (),
R mrand48 ()
or
R jrand48 ()
is
computed by first generating the next 48-bit
Xi in the sequence.
Then the appropriate number of bits, according to the type of data item to
be returned, is copied from the high-order bits of
Xi and transformed
into the returned value.