Ziggurat Method for Exponential or Normal Random Numbers

ZIGGURAT_INLINE is a C library which rapidly generates random variates from the uniform, normal or exponential distributions.

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

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


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


ZIGGURAT_INLINE is available in a C version and a C++ version.

Related Data and Programs:

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

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

ZIGGURAT, a C program which generates points from a uniform, normal or exponential distribution, using the ziggurat method.

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


  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:

List of Routines:

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

Last revised on 16 October 2013.