mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 14:50:25 +01:00
test_jackknife added
This commit is contained in:
parent
69d786c155
commit
331d7cb471
2 changed files with 16 additions and 1 deletions
|
@ -562,7 +562,7 @@ class Obs:
|
|||
|
||||
Returns
|
||||
-------
|
||||
np.ndarray
|
||||
numpy.ndarray
|
||||
Returns a numpy array of length N + 1 where N is the number of samples
|
||||
for the given ensemble and replicum. The zeroth entry of the array contains
|
||||
the mean value of the Obs, entries 1 to N contain the N jackknife samples
|
||||
|
|
|
@ -504,3 +504,18 @@ def test_covariance2_symmetry():
|
|||
cov_ba = pe.covariance2(a, test_obs1)
|
||||
assert np.abs(cov_ab - cov_ba) <= 10 * np.finfo(np.float64).eps
|
||||
assert np.abs(cov_ab) < test_obs1.dvalue * test_obs2.dvalue * (1 + 10 * np.finfo(np.float64).eps)
|
||||
|
||||
|
||||
def test_jackknife():
|
||||
full_data = np.random.normal(1.1, 0.87, 5487)
|
||||
|
||||
my_obs = pe.Obs([full_data], ['test'])
|
||||
|
||||
n = full_data.size
|
||||
mean = np.mean(full_data)
|
||||
tmp_jacks = np.zeros(n + 1)
|
||||
tmp_jacks[0] = mean
|
||||
for i in range(n):
|
||||
tmp_jacks[i + 1] = (n * mean - full_data[i]) / (n - 1)
|
||||
|
||||
assert np.allclose(tmp_jacks, my_obs.export_jackknife())
|
||||
|
|
Loading…
Add table
Reference in a new issue