【问题标题】:if Statement to Override Valueif 语句覆盖值
【发布时间】: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 页。

【问题讨论】:

标签: python list for-loop if-statement statistics


【解决方案1】:

感谢@jfaccioni 的回答;我只想要一个=这样的

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
  if x == n: high = 1
  Low.append(low)
  High.append(high)

【讨论】:

    猜你喜欢
    • 2023-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-19
    • 1970-01-01
    相关资源
    最近更新 更多