【发布时间】:2020-05-28 12:30:04
【问题描述】:
我正在尝试从论文中实现这个公式(ref):
我试过了:
import statsmodels.api
n = 1 # samples
x = 1 # positive results
# Range of significance
Min=0
Max=1
Step=.01
Alpha = np.arange(Min,Max+Step,Step)
Low = []
High = []
for A in Alpha:
low, high = statsmodels.stats.proportion.proportion_confint(x, n, alpha=A, method='jeffreys')
if x == 0: low == 0 # these lines
if x == n: high == 1 # aren't working
Low.append(low)
High.append(high)
但这给了我这个:
我的 if 语句应该覆盖 low 和 high 当 x=0 或 x=n。请问我怎样才能让他们工作?
参考:Brown, L.D.、Cai, T.T. 和 DasGupta, A., 2001。二项式比例的区间估计。统计科学,第 101-117 页。
【问题讨论】:
-
将 if 子句
low == 0和high == 1分别更改为low = 0和high = 1。
标签: python list for-loop if-statement statistics