NumPy Poisson Distribution

The Poisson distribution models how many times a rare, independent event happens in a fixed interval of time or space, and np.random.poisson generates samples from it using a single rate parameter.

Counting Random Events

The Poisson distribution describes the number of times an event occurs within a fixed interval, given a known average rate, when each occurrence happens independently of the others. Typical examples include the number of emails arriving per hour, cars passing an intersection per minute, typos per page of a manuscript, or customers walking into a shop per hour.

Example

import numpy as np

np.random.seed(50)

# Simulate emails received in 10 separate one-hour windows,
# averaging 5 emails per hour
emails_per_hour = np.random.poisson(lam=5, size=10)
print(emails_per_hour)

The lam Parameter (Rate)

np.random.poisson(lam, size) uses lam, short for lambda, to represent the expected average number of occurrences per interval. It must be a positive number, and unusually, both the mean and the variance of a Poisson distribution are equal to lam. The size argument controls how many interval-samples are drawn, exactly as with the other random functions in this module.

Example

import numpy as np

np.random.seed(51)

# Low-rate event: about 1 occurrence per interval
rare = np.random.poisson(lam=1, size=8)

# High-rate event, arranged into a 3x4 grid of intervals
frequent = np.random.poisson(lam=20, size=(3, 4))

print("Rare event counts:", rare)
print("Frequent event counts:")
print(frequent)

Poisson vs Binomial

The Poisson distribution can be thought of as a limiting case of the binomial distribution: if you imagine slicing an interval into an enormous number of tiny trials n, each with a tiny success probability p, so that n times p stays fixed at lam, the binomial counts converge to a Poisson distribution. This makes Poisson the right tool when you know the average rate of a rare event but have no natural fixed number of trials to count, unlike binomial where n is explicit.

Note: lam must be zero or positive, and every value np.random.poisson returns is a non-negative whole number - it represents a count, so negative results or fractional results are never possible.
  • Call center volume: number of calls received per minute.
  • Website traffic: number of hits or errors logged per minute.
  • Manufacturing: number of defects found per batch or per meter of material.
  • Networking: number of packets arriving at a server per second.
  • Insurance and risk modeling: number of rare claims filed per year.
ParameterMeaning
lamExpected average number of occurrences per interval
sizeNumber of intervals (samples) to simulate

Example

import numpy as np

np.random.seed(52)

# Customer arrivals per minute over a 60-minute period, averaging 3 per minute
arrivals = np.random.poisson(lam=3, size=60)

print("Simulated average arrivals per minute:", np.mean(arrivals))
print("Minutes with zero arrivals:", np.sum(arrivals == 0))

Exercise: NumPy Poisson Distribution

What does the lam parameter in np.random.poisson() represent?