Generate Poisson Distributed Data in Python

Your goal

You need to randomly generate Poisson distributed data in Python.

Step-by-step tutorial

We will use the geometric random number generator from numpy.random.default_rng.

>>> from numpy.random import default_rng
>>> rng = default_rng()
>>> data = data = rng.poisson(10, 5000)
>>> data
array([11,  8,  7, ..., 12, 15,  3])

Here's a histogram for the data:

>>> plt.hist(data, bins=range(30))
Histogram of Poisson distributed data
Histogram of Poisson distributed data