rpgm.rexp: Fast Simulation of Exponential Random Variables

Description Usage Arguments Details Value Note Author(s) References See Also Examples

View source: R/rpgm.rexp.R

Description

The function rpgm.rexp uses the Ziggurat algorithm with a 256-regions table, in order to simulate exponential random variables faster than rexp.

Usage

1
rpgm.rexp(n, lambda = 1)

Arguments

n

integer, number of simulations.

lambda

double, the parameter lambda.

Details

The density is lambda * exp(-lambda*x) for x > 0.

Value

A vector of i.i.d. exponential random variables.

Note

For a big number of simulations, it is in general three times faster than the usual rexp. For one simulution, it is around one half faster.

Author(s)

Nicolas Baradel - PGM Solutions

References

https://en.wikipedia.org/wiki/Ziggurat_algorithm

See Also

http://pgm-solutions.com/packages

Examples

1

Example output

[1] -0.2839522 -0.7784362  1.4719206 -0.3494252  0.3282544

rpgm documentation built on March 18, 2018, 2:24 p.m.