Contents:
The module resampling can be used for estimating errors of of non-linear functions of random measurements.
It can be used mainly for the analysis of Markov chain Monte Carlo methods.
Compute the bootstrap mean and error of an array with respect to a given function.
| Parameters : | a : array_like
iterations: int
func: callable function
func_axis: integer, optional
dtype : data-type, optional
|
|---|
Examples
>>> a = numpy.random.normal(loc=5.0, scale=2.0, size=1000)
>>> mean_a, error_a = bootstrap(a, 100)
>>> (mean_a > 4.9, mean_a < 5.1)
(True, True)
>>> (error_a > 2.0/math.sqrt(1000 - 1) - 0.01, error_a < 2.0/math.sqrt(1000 - 1) + 0.01)
(True, True)
Identity function used as default function in the resampling methods.
Compute the jackknife mean and error of an array (with \(N\) values) with respect to a given function \(f\).
| Parameters : | a : array_like
func: callable function, optional
func_axis: integer, optional
dtype : data-type, optional
|
|---|---|
| Returns : | jackknife_mean : dtype
jackknife_error: dtype
|
Notes
The single jackknife values are calculated by
and the mean \(\overline f\) and the error \(\sigma_{\overline f}\) of the function \(f\) are calculated using
References
| [R1] |
|
| [R2] |
|
Examples
>>> a = numpy.array([1.0, 2.0, 3.0, 4.0, 5.0])
>>> jackknife(a)
(3.0, 0.70710678118654757)
>>> jackknife(a, func=lambda x: x**2)
(9.125, 4.247793544888923)
>>> b = numpy.array([[1.0, 2.0, 3.0, 4.0, 5.0], [1.0, 3.0, 5.0, 7.0, 9.0]])
>>> jackknife(b, func=lambda x,y: x*y, func_axis=0)
Compute the subsampling mean and error of an array with respect to a given function.
| Parameters : | a : array_like
iterations: int
samples: int
func: callable function
func_axis: integer, optional
dtype : data-type, optional
|
|---|
Examples
>>> a = numpy.random.normal(loc=5.0, scale=2.0, size=1000)
>>> mean_a, error_a = subsampling(a, 100, 50)
>>> (mean_a > 4.9, mean_a < 5.1)
(True, True)
>>> (error_a > 2.0/math.sqrt(1000 - 1) - 0.01, error_a < 2.0/math.sqrt(1000 - 1) + 0.01)
(True, True)