English

A modified ziggurat algorithm for generating exponentially- and normally-distributed pseudorandom numbers

Mathematical Software 2014-04-22 v2

Abstract

The Ziggurat Algorithm is a very fast rejection sampling method for generating PseudoRandom Numbers (PRNs) from common statistical distributions. The algorithm divides a distribution into rectangular layers that stack on top of each other (resembling a Ziggurat), subsuming the desired distribution. Random values within these rectangular layers are then sampled by rejection. This implementation splits layers into two types: those constituting the majority that fall completely under the distribution and can be sampled extremely fast without a rejection test, and a few additional layers that encapsulate the fringe of the distribution and require a rejection test. This method offers speedups of 65% for exponentially- and 82% for normally-distributed PRNs when compared to the best available C implementations of these generators. Even greater speedups are obtained when the algorithm is extended to the Python and MATLAB/OCTAVE programming environments.

Keywords

Cite

@article{arxiv.1403.6870,
  title  = {A modified ziggurat algorithm for generating exponentially- and normally-distributed pseudorandom numbers},
  author = {Christopher D McFarland},
  journal= {arXiv preprint arXiv:1403.6870},
  year   = {2014}
}
R2 v1 2026-06-22T03:35:31.743Z