Bootstrap replicates of other statistics
We saw in a previous exercise the the mean is Normally distributed. This does not necessarily hold for other statistics, but no worry: as hackers, we can always take bootstrap replicates! Generate bootstrap replicates for the variance of the annual rainfall at the Sheffield Weather Station and plot the histogram of the replicates.
Here, you will make use of the draw_bs_reps() function you defined a few exercises ago. It is provided below for your reference:
def draw_bs_reps(data, func, size=1):
return np.array([bootstrap_replicate_1d(data, func) for _ in range(size)])
This exercise is part of the course
Statistical Thinking in Python (Part 2)
Exercise instructions
- Draw 10,000 bootstrap replicates of the variance in annual rainfall using your
draw_bs_reps()function. Hint: Pass innp.varfor computing the variance. - Divide you variance replicates by 100 to put the variance in units of square centimeters for convenience.
- Make a histogram of the replicates using the
normed=Truekeyword argument and 50 bins. Be sure to label the axes. - Show your plot.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Generate 10,000 bootstrap replicates of the variance: bs_replicates
bs_replicates = ____
# Put the variance in units of square centimeters
____
# Make a histogram of the results
_ = plt.hist(____, ____, ____)
_ = plt.xlabel('variance of annual rainfall (sq. cm)')
_ = plt.ylabel('PDF')
# Show the plot
plt.show()