Basic jackknife estimation - mean
Jackknife resampling is an older procedure, which isn't used as often compared as bootstrapping. However, it's still useful to know how to run a basic jackknife estimation procedure. In this first exercise, we will calculate the jackknife estimate for the mean. Let's return to the wrench factory.
You own a wrench factory and want to measure the average length of the wrenches to ensure that they meet some specifications. Your factory produces thousands of wrenches every day, but it's infeasible to measure the length of each wrench. However, you have access to a representative sample of 100 wrenches. Let's use jackknife estimation to get the average lengths.
Examine the variable wrench_lengths
in the shell.
This is a part of the course
“Statistical Simulation in Python”
Exercise instructions
- Get a jackknife sample by iteratively leaving one observation out of
wrench_lengths
and assigning it tojk_sample
. - Calculate the mean of
jk_sample
and append it tomean_lengths
. - Finally, calculate the jackknife estimate
mean_lengths_jk
as the mean of themean_lengths
array.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Leave one observation out from wrench_lengths to get the jackknife sample and store the mean length
mean_lengths, n = [], len(wrench_lengths)
index = np.arange(n)
for i in range(n):
jk_sample = ____[index != i]
mean_lengths.append(____)
# The jackknife estimate is the mean of the mean lengths from each sample
mean_lengths_jk = ____(np.array(mean_lengths))
print("Jackknife estimate of the mean = {}".format(mean_lengths_jk))
This exercise is part of the course
Statistical Simulation in Python
Learn to solve increasingly complex problems using simulations to generate and analyze data.
In this chapter, we will get a brief introduction to resampling methods and their applications. We will get a taste of bootstrap resampling, jackknife resampling, and permutation testing. After completing this chapter, students will be able to start applying simple resampling methods for data analysis.
Exercise 1: Introduction to resampling methodsExercise 2: Sampling with replacementExercise 3: Probability exampleExercise 4: BootstrappingExercise 5: Running a simple bootstrapExercise 6: Non-standard estimatorsExercise 7: Bootstrapping regressionExercise 8: Jackknife resamplingExercise 9: Basic jackknife estimation - meanExercise 10: Jackknife confidence interval for the medianExercise 11: Permutation testingExercise 12: Generating a single permutationExercise 13: Hypothesis testing - Difference of meansExercise 14: Hypothesis testing - Non-standard statisticsWhat is DataCamp?
Learn the data skills you need online at your own pace—from non-coding essentials to data science and machine learning.