← back

Poisson Distribution Probability Calculator

#81 · Probability · Easy

⊣ Solve on deep-ml.com

Problem

Calculate the probability of observing exactly k events in a fixed interval using the Poisson distribution, given the average rate lambda.

Solution

1
2
3
4
5
import math

def poisson_probability(lam, k):
    probability = (lam ** k) * math.exp(-lam) / math.factorial(k)
    return round(probability, 4)

Explanation

  1. The Poisson PMF formula is: P(X = k) = (lambda^k * e^(-lambda)) / k!
  2. lambda^k: expected rate raised to the power of observed events.
  3. e^(-lambda): decay factor ensuring probabilities sum to 1.
  4. k!: accounts for the number of orderings of k events.
  5. Used to model the number of events occurring in a fixed interval (e.g., arrivals per hour, defects per batch).

Complexity

  • Time: O(k) for computing factorial
  • Space: O(1)