Skip to content

Instantly share code, notes, and snippets.

@csetzkorn
Created August 29, 2018 07:43
Show Gist options
  • Save csetzkorn/f5bbe72d5225151730d60734be3dc4a6 to your computer and use it in GitHub Desktop.
Save csetzkorn/f5bbe72d5225151730d60734be3dc4a6 to your computer and use it in GitHub Desktop.
jackknife estimate of median and CI
# 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