Poisson Distribution and Poisson Process in Python — Statistics
In this article we will explore Poisson distribution and Poisson process in Python.
Table of contents
- Introduction
- What is a Poisson process
- What is a Poisson distribution
- Poisson distribution example
- Poisson distribution example in Python
- Conclusion
Introduction
To continue following this tutorial we will need the following Python libraries: scipy, numpy, and matplotlib.
If you don’t have it installed, please open “Command Prompt” (on Windows) and install it using the following code:
pip install scipy
pip install numpy
pip install matplotlibWhat is a Poisson process
A Poisson point process (or simply, Poisson process) is a collection of points randomly located in mathematical space.
Due to its several properties, the Poisson process is often defined on a real line, where it can be considered a random (stochastic) process in one dimension. This further allows to build mathematical systems and study certain events that appear in a random manner.
One of its important properties is that each point of the process is stochastically independent from other points in the process.
As an example we can think of an example where such process can be observed in real life. Suppose you are studying the historical frequencies of hurricanes. This indeed is a random process, since the number of hurricanes this year is independent of the number of hurricanes las year and so on. However, over time you may be observing some trends, average frequency, and more.
Mathematically speaking, in this case, the point process depends on something that might be some constant, such as average rate (average number of customers calling, for example).
A Poisson process is defined by a Poisson distribution.
What is a Poisson distribution?
A Poisson distribution is a discrete probability distribution of a number of events occurring in a fixed interval of time given two conditions:
- Events occur with some constant mean rate.
- Events are independent of each other and independent of time.
To put this in some context, consider our example of frequencies of hurricanes from the previous section.
Assume that when we have data on observing hurricanes over a period of 20 years. We find that the average number of hurricanes per year is 7. Each year is independent of previous years, which means that if we observed 8 hurricanes this year, it doesn’t mean we will observe 8 next year.
The PMF (probability mass function) of a Poisson distribution is given by:

where:
- λ is a real positive number given by λ = E(X) = μ
- k is the number of occurrences
- e = 2.71828\)
The Pr(X=k) can be read as: Poisson probability of k events in an interval.
And the CDF (cumulative distribution function) of a Poisson distribution is given by:

Poisson distribution example
Now that we know some formulas to work with, let’s go through an example in detail.
Recall the hurricanes data we mentioned in the previous sections. We know that the historical frequency of hurricanes is 7 per year, and this forms our λ value:
λ = 7
The question we can have is what is the probability of observing exactly 5 hurricanes this year? And this forms our k value:
k = 5
Using the formula from the previous section, we can calculate the Poisson probability:

Therefore, the probability of observing exactly 5 hurricanes next year is equal to 12.77%.
Naturally, we are curious about the probabilities of other frequencies.
Poisson PMF (probability mass function)
Consider the table below which shows the Poisson probability of hurricane frequencies (0–15):
Using the above table we can create the following visualization of the Poisson probability mass function for this example:
Poisson CDF (cumulative distribution function)
Consider the table below which shows the Poisson cumulative probability of hurricane frequencies (0–15):
Using the above table we can create the following visualization of the Poisson cumulative distribution function for this example:
The table also allows us to answer some interesting questions.
For example, what if we wanted to find out the probability of seeing up to 5 hurricanes (mathematically: k≤5), we can see that it’s 0.30071 or 30.07%.
On the other hand, we can be interested in probability of observing more than 5 hurricanes (mathematically: k>5), which would be 1-p(5,7) = 1–0.30071 = 0.69929 or 69.93%.
Poisson distribution example in Python
In the previous section we computed probability mass function and cumulative distribution function by hand. In this section, we will reproduce the same results using Python.
We will begin with importing the required dependencies:





