python中给定上下限数组和平均值的置信区间

2024-09-28 03:21:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我计算了250次测量的平均值、上限和下限。我有三个250个元素的数组。现在我想生成置信区间,我用一种简单的方法来实现

fig = plt.figure(figsize=(8,8))
fig.subplots_adjust(wspace=1.,hspace=1.)

indx = np.argsort(hat_y[:,0])

ysmoothed = gaussian_filter1d(hat_y[indx,0], sigma=2)
plt.plot(ysmoothed, label="average")

uppersmooth = gaussian_filter1d(hat_y[indx,0]+1.96*np.sqrt(var_y[indx,0]*1.0/np.sqrt(B)),2)
plt.plot(uppersmooth, linestyle='-', linewidth=1, label="upper bound")

lowersmooth = gaussian_filter1d(hat_y[indx,0]-1.96*np.sqrt(var_y[indx,0]*1.0/np.sqrt(B)),2)
plt.plot(lowersmooth, linestyle='-', linewidth=1, label="lower bound")

是否有一种方法可以将三个数组(平均、上限、下限)作为输入参数,并在python中生成点图,以显示每个测量的不确定性

与seaborn point绘图类似: enter image description here


Tags: 方法plotvarhatnpfigpltsqrt

热门问题