Get startedGet started for free

Bootstrap replicates of other statistics

We saw in a previous exercise that the mean is Normally distributed. This does not necessarily hold for other statistics, but no worry: as hackers, we can always take bootstrap replicates! In this exercise, you'll 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):
    """Draw bootstrap replicates."""
    # Initialize array of replicates
    bs_replicates = np.empty(size)
    # Generate replicates
    for i in range(size):
        bs_replicates[i] = bootstrap_replicate_1d(data, func)
    return bs_replicates

This exercise is part of the course

Statistical Thinking in Python (Part 2)

View Course

Exercise instructions

  • Draw 10000 bootstrap replicates of the variance in annual rainfall, stored in the rainfall dataset, using your draw_bs_reps() function. Hint: Pass in np.var for computing the variance.
  • Divide your variance replicates (bs_replicates) by 100 to put the variance in units of square centimeters for convenience.
  • Make a histogram of bs_replicates using the normed=True keyword argument and 50 bins.

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()
Edit and Run Code