bundles / numpy latest / numpy / random / _generator / Generator / poisson
cython_function_or_method
numpy.random._generator:Generator.poisson
Signature
def poisson ( lam = 1.0 , size = None ) Summary
Draw samples from a Poisson distribution.
Extended Summary
The Poisson distribution is the limit of the binomial distribution for large N.
Parameters
lam: float or array_like of floatsExpected number of events occurring in a fixed-time interval, must be >= 0. A sequence must be broadcastable over the requested size.
size: int or tuple of ints, optionalOutput shape. If the given shape is, e.g.,
(m, n, k), thenm * n * ksamples are drawn. If size isNone(default), a single value is returned iflamis a scalar. Otherwise,np.array(lam).sizesamples are drawn.
Returns
out: ndarray or scalarDrawn samples from the parameterized Poisson distribution.
Notes
The probability mass function (PMF) of Poisson distribution is
For events with an expected separation the Poisson distribution describes the probability of events occurring within the observed interval .
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.
Examples
Draw samples from the distribution:rng = np.random.default_rng() lam, size = 5, 10000 s = rng.poisson(lam=lam, size=size)✓
s.mean(), s.var()
✗import matplotlib.pyplot as plt from scipy import stats x = np.arange(0, 21) pmf = stats.poisson.pmf(x, mu=lam)✓
plt.hist(s, bins=x, density=True, width=0.5) plt.stem(x, pmf, 'C1-')✗
plt.show()
✓
s = rng.poisson(lam=(100., 500.), size=(100, 2))
✓Aliases
-
numpy.random.Generator.poisson