*** Wartungsfenster jeden ersten Mittwoch vormittag im Monat ***

Skip to content
Snippets Groups Projects
Commit 8f1609aa authored by Patrick Kappl's avatar Patrick Kappl
Browse files

Save jackknife output in HDF5 file

parent 397934fe
No related branches found
No related tags found
No related merge requests found
import numpy as np
import h5py
# TODO: Update docstring
# TODO: Rewrite the docstring with argument descriptions
def do_jackknife_estimation(input_sample_generator, n_samples,
transformation_function):
"""Do a jackknife estimation for the transformed sample.
transformation_function,
output_file_name="jackknife.hdf5"):
"""Do a jackknife estimation for the given samples and function.
Estimate and return the sample mean, variance and standard deviation
of the transformed sample y = f(x), where x is the input sample and
of the transformed value y = f(x), where x is the input sample and
f() is the transformation function. The expectation value <y> is
estimated using the Jackknife algorithm, which does a resampling of
the input x and then a bias-corrected transformation. For more
......@@ -48,10 +52,18 @@ def do_jackknife_estimation(input_sample_generator, n_samples,
output_variance = sum_of_squares - np.abs(sum_)**2 / n_samples
output_variance /= (n_samples - 1)
output_standard_deviation = np.lib.scimath.sqrt(output_variance)
return (output_mean, output_variance, output_standard_deviation,
transformed_mean)
out_file = h5py.File(output_file_name, "w")
out_file.create_dataset("estimated_mean", data=output_mean)
out_file.create_dataset("estimated_variance", data=output_variance)
out_file.create_dataset("estimated_standard_deviation",
data=output_standard_deviation)
out_file.create_dataset("transformed_input_mean", data=transformed_mean)
out_file.close()
return
# TODO: Rewrite the docstring with argument descriptions
def resample_and_transform(sample, n_samples, sample_mean,
transformation_function, transformed_mean):
"""Do a resampling and a bias-corrected transformation.
......
......@@ -5,6 +5,7 @@ import numpy as np
# %%
# TODO: Make the paths and files command line options
abinitio_dga = adga.Adga("/home/pkappl/Programs/ADGA",
"dga.conf", "two_particle_4_worms.hdf5")
x_generator = abinitio_dga.get_worm_sample_generator()
......@@ -12,10 +13,5 @@ n = abinitio_dga.n_worm_samples
f = abinitio_dga.__call__
# %%
# Do a Jackknife estimation with the x-values and f() and print the
# results
output = jackknife.do_jackknife_estimation(x_generator, n, f)
print("{}{}".format("f(mean(x)) = ", output[3]))
print("{}{}".format("mean(y') = ", output[0]))
print("{}{}".format("variance(y') = ", output[1]))
print("{}{}".format("standard deviation(y') = ", output[2]))
# Do the Jackknife estimation
jackknife.do_jackknife_estimation(x_generator, n, f)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment