Skip to main content

Introduction to Python Poisson Distribution

Python Poisson Distribution

The Poisson distribution is a discrete probability distribution that models the number of events that occur in a fixed interval of time or space, given the average rate of occurrence.

It is often used to model rare events or events that occur randomly and independently of each other.

The probability mass function (PMF) of the Poisson distribution is given by the following formula:

P(X = k) = (e^(-λ) * λ^k) / k!

Where:

  • P(X = k) is the probability of observing exactly k events.
  • e is the base of the natural logarithm (approximately 2.71828).
  • λ (lambda) is the average rate of events in the given interval.
  • k is the number of events.

In Python, you can use the scipy.stats.poisson module from the SciPy library to work with the Poisson distribution.

The poisson.pmf() function can be used to calculate the probability mass function for a specific value of k.

As an example:

from scipy.stats import poisson

# Define the average rate of events
lambda_ = 2.5

# Calculate the probability of observing exactly k events
k = 3
probability = poisson.pmf(k, lambda_)
print("Probability of observing exactly", k, "events:", probability)

In this example:

  • We use the poisson.pmf(k, lambda_) function to calculate the probability of observing exactly 3 events, given an average rate of 2.5 events.
  • The result is stored in the variable probability and printed.

You can also use other functions from the scipy.stats.poisson module to calculate other properties of the Poisson distribution, such as the cumulative distribution function (poisson.cdf()), the mean (poisson.mean()), the variance (poisson.var()), and more.

Difference Between Normal and Poisson Distribution

The main differences between the normal distribution and the Poisson distribution are as follows:

Continuity vs. Discreteness

The normal distribution is a continuous probability distribution, meaning that its values can take any real number within a given range. On the other hand, the Poisson distribution is a discrete probability distribution, which means its values are restricted to non-negative integers.

Shape

The normal distribution is symmetric and bell-shaped, characterized by its mean and standard deviation. It has a smooth, continuous probability density function. The Poisson distribution, on the other hand, is a skewed distribution with a longer right tail. It is characterized by a single parameter, usually denoted as lambda (λ), which represents the average rate of events.

Applications

The normal distribution is commonly used to model continuous random variables, such as measurements, heights, weights, and errors, which follow a symmetric and bell-shaped distribution. It is also used in statistical inference and hypothesis testing. The Poisson distribution, on the other hand, is often used to model the number of discrete events that occur in a fixed interval of time or space, such as the number of phone calls received per hour or the number of accidents at an intersection.

Independence

In the normal distribution, the probability of an event does not depend on the occurrence of any other event. Each observation is assumed to be independent. In the Poisson distribution, the occurrence of events is assumed to be independent, meaning that the number of events in one interval does not affect the number of events in another interval.

Parameterization

The normal distribution is parameterized by the mean (μ) and the standard deviation (σ). These parameters define the location and spread of the distribution. The Poisson distribution is parameterized by a single parameter, lambda (λ), which represents the average rate of events. The mean and variance of the Poisson distribution are both equal to lambda.