Lesson 11 of 15

Poisson & Exponential Distributions

Rare Events and Waiting Times

Poisson Distribution

XPoisson(λ)X \sim \text{Poisson}(\lambda) counts the number of rare events in a fixed interval, where λ\lambda is the average rate:

P(X=k)=eλλkk!P(X = k) = \frac{e^{-\lambda} \lambda^k}{k!}

E[X]=λ,Var(X)=λE[X] = \lambda, \qquad \text{Var}(X) = \lambda

Examples: customers arriving per hour, mutations per genome, photons hitting a detector.

Exponential Distribution

TExponential(λ)T \sim \text{Exponential}(\lambda) models the waiting time between consecutive Poisson events:

f(t)=λeλt,t0f(t) = \lambda e^{-\lambda t}, \quad t \geq 0

F(t)=P(Tt)=1eλtF(t) = P(T \leq t) = 1 - e^{-\lambda t}

E[T]=1λ,Var(T)=1λ2E[T] = \frac{1}{\lambda}, \qquad \text{Var}(T) = \frac{1}{\lambda^2}

Memoryless property: P(T>s+tT>s)=P(T>t)P(T > s + t \mid T > s) = P(T > t). The distribution forgets how long you have already waited.

import math

lam = 2.0  # 2 events per hour on average

# P(exactly 2 events in one hour)
pmf = math.exp(-lam) * lam**2 / math.factorial(2)
print(round(pmf, 4))   # 0.2707

# P(wait ≤ 1 hour for next event)
cdf = 1 - math.exp(-lam * 1.0)
print(round(cdf, 4))   # 0.8647

Your Task

Implement poisson_and_exponential(lam, k, x) that prints:

  1. Poisson PMF: P(K=k)P(K=k)
  2. Exponential CDF: P(Tx)P(T \leq x)
  3. Exponential mean: 1/λ1/\lambda

All rounded to 4 decimal places.

Pyodide loading...
Loading...
Click "Run" to execute your code.