librandist
NAME
librandist - Library of pseudorandom distribution functions,
based upon GFSR.
SYNOPSIS
double GFSR()
int readGFSR( file ) char *file;
int writeGFSR( file ) char *file;
double unidist()
double expdist()
double normdist()
DESCRIPTION
Librandist is a library of pseudorandom distribution func-
tions, based upon the excellent routine GFSR. GFSR is a
fast pseudorandom number generator with a uniform distribu-
tion, having a large period that is independent of the com-
puter word size. This implementation uses a 31-bit GFSR
algorithm for x^98+x^27+1 to generate pseudorandom double-
precision numbers in the range [0,1]. The polynomial used
provides a period of 2^98 - 1. The expected mean is 1/2;
the expected variance is 1/12.
ReadGFSR loads a state table from file. WriteGFSR writes
the current state table to a file. Use of these routines is
not mandatory, but does allow GFSR to return different
values with each program run.
GFSR returns values uniformly distributed over the interval
[0,1]. Unidist returns values uniformly distributed over
the interval (0,1). Expdist returns values with an exponen-
tial distribution. Normdist returns values with a normal
distribution about the mean 0 with variance 1. The non-
uniform distribution functions, expdist and normdist, call
unidist as their source of random numbers, so 0 and 1 are
not inputs to these functions.
To compile using librandist, use the load flags '-lrandist
-lm' as arguments to cc or ld.
FORTRAN COMPATIBILITY
These routines may all be called from Fortran. Those that
return a number are functions of type DOUBLE PRECISION
(i.e., REAL*8).
REFERENCES
Lewis and Payne. "Generalized Feedback Shift Register Pseu-
dorandom Number Algorithm". Journal of the Association
for Computing Machinery. July 1973, pp. 456-468.
Press et al. "Numerical Recipes in C: The art of scientific
computing". Cambridge University Press. 3rd ed.,
1992, pp. 288--290.
SEE ALSO
seqaln-intro(1), librandist(3), gfsr(3), expdist(3)
,
normdist(3), unidist(3).