Problems
Loading...
1 / 1

Poisson Probability Mass Function & Cumulative Distribution Function

Probability and Statistics
Medium

Implement the Poisson distribution Probability Mass Function (PMF) and Cumulative Distribution Function (CDF). The Poisson distribution models the count of events in a fixed interval with average rate λ.

Poisson Distribution:

Probability Mass Function:

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

Cumulative Distribution Function:

P(Xk)=i=0keλλii!P(X \le k) = \sum_{i=0}^{k} \frac{e^{-\lambda} \lambda^{i}}{i!}

Function Arguments

  • lam: float - Rate parameter (λ > 0)
  • k: int - Number of events (k ≥ 0)
Loading visualization...

Examples

Input: lam=3, k=2

Output: pmf≈0.2240, cdf≈0.4232

Input: lam=2.5, k=0

Output: pmf≈0.0821, cdf≈0.0821

Input: lam=1.0, k=1

Output: pmf≈0.3679, cdf≈0.7358

Hint 1

Use np.log() and np.exp() for numerical stability in factorial computation.

Hint 2

For CDF, sum PMF values from i=0 to k using a loop.

Hint 3

Use np.sum(np.log(np.arange(1, k+1))) for log factorial.

Requirements

  • Return tuple: (pmf, cdf)
  • Both pmf and cdf: scalar floats
  • Use stable log factorial computation
  • No loops over factorial calculation

Constraints

  • λ > 0, k ≥ 0 ≤ 50
  • NumPy only; time limit: 300ms
Try Similar Problems