def poisson_interval(k, alpha=0.05):
    """
    uses chisquared info to get the poisson interval. Uses scipy.stats 
    (imports in function). 
    """
from scipy.stats import chi2
a = alpha
low, high = chi2.ppf(a / 2, 2 * k) / 2, chi2.ppf(1 - a / 2, 2 * k + 2) / 2
if k == 0:
    low = 0.0
return low, high
Poisson confidence interval with numpy