Using scipy.stats.poisson and the interval method:
>>> scipy.stats.poisson.interval(0.95, [10, 20, 30]) (array([ 4., 12., 20.]), array([ 17., 29., 41.]))
Although calculating the Poisson distribution for non-integer values has limited meaning, it is possible to calculate the exact confidence intervals requested by the OP, which can be done as follows:
>>> data = np.array([10, 20, 30]) >>> scipy.stats.poisson.interval(0.95, data) (array([ 4., 12., 20.]), array([ 17., 29., 41.])) >>> np.array(scipy.stats.chi2.interval(.95, 2 * data)) / 2 - 1 array([[ 3.7953887 , 11.21651959, 19.24087402], [ 16.08480345, 28.67085357, 40.64883744]])
You can also use the ppf method:
>>> data = np.array([10, 20, 30]) >>> scipy.stats.poisson.ppf([0.025, 0.975], data[:, None]) array([[ 4., 17.], [ 12., 29.], [ 20., 41.]])
But since the distribution is discrete, the returned values will be integers, and the confidence interval will not be 95%:
>>> scipy.stats.poisson.ppf([0.025, 0.975], 10) array([ 4., 17.]) >>> scipy.stats.poisson.cdf([4, 17], 10) array([ 0.02925269, 0.98572239])