jackknife_stats#
- astropy.stats.jackknife_stats(data, statistic, confidence_level=0.95)[源代码]#
根据刀切重采样执行刀切估计。
此功能需要 SciPy 待安装。
- 参数:
- 返回:
- estimate :
float
或ndarray
Python :浮点或ndarray 第i个元素是经过偏差修正的“锯齿状”估计值。
- bias :
float
或ndarray
Python :浮点或ndarray 第i个元素是锯齿形偏差。
- std_err :
float
或ndarray
Python :浮点或ndarray 第i个元素是jackknife标准错误。
- conf_interval :
ndarray
恩达雷 如果
statistic
为单值时,第一个元素和第二个元素分别为上界和下界。如果statistic
是向量值,每列对应于statistic
. 第一行和第二行分别包含下界和上界。
- estimate :
实例
获取刀切重采样:
>>> import numpy as np >>> from astropy.stats import jackknife_resampling >>> from astropy.stats import jackknife_stats >>> data = np.array([1,2,3,4,5,6,7,8,9,0]) >>> resamples = jackknife_resampling(data) >>> resamples array([[2., 3., 4., 5., 6., 7., 8., 9., 0.], [1., 3., 4., 5., 6., 7., 8., 9., 0.], [1., 2., 4., 5., 6., 7., 8., 9., 0.], [1., 2., 3., 5., 6., 7., 8., 9., 0.], [1., 2., 3., 4., 6., 7., 8., 9., 0.], [1., 2., 3., 4., 5., 7., 8., 9., 0.], [1., 2., 3., 4., 5., 6., 8., 9., 0.], [1., 2., 3., 4., 5., 6., 7., 9., 0.], [1., 2., 3., 4., 5., 6., 7., 8., 0.], [1., 2., 3., 4., 5., 6., 7., 8., 9.]]) >>> resamples.shape (10, 9)
2获得平均值、偏差、标准误差及其95%置信区间的刀切估计值:
>>> test_statistic = np.mean >>> estimate, bias, stderr, conf_interval = jackknife_stats( ... data, test_statistic, 0.95) >>> estimate 4.5 >>> bias 0.0 >>> stderr 0.95742710775633832 >>> conf_interval array([2.62347735, 6.37652265])
两个估计值的示例
>>> test_statistic = lambda x: (np.mean(x), np.var(x)) >>> estimate, bias, stderr, conf_interval = jackknife_stats( ... data, test_statistic, 0.95) >>> estimate array([4.5 , 9.16666667]) >>> bias array([ 0. , -0.91666667]) >>> stderr array([0.95742711, 2.69124476]) >>> conf_interval array([[ 2.62347735, 3.89192387], [ 6.37652265, 14.44140947]])
重要提示:请注意,置信区间以列的形式给出