Created
August 29, 2018 07:43
-
-
Save csetzkorn/f5bbe72d5225151730d60734be3dc4a6 to your computer and use it in GitHub Desktop.
jackknife estimate of median and CI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Leave one observation out to get the jackknife sample and store the median length | |
median_lengths = [] | |
for i in range(n): | |
jk_sample = wrench_lengths[index != i] | |
median_lengths.append(np.median(jk_sample)) | |
median_lengths = np.array(median_lengths) | |
# Calculate jackknife estimate and it's variance | |
jk_median_length = np.mean(median_lengths) | |
jk_var = (n-1)*np.var(median_lengths) | |
# Assuming normality, calculate lower and upper 95% confidence intervals | |
print("Jackknife 95% CI lower = {}, upper = {}".format(jk_median_length - 1.96*np.sqrt(jk_var), jk_median_length + 1.96*np.sqrt(jk_var))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment