Poisson distribution is a probability distribution that can be used to model the number of events in a fixed interval. It is often referred to as “random poisson process” or “poisson process”. The poisson distribution describes how many occurrences of an event occur within a given time frame, for example, how many customers visit your store or restaurant every hour. In this post, you will learn about the concepts of Poisson probability distribution with Python examples. As a data scientist, you must get a good understanding of the concepts of probability distributions including normal, binomial, Poisson etc.
Poisson distribution is the discrete probability distribution which represents the probability of occurrence of an event r number of times in a given interval of time or space if these events occur with a known constant mean rate and are independent of each other. This type of probability is used in many cases where events occur randomly, but with a known average rate. The number of events that happen during an interval is dependent on the time elapsed rather than the total time available. The Poisson distribution can be applied to time-sensitive processes such as text messages sent per minute and phone calls received per second. Poisson distribution can help us determine how often we may expect an “event” such as finding customers in line or the number of accidents that occur per hour.
The following are the key criteria that the random variable follows the Poisson distribution.
The random variable X represents the number of times that the event occurs in the given interval of time or space. If a random variable X follows Poisson distribution, it is represented as the following:
X ~ Po([latex]\lambda[/latex])
In the above expression, [latex]\lambda[/latex] represents the mean number of occurrences in a given interval. Mathematically, the Poisson probability distribution can be represented using the following probability mass function:
[latex]\Large P(X=r) = \frac{e^{-\lambda}*\lambda^r}{r!}[/latex]
.
In the above formula, the [latex]\lambda[/latex] represents the mean number of occurrences, r represents different values of random variable X.
The expected value and variance of a Poisson random variable is one and same and given by the following formula. [latex]\lambda[/latex] is the mean number of occurrences in an interval (time or space)
[latex]\Large E(X) = \lambda[/latex]
.
[latex]\Large Var(X) = \lambda[/latex]
.
Here are some real-world examples of Poisson distribution.
Here is how the Python code will look like, along with the plot for the Poisson probability distribution modeling the probability of the different number of restaurants ranging from 0 to 5 that one could find within 10 KM given the mean number of occurrences of the restaurant in 10 KM is 2. Scipy.stats Poisson class is used along with pmf method to calculate the value of probabilities.
from scipy.stats import poisson
import matplotlib.pyplot as plt
#
# Random variable representing number of restaurants
# Mean number of occurences of restaurants in 10 KM is 2
#
X = [0, 1, 2, 3, 4, 5]
lmbda = 2
#
# Probability values
#
poisson_pd = poisson.pmf(X, lmbda)
#
# Plot the probability distribution
#
fig, ax = plt.subplots(1, 1, figsize=(8, 6))
ax.plot(X, poisson_pd, 'bo', ms=8, label='poisson pmf')
plt.ylabel("Probability", fontsize="18")
plt.xlabel("X - No. of Restaurants", fontsize="18")
plt.title("Poisson Distribution - No. of Restaurants Vs Probability", fontsize="18")
ax.vlines(X, 0, poisson_pd, colors='b', lw=5, alpha=0.5)
Here is how the plot representing the Poisson probability distribution of number of restaurants occurring in the range of 10 kms would look like:
Here is how the Python code will look like, along with the plot for the Poisson probability distribution modeling the probability of a different numbers of buses ranging from 0 to 4 that could arrive on the bus stop within 30 min given the mean number of occurrences of buses in 30 min interval is 1.
from scipy.stats import poisson
import matplotlib.pyplot as plt
#
# Random variable representing number of buses
# Mean number of buses coming to bus stop in 30 minutes is 1
#
X = [0, 1, 2, 3, 4]
lmbda = 1
#
# Probability values
#
poisson_pd = poisson.pmf(X, lmbda)
#
# Plot the probability distribution
#
fig, ax = plt.subplots(1, 1, figsize=(8, 6))
ax.plot(X, poisson_pd, 'bo', ms=8, label='poisson pmf')
plt.ylabel("Probability", fontsize="18")
plt.xlabel("X - No. of Buses", fontsize="18")
plt.title("Poisson Distribution - No. of Buses Vs Probability", fontsize="18")
ax.vlines(X, 0, poisson_pd, colors='b', lw=5, alpha=0.5)
Here is how the Poisson probability distribution plot would look like representing the probability of different number of buses coming to the bus stop in next 30 minutes given the mean number of buses that come within 30 min on that stop is 1.
Here are few other examples of Poisson distribution.
Here is the summary of what you learned in this post in relation to Poisson probability distribution:
In recent years, artificial intelligence (AI) has evolved to include more sophisticated and capable agents,…
Adaptive learning helps in tailoring learning experiences to fit the unique needs of each student.…
With the increasing demand for more powerful machine learning (ML) systems that can handle diverse…
Anxiety is a common mental health condition that affects millions of people around the world.…
In machine learning, confounder features or variables can significantly affect the accuracy and validity of…
Last updated: 26 Sept, 2024 Credit card fraud detection is a major concern for credit…
View Comments
Well exemplified!