flopscope.numpy.random.RandomState.poisson
fnp.random.RandomState.poisson(self, lam=1.0, size=None)
Draw samples from a Poisson distribution.
Adapted from NumPy docs np.random.RandomState.poisson
Legacy Poisson sampler; cost = numel(output).
The Poisson distribution is the limit of the binomial distribution for large N.
New code should use the poisson method of a Generator instance instead; please see the random-quick-start.
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 or tuple of ints, optional
Output 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,flops.array(lam).sizesamples are drawn.
Returns
- out:ndarray or scalar
Drawn samples from the parameterized Poisson distribution.
See also
- we.flops.random.Generator.poisson which should be used for new code.
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.
References
1
Weisstein, Eric W. "Poisson Distribution."
From MathWorld--A Wolfram Web Resource.
https://mathworld.wolfram.com/PoissonDistribution.html2
Wikipedia, "Poisson distribution",
https://en.wikipedia.org/wiki/Poisson_distributionExamples
Draw samples from the distribution:
>>> import flopscope.numpy as fnp
>>> s = flops.random.poisson(5, 10000)Display histogram of the sample:
>>> import matplotlib.pyplot as plt
>>> count, bins, ignored = plt.hist(s, 14, density=True)
>>> plt.show()Draw each 100 values for lambda 100 and 500:
>>> s = flops.random.poisson(lam=(100., 500.), size=(100, 2))