mkl_random.MKLRandomState.poisson¶
- MKLRandomState.poisson(lam=1.0, size=None, method='POISNORM')¶
Draw samples from a Poisson distribution.
The Poisson distribution is the limit of the binomial distribution for large N.
- Parameters:
- lamfloat or array_like of floats
Expectation of interval, should be >= 0. A sequence of expectation intervals must be broadcastable over the requested size.
- sizeint or tuple of ints, optional
Output shape. If the given shape is, e.g.,
(m, n, k), thenm * n * ksamples are drawn. Default is None, in which case a single value is returned.- method‘POISNORM, ‘PTPE’, optional
Sampling method used by Intel MKL. Can also be specified using tokens mkl_random.POISNORM, mkl_random.PTPE
- Returns:
- samplesndarray or scalar
The drawn samples, of shape size, if it was provided.
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 long type, a ValueError is raised when lam is within 10 sigma of the maximum representable value.
References
[1]Weisstein, Eric W. “Poisson Distribution.” From MathWorld–A Wolfram Web Resource. http://mathworld.wolfram.com/PoissonDistribution.html
[2]Wikipedia, “Poisson distribution”, http://en.wikipedia.org/wiki/Poisson_distribution
Examples
Draw samples from the distribution:
>>> import numpy as np >>> s = mkl_random.poisson(5, 10000)
Display histogram of the sample:
>>> import matplotlib.pyplot as plt >>> count, bins, ignored = plt.hist(s, 14, normed=True) >>> plt.show()
Draw each 100 values for lambda 100 and 500:
>>> s = mkl_random.poisson(lam=(100., 500.), size=(100, 2))