def jackknife_stats(data, statistic, conf_lvl=0.95):
 from scipy.special import erfinv
 n = data.shape[0]
 assert (n > 0), u'data must contain at least one measurement'
 resamples = jackknife_resampling(data)
 stat_data = statistic(data)
 jack_stat = np.apply_along_axis(statistic, 1, resamples)
 mean_jack_stat = np.mean(jack_stat, axis=0)
 bias = ((n - 1) * (mean_jack_stat - stat_data))
 std_err = np.sqrt(((n - 1) * np.mean(((jack_stat - mean_jack_stat) * (jack_stat - mean_jack_stat)), axis=0)))
 estimate = (stat_data - bias)
 assert ((conf_lvl > 0) and (conf_lvl < 1)), u'confidence level must be in (0, 1).'
 z_score = (np.sqrt(2.0) * erfinv(conf_lvl))
 conf_interval = (estimate + (z_score * np.array(((- std_err), std_err))))
 return (estimate, bias, std_err, conf_interval)

def jackknife_stats ( data , statistic , conf_lvl = 0.95 ) : from scipy . special import erfinv n = data . shape [ 0 ] assert ( n > 0 ) , u'data must contain at least one measurement' resamples = jackknife_resampling ( data ) stat_data = statistic ( data ) jack_stat = np . apply_along_axis ( statistic , 1 , resamples ) mean_jack_stat = np . mean ( jack_stat , axis = 0 ) bias = ( ( n - 1 ) * ( mean_jack_stat - stat_data ) ) std_err = np . sqrt ( ( ( n - 1 ) * np . mean ( ( ( jack_stat - mean_jack_stat ) * ( jack_stat - mean_jack_stat ) ) , axis = 0 ) ) ) estimate = ( stat_data - bias ) assert ( ( conf_lvl > 0 ) and ( conf_lvl < 1 ) ) , u'confidence level must be in (0, 1).' z_score = ( np . sqrt ( 2.0 ) * erfinv ( conf_lvl ) ) conf_interval = ( estimate + ( z_score * np . array ( ( ( - std_err ) , std_err ) ) ) ) return ( estimate , bias , std_err , conf_interval )
performs jackknife estimation on the basis of jackknife resamples .