Search code examples
pythonrpoisson

How to implement this R Poisson distribution in Python?


I've coded something in R but I can't seem to do the same in Python.

Below is the code - it definitely works in R.

I am having trouble with the Python syntax to achieve the same with numpy.

myMaxAC = qpois(p=as.numeric(0.95),
                lambda=(121412)*(0.005))

For clarity, 0.95 is the confidence interval, 121412 is my population size, and 0.005 is a frequency within the population.

I just want to know how to get the same answer in Python, which incidentally is 648.


Solution

  • You can get this using poisson.ppf:

    from scipy.stats import poisson
    myMaxAC = poisson.ppf(0.95, (121412)*(0.005))
    print(myMaxAC)
    648.0