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:
- xscalar or
array The expectation value for the distribution.
- rng
numpy.random.Generator,numpy.random.RandomState,orNone,optional Determines how the random numbers are created. If set to None then the
numpy.random.poissonroutine is used.
- xscalar or
- Returns:
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.])