bootstrap可以用来估计样本中任何函数(np.mean,st.genextreme.fit,等等)的置信区间,并且有一个Python库:^{}。在
以下是作者相关问题question中的数据:import numpy as np, scipy.stats as st, scikits.bootstrap as boot
data = np.array([ 22.20379411, 22.99151292, 24.27032696, 24.82180626,
25.23163221, 25.39987272, 25.54514567, 28.56710007,
29.7575898 , 30.15641696, 30.79168255, 30.88147532,
31.0236419 , 31.17380647, 31.61932755, 32.23452568,
32.76262978, 33.39430032, 33.81080069, 33.90625861,
33.9914, 35.45748368, 37.0342621 , 37.14768791,
38.14350221, 42.72699534, 44.16449992, 48.77736737,
49.80441736, 50.57488779])
st.genextreme.fit(data) # just to check the parameters
boot.ci(data, st.genextreme.fit)
结果是
^{pr2}$
在我的机器上引导大约需要3分钟;默认情况下,boot.ci使用10000次引导迭代(n_samples),请参见code或{},并且{}不是超快速的。在
来自boot.ci的置信区间与来自MATLAB的^{}的置信区间不完全匹配。E、 g.,MATLAB给出了第一个参数(0.0144)的对称值[-0.3032,0.3320]。在