Poisson Probability Mass Function & Cumulative Distribution Function
Poisson Probability Mass Function & Cumulative Distribution Function
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)=k!e−λλkCumulative Distribution Function:
P(X≤k)=i=0∑ki!e−λλiFunction Arguments
lam: float- Rate parameter (λ > 0)k: int- Number of events (k ≥ 0)
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
Log in to take notes on this problem
Accepts: number
Accepts: number
Poisson Probability Mass Function & Cumulative Distribution Function
Poisson Probability Mass Function & Cumulative Distribution Function
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)=k!e−λλkCumulative Distribution Function:
P(X≤k)=i=0∑ki!e−λλiFunction Arguments
lam: float- Rate parameter (λ > 0)k: int- Number of events (k ≥ 0)
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
Log in to take notes on this problem
Accepts: number
Accepts: number