Show 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.
What is Poisson distribution?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(\(\lambda\)) In the above expression, \(\lambda\) represents the mean number of occurrences in a given interval. Mathematically, the Poisson probability distribution can be represented using the following probability mass function: \(\Large P(X=r) = \frac{e^{-\lambda}*\lambda^r}{r!}\) . In the above formula, the \(\lambda\) represents the mean number of occurrences, r represents different values of random variable X. Expectation & Variance of Poisson DistributionThe expected value and variance of a Poisson random variable is one and same and given by the following formula. \(\lambda\) is the mean number of occurrences in an interval (time or space) \(\Large E(X) = \lambda\) . \(\Large Var(X) = \lambda\) . Poisson Distribution Explained with Real-world examplesHere 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: Fig 1. Poisson Probability Distribution (X = No. of Restaurants in 10 KM)
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. Fig 2. Poisson Probability Distribution (X = No. of Buses in 30 Min)Here are few other examples of Poisson distribution.
ConclusionsHere is the summary of what you learned in this post in relation to Poisson probability distribution:
I have been recently working in the area of Data analytics including Data Science and Machine Learning / Deep Learning. I am also passionate about different technologies including programming languages such as Java/JEE, Javascript, Python, R, Julia, etc, and technologies such as Blockchain, mobile computing, cloud-native technologies, application security, cloud computing platforms, big data, etc. For latest updates and blogs, follow us on Twitter. I would love to connect with you on Linkedin. Check out my latest book titled as First Principles Thinking: Building winning products using first principles thinking Ajitesh KumarI have been recently working in the area of Data analytics including Data Science and Machine Learning / Deep Learning. I am also passionate about different technologies including programming languages such as Java/JEE, Javascript, Python, R, Julia, etc, and technologies such as Blockchain, mobile computing, cloud-native technologies, application security, cloud computing platforms, big data, etc. For latest updates and blogs, follow us on Twitter. I would love to connect with you on Linkedin. Check out my latest book titled as First Principles Thinking: Building winning products using first principles thinking |