jeudi 28 mai 2020

if Statement to Override Value

I'm trying to implement this formula from a paper (ref):

enter image description here

I tried:

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)

But that gives me this:

enter image description here

My if statements are supposed to override the values of low and high when x=0 or x=n. How can I get them to work please?

ref: Brown, L.D., Cai, T.T. and DasGupta, A., 2001. Interval estimation for a binomial proportion. Statistical science, pp.101-117.

Aucun commentaire:

Enregistrer un commentaire