Package 'zigg'

Title: Lightweight Interfaces to the 'Ziggurat' Pseudo Random Number Generator
Description: 'Ziggurat', originally introduced by Marsaglia and Tsang (2000, <doi:10.18637/jss.v005.i08>) and further improved by Leong et al (2005, <doi:10.18637/jss.v012.i07>) offers a lightweight and very fast pseudo-random number generator (or 'PRNG') for the normal, exponential, and uniform distributions. It is provided here in a small zero-dependency package. It can be used from R as well as from C(++) code in other packages as is demonstrated by four included sample packages using four distinct methods to use the PRNG presented here in client package. The implementation is influenced by our older package 'RcppZiggurat' which offers a comparisone among multiple alternative implementations. These PRNGs provided are generally faster than the ones in base R: on our machine, the relative gains for normal, exponential and uniform are on the order of 7.4, 5.2 and 4.7 times faster than base R. However, these generators are of potentially lesser quality so if in doubt use of the base R function generatrs remains the general recommendation.
Authors: Dirk Eddelbuettel [aut, cre]
Maintainer: Dirk Eddelbuettel <[email protected]>
License: GPL (>= 2)
Version: 0.0.0
Built: 2025-01-12 16:22:06 UTC
Source: https://github.com/eddelbuettel/zigg

Help Index


Lightweight Interfaces to the 'Ziggurat' Pseudo Random Number Generator

Description

'Ziggurat', originally introduced by Marsaglia and Tsang (2000, <doi:10.18637/jss.v005.i08>) and further improved by Leong et al (2005, <doi:10.18637/jss.v012.i07>) offers a lightweight and very fast pseudo-random number generator (or 'PRNG') for the normal, exponential, and uniform distributions. It is provided here in a small zero-dependency package. It can be used from R as well as from C(++) code in other packages as is demonstrated by four included sample packages using four distinct methods to use the PRNG presented here in client package. The implementation is influenced by our older package 'RcppZiggurat' which offers a comparisone among multiple alternative implementations. These PRNGs provided are generally faster than the ones in base R: on our machine, the relative gains for normal, exponential and uniform are on the order of 7.4, 5.2 and 4.7 times faster than base R. However, these generators are of potentially lesser quality so if in doubt use of the base R function generatrs remains the general recommendation.

Package Content

Index of help topics:

zigg-package            Lightweight Interfaces to the 'Ziggurat' Pseudo
                        Random Number Generator
zrnorm                  Ziggurat Pseudo Random Number Generators

Maintainer

Dirk Eddelbuettel <[email protected]>

Author(s)

Dirk Eddelbuettel [aut, cre] (<https://orcid.org/0000-0001-6419-907X>)


Ziggurat Pseudo Random Number Generators

Description

Pseudo random numbers drawn from one of three distributions are offered, as proposed by Marsaglia and Tsang (2000, <doi:10.18637/jss.v005.i08>) and improved by Leong et al (2005, <doi:10.18637/jss.v012.i07>.

Usage

zrnorm(n)

zrexp(n)

zrunif(n)

zsetseed(s)

Arguments

n

The size of the returned vector

s

The chosen seed

Value

A vector of pseudo random-number generated draws from either the Normal, Exponential or Uniform distribution, as selected

References

<doi:10.18637/jss.v005.i08> <doi:10.18637/jss.v012.i07>

Examples

zsetseed(123)
zrnorm(3)
round(summary(zrunif(1e6)), 4)