Search code examples
pythondistributionpoisson

Poisson random variable in python


Assume that number of calls that some call center receives during one minute is Poisson random variable with parameter λ=2. Use Python to find probability that number of calls is larger than 5. Enter number with first 5 digits after the decimal point.

I wonder if I understand and solve this task correctly using scipy.stats.poisson?

from scipy.stats import poisson
import numpy as np

mu = 2  # lambda
k = 6  # number of calls is larger than 5?
pmf = poisson.pmf(k, mu)
print(pmf)

My output is 0.012029802954365565

Here is the second part of the task:

Assume now that one operator can handle one call in one minute. If call is not handled, it's missed. How many operators should I hire to be sure that probability to miss a call during one minute is not larger than 0.05? Of course I want to minimize number of operators hired.

Hint: scipy.stats random variables have .ppf method that calculates percent point function (also known as quantile function) that is inverse function for CDF. For any value p it finds a minimal value q such that CDF(q)≥p.

ppf = poisson.ppf(cdf, mu)

Am I using ppf correctly? It gives 5.0 as answer.


Solution

  • pmf stands for Probability mass function, which means you have the probability that 6 calls arrive in one minute. I think you look for the Cumulative distribution function cdf = 1- poisson.cdf(k=5, mu). Since the F(x) = P(X <= x), where x=5.