Poisson Random API

PoissonRandom.PassthroughRNGType
PassthroughRNG()

An AbstractRNG sentinel for backend-specific random number generation.

PassthroughRNG forwards scalar rand, randn, and randexp calls to the ambient random number implementation. It is useful when a backend, such as a GPU kernel overlay, provides the actual random number generation but an AbstractRNG argument is still needed by the Poisson sampler.

Examples

using PoissonRandom

x = pois_rand(PassthroughRNG(), 3.0)
x isa Integer
source
PoissonRandom.pois_randFunction
pois_rand(λ::Real)
pois_rand(rng::AbstractRNG, λ::Real)

Draw one random variate from the Poisson distribution with rate λ.

For small λ, pois_rand uses an exponential-counting method. For larger λ, it switches to the Ahrens-Dieter modified normal algorithm.

Arguments

  • λ: Poisson rate parameter. It should be nonnegative.
  • rng: optional random number generator. Defaults to Random.default_rng().

Examples

using PoissonRandom
using Random

rng = MersenneTwister(1234)
x = pois_rand(rng, 4.0)
x isa Integer

y = pois_rand(PassthroughRNG(), 4.0)
y isa Integer
source