poisson

Contents

poisson#

class brainstate.random.poisson(lam=1.0, size=None, key=None, dtype=None)#

Draw samples from a Poisson distribution.

The Poisson distribution is the limit of the binomial distribution for large N.

Parameters:
  • lam (float or array_like of floats) – Expected number of events occurring in a fixed-time interval, must be >= 0. A sequence must be broadcastable over the requested size.

  • size (int | Sequence[int] | integer | Sequence[integer] | None) – Output shape. If the given shape is, e.g., (m, n, k), then m * n * k samples are drawn. If size is None (default), a single value is returned if lam is a scalar. Otherwise, np.array(lam).size samples are drawn.

  • key (int | Array | ndarray | None) – The key for the random number generator. If not given, the default random number generator is used.

Returns:

out – Drawn samples from the parameterized Poisson distribution.

Return type:

ndarray or scalar

Notes

The Poisson distribution

\[f(k; \lambda)=\frac{\lambda^k e^{-\lambda}}{k!}\]

For events with an expected separation \(\lambda\) the Poisson distribution \(f(k; \lambda)\) describes the probability of \(k\) events occurring within the observed interval \(\lambda\).

Because the output is limited to the range of the C int64 type, a ValueError is raised when lam is within 10 sigma of the maximum representable value.

References

Examples

Draw samples from the distribution:

>>> import numpy as np
>>> s = brainstate.random.poisson(5, 10000)

Display histogram of the sample:

>>> import matplotlib.pyplot as plt  # noqa
>>> count, bins, ignored = plt.hist(s, 14, density=True)
>>> plt.show()

Draw each 100 values for lambda 100 and 500:

>>> s = brainstate.random.poisson(lam=(100., 500.), size=(100, 2))