jackknife_stats#

astropy.stats.jackknife_stats(data, statistic, confidence_level=0.95)[源代码]#

根据刀切重采样执行刀切估计。

此功能需要 SciPy 待安装。

参数:
data : ndarray恩达雷

原始样本(一维阵列)。

statistic : functionPYTHON:函数

基于测量数据的任何函数(或函数向量),例如样本平均值、样本方差等。将返回该统计量的刀切估计值。

confidence_level : float ,可选Python:Float,可选

刀切估计的置信区间的置信水平。必须是(0,1)中的实数。默认值为0.95。

返回:
estimate : floatndarrayPython :浮点或ndarray

第i个元素是经过偏差修正的“锯齿状”估计值。

bias : floatndarrayPython :浮点或ndarray

第i个元素是锯齿形偏差。

std_err : floatndarrayPython :浮点或ndarray

第i个元素是jackknife标准错误。

conf_interval : ndarray恩达雷

如果 statistic 为单值时,第一个元素和第二个元素分别为上界和下界。如果 statistic 是向量值,每列对应于 statistic . 第一行和第二行分别包含下界和上界。

实例

  1. 获取刀切重采样:

>>> 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])
  1. 两个估计值的示例

>>> 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]])

重要提示:请注意,置信区间以列的形式给出