## Random number generation

This collection of subroutines generates random numbers from a variety of
different distributions (uniform, exponential, normal, binomial, poisson,
geometric, gamma, beta, negative binomial and weibull) using a basic
generator, due to Marsaglia and Zaman,
with extremely good properties. The seed for the generator can be set to a
non-repeatable initial state if your FORTRAN implementation
supports the `CALL SYSTEM`

feature - most `Unix`

implementations are OK with this. The bits to change are clearly labelled in the
code if your implementation desn't support it. The routines have been used
without problems on Silicon Graphics Machines running Irix 5.3 and Irix 6.3,
Sun workstations running SunOS 5.5.1 and some version of Solaris (now defunct
so I can't remember which), a PC running Linux 2.0.35 and a PC running the
Salford Fortran compiler under MS-DOS (with ```
CALL
SYSTEM
```

removed for the last case).
**Code last updated on 26th August 2003**: routine ZBQLU01
amended to prevent it from returning zero values (which are perfectly
legitimate as far as the discrete arithmetic of the generator is
concerned, but cause problems if, for example, you try to calculate
log(U) in order to generate an exponential random variate). If the
discrete arithmetic returns zero, the code will now return a random
number uniformly distributed between zero and the smallest possible
discrete value (which is around 4*10^-9). The integer arithmetic has
also been replaced with double precision throughout, to avoid problems
with integer overflow errors. The accuracy has been checked and is OK
(see comments in code). Thanks again to Peter Visscher for testing the
previous version to destruction!

### Download the code here.

### Download the documentation here.

To Richard's work page.

Page last updated: 26th August 2003.