ziggurat


ziggurat, a FORTRAN77 code 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. The FORTRAN77 code uses signed integers, and for this reason, the FORTRAN77 version of the exponential random number algorithm does not match the C version - that is, for the same initial seed value, different results emerge from the two codes. Whether this seriously affects the validity of the FORTRAN77 results remains to be checked.

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 Fortran90 version and a MATLAB version and an Octave version.

Related Data and Programs:

ziggurat_test

asa183, a FORTRAN77 library which implements the Wichman-Hill pseudorandom number generator.

CVT, a FORTRAN90 library which computes elements of a Centroidal Voronoi Tessellation.

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

GRID, a FORTRAN90 library which computes elements of a grid dataset.

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

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

HEX_GRID, a FORTRAN90 library which computes elements of a hexagonal grid dataset.

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

IHS, a FORTRAN90 library which computes elements of an improved distributed Latin hypercube dataset.

LATIN_CENTER, a FORTRAN90 library which computes elements of a Latin Hypercube dataset, choosing center points.

LATIN_EDGE, a FORTRAN90 library which computes elements of a Latin Hypercube dataset, choosing edge points.

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

LCVT, a FORTRAN90 library which computes a latinized Centroidal Voronoi Tessellation.

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

NORMAL, a FORTRAN77 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.

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

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

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

ZIGGURAT_OPENMP, a FORTRAN77 program which demonstrates how the ZIGGURAT library can be used to generate random numbers in an OpenMP parallel program.

Author:

Original C version by George Marsaglia, Wai Wan Tsang. This version by John Burkardt.

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:


Last revised on 07 September 2023.