pypomp.random.fast_poisson

pypomp.random.fast_poisson(key: Array, lam: Array, dtype: dtype | None = None, max_newton_loops: int = 5, max_inverse_cdf_loops: int = 20) Array[source]

Sample Poisson random variates using a GPU-optimized inverse CDF algorithm.

Generates Poisson-distributed integers with rate lam using an approximate inverse CDF method from Giles (2016) [1]. The implementation is designed to run efficiently on GPUs.

Iterations of both the Newton-Raphson and exact inverse CDF stages are capped to bound runtime. The output is very close to exact Poisson but not guaranteed to be identical to a reference sampler.

Parameters:
  • key (jax.Array) – JAX PRNG key.

  • lam (jax.Array) – Rate parameter(s). Broadcast with key shape. Negative values produce -1.

  • dtype (np.dtype or None, optional) – Integer output dtype. Defaults to int64 if jax_enable_x64=True, otherwise int32.

  • max_newton_loops (int, optional) – Maximum Newton-Raphson iterations. Defaults to 5.

  • max_inverse_cdf_loops (int, optional) – Maximum exact inverse CDF iterations. Defaults to 20.

Returns:

Integer array of Poisson samples with the broadcast shape of lam. Returns -1 for invalid (negative) rate inputs.

Return type:

jax.Array

Notes

For speed and accuracy metrics, see the Quant Tests.

Examples

>>> import jax
>>> from pypomp.random import fast_poisson
>>> fast_poisson(jax.random.key(0), lam=5.0)
Array(5, dtype=int32)

References