Poisson: Exactly k Events, and k or Fewer

Probability and StatisticsMedium+10 XP+10

Poisson: Exactly k Events, and k or Fewer

A Poisson variable counts how many times a rare event happens in a fixed window, given it happens at an average rate lambda. Unlike Binomial, there's no fixed number of trials — events can happen any number of times.

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

Task: write poisson_pmf_cdf(lam, k) returning [pmf, cdf], each rounded to 4 decimal places, where cdf = P(X \le k).

  • lam is the rate λ — the expected number of events in the window.
  • When k is close to lam, the pmf sits near its peak — that's the most likely single outcome.

Examples

lam = 3
k = 2
returns [0.224, 0.4232]
lam = 5
k = 5
returns [0.1755, 0.616]

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run