# How to calculate poisson approximation?

I have a p-value definition as follows and I would like to implement it.

The values of n1, n2, n3, n4, n5 and N are as follows.

n1 = 102
n2 = 95

Calculating λ:

n3 = 1350
n4 = 3588
n5 = 886
N = 10382

So my λ would be 421.41

I followed scipy.stats.poisson documentation: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.poisson.html

from scipy.stats import poisson

However, scipy provides number of methods to calculate poisson value as;

rvs(mu, loc=0, size=1, random_state=None)   Random variates.
pmf(k, mu, loc=0)   Probability mass function.
etc.

I am still not sure what method I should use to get the summation of poisson vales from i = n1+n2, ...., ∞.

NOTE: I am not limited to scipy and would like to receive answers using python or R.

I am happy to provide more details if needed.

The p-value definition that you want to implement is the probability that a Poisson random variable with parameter $$\lambda$$ is greater than $$n_{1} + n_{2}$$. If $$X\sim Poisson(\lambda)$$, then $$\sum_{i=n_{1} + n_{2}}^{\infty} e^{-\lambda} \frac{\lambda^{i}}{i!}=\mathbb{P}(X \geq n_{1} + n_{2}) = 1 - \mathbb{P}(X \leq n_{1} + n_{2} - 1)$$.
In R, you can use the ppois(q, lambda, lower.tail) function with $$q = n_{1} + n_{2}$$, $$lambda = \lambda$$ and lower.tail = FALSE to calculate $$\mathbb{P}(X \geq n_{1} + n_{2})$$.
I have never used Python, but the page you link to has two function that I think that you can use. You can use the cdf(k, mu, loc=0) function with $$k = n_{1} + n_{2}-1$$ and $$mu = \lambda$$. Alternatively, you can use the sf(k, mu, loc=0) function with $$k = n_{1} + n_{2}$$ and $$mu = \lambda$$.