Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python中的单边泊松置信区间_Python_Statistics_Poisson - Fatal编程技术网

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);高回报?