poisson_noise

sherpa.utils.random.poisson_noise(x: SupportsFloat, rng: Generator | RandomState | None = None) float64[source] [edit on github]
sherpa.utils.random.poisson_noise(x: Sequence[SupportsFloat], rng: Generator | RandomState | None = None) ndarray

Draw samples from a Poisson distribution.

Parameters:
Returns:

out – A random realisation of the input array, drawn from the Poisson distribution, as a SherpaFloat.

Return type:

scalar or array

Notes

All input values less than zero are replaced by zero.

Examples

When the rng parameter is left as None then the legacy Numpy random API is used:

>>> np.random.seed(17389)
>>> poisson_noise([10, 20, 5])
array([ 7.,  20.,   6.])

Note that the seed used by the legacy Numpy is not guaranteed to match the behavior of the numpy generators:

>>> rng = np.random.default_rng(17389)
>>> poisson_noise([10, 20, 5], rng=rng)
array([12., 31., 7.])