python中的单边泊松置信区间
考虑到在另一个问题中作为答案给出的代码:python中的单边泊松置信区间,python,statistics,poisson,Python,Statistics,Poisson,考虑到在另一个问题中作为答案给出的代码: 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,
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
这段代码返回一个双边置信区间,但是如果我希望它是单边的,我将如何执行呢。由于泊松分布是不对称的,这就更加复杂了。任何帮助都将不胜感激。我认为您应该将
a/2
更改为a
或0
,因为它表明了间隔的位置:
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(0, 2*k) / 2, chi2.ppf(1-a, 2*k + 2) / 2)
if k == 0:
low = 0.0
return low, high
告诉我它是否有效。high=poisson.ppf(a,mu);高回报?