ZIGGURAT
Ziggurat Method for Exponential or Normal Random Numbers


ZIGGURAT is a C library, using double precision arithmetic, which rapidly generates random variates from the uniform, normal or exponential distributions.

The uniform numbers are generated directly. The ziggurate 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.

A user interested in the most efficient execution can easily extract all the necessary code from the library file and include it in the body of the main program. In that case, instead of calling the function shr3_value, the user would invoke the inline function SHR3 directly. For further details, see Marsaglia and Tang's paper.

Related Data and Programs:

CVT is a C++ library which computes elements of a Centroidal Voronoi Tessellation.

FAURE is a C++ library which computes elements of a Faure quasirandom sequence.

GRID is a C++ library which computes elements of a grid dataset.

HALTON is a C++ library which computes elements of a Halton quasirandom sequence.

HAMMERSLEY is a C++ library which computes elements of a Hammersley quasirandom sequence.

HEX_GRID is a C++ library which computes elements of a hexagonal grid dataset.

HEX_GRID_ANGLE is a FORTRAN90 library which computes elements of an angled hexagonal grid dataset.

IHS is a C++ library which computes elements of an improved distributed Latin hypercube dataset.

LATIN_CENTER is a C++ library which computes elements of a Latin Hypercube dataset, choosing center points.

LATIN_EDGE is a C++ library which computes elements of a Latin Hypercube dataset, choosing edge points.

LATIN_RANDOM is a C++ library which computes elements of a Latin Hypercube dataset, choosing points at random.

LCVT is a C++ library which computes a latinized Centroidal Voronoi Tessellation.

NIEDERREITER2 is a C++ library which computes elements of a Niederreiter quasirandom sequence with base 2.

NORMAL is a C library which computes elements of a sequence of pseudorandom normally distributed values.

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

SOBOL is a C++ library which computes elements of a Sobol quasirandom sequence.

UNIFORM is a C library which computes elements of uniform pseudorandom sequence.

VAN_DER_CORPUT is a C++ library which computes elements of a van der Corput quasirandom sequence.

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

Reference:

  1. 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:

List of Routines:

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


Last revised on 01 May 2008.