ZIGGURAT
Ziggurat Random Number Generator (RNG)


ZIGGURAT is a MATLAB library which rapidly generates random variates from the uniform, normal or exponential distributions, by Marsaglia and Tsang.

The uniform numbers are generated directly. The ziggurat method is used to compute the normal and exponential values.

In the reference, the underlying generators are implemented "inline", invoking a function call only in exceptional cases. This results in very fast execution.

In this implementation, the advantages of inline code are not used. All the routines and inline functions are isolated in a separate file, so that a user invokes them through the familiar library interface.

This code is a translation of software written in C. The C code used unsigned integers for the underlying SHR3 algorithm. Getting the MATLAB code to reproduce the results of the C code has been somewhat tricky. The results seem to match the C code, but I have not tried to be efficient in my modifications.

Licensing:

The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.

Languages:

ZIGGURAT is available in a C version and a C++ version and a FORTRAN77 version and a FORTRAN90 version and a MATLAB version.

Related Data and Programs:

FAURE, a MATLAB library which computes elements of a Faure quasirandom sequence.

HALTON, a MATLAB library which computes elements of a Halton quasirandom sequence.

HAMMERSLEY, a MATLAB library which computes elements of a Hammersley quasirandom sequence.

NIEDERREITER2, a MATLAB library which computes elements of a Niederreiter quasirandom sequence with base 2.

NORMAL, a MATLAB library which computes elements of a sequence of pseudorandom normally distributed values.

RBOX, a C program which generates a set of points in a region, selected at random according to a given distribution.

RNGLIB, a MATLAB library which implements a random number generator (RNG) with splitting facilities, allowing multiple independent streams to be computed, by L'Ecuyer and Cote.

SOBOL, a MATLAB library which computes elements of a Sobol quasirandom sequence.

UNIFORM, a MATLAB library which computes elements of uniform pseudorandom sequence.

VAN_DER_CORPUT, a MATLAB library which computes elements of a van der Corput quasirandom sequence.

Author:

George Marsaglia, Wai Wan Tsang.

Reference:

  1. Philip Leong, Guanglie Zhang, Dong-U Lee, Wayne Luk, John Villasenor,
    A comment on the implementation of the ziggurat method,
    Journal of Statistical Software,
    Volume 12, Number 7, February 2005.
  2. George Marsaglia, Wai Wan Tsang,
    The Ziggurat Method for Generating Random Variables,
    Journal of Statistical Software,
    Volume 5, Number 8, October 2000, seven pages.

Source Code:

Examples and Tests:

You can go up one level to the MATLAB source codes.


Last revised on 20 May 2008.