将置信区间计算为分位数

时间:2019-06-06 08:33:36

标签: python confidence-interval

我需要找到95%的置信区间为2.5和97.5个分位数

boot_mean_diff = []
for i in range(3000):
    boot_before = before_proportion
    boot_after = after_proportion
    boot_mean_diff.append(boot_after.mean()-boot_before.mean())

# Calculating a 95% confidence interval from boot_mean_diff 
boot_mean_diff=pd.Series(boot_mean_diff)
#boot_mean_diff1=boot.boot_mean_diff(frac=1,replace=True)
confidence_interval = pd.Series(boot_mean_diff).quantile([0.025,0.975])
confidence_interval

但是,我在下面得到了错误----

  

AssertionError:置信区间应计算为boot_mean_diff的[0.025,0.975]分位数。

1 个答案:

答案 0 :(得分:0)

我也面临着同样的错误。试试下面的代码

   didParseCell: data => {   
         if (data.cell && $(data.cell.raw).data('subhead') == true) {  
             console.log('Subheader Found;')
             data.cell.styles.halign = 'center'; 
         }             
   }

我将import numpy用作np,因此使用了np.mean() 您可以直接尝试使用boot_after.mean()