1. Learn
  2. /
  3. Courses
  4. /
  5. Statistical Thinking in Python (Part 2)

Connected

Exercise

Visualizing bootstrap samples

In this exercise, you will generate bootstrap samples from the set of annual rainfall data measured at the Sheffield Weather Station in the UK from 1883 to 2015. The data are stored in the Numpy array rainfall in units of millimeters (mm). By graphically displaying the bootstrap samples with an ECDF, you can get a feel for how bootstrap sampling allows probabilistic descriptions of data.

Instructions

100 XP
  • Write a for loop to acquire 50 bootstrap samples of the rainfall data and plot their ECDF.
    • Use np.random.choice() to generate a bootstrap sample. Be sure that the length of the resampled array is len(data).
    • Use the function ecdf() that you wrote in the prequel to this course to generate the x and y values for the ECDF of the bootstrap sample, and plot them. Use the color='gray' (to make gray dots) and alpha=0.1 (to make them semi-transparent, since we are overlaying so many).
  • Use ecdf() to generate x and y values for the ECDF of the original rainfall data and plot them as you normally plot ECDFs.
  • Label your axes and specify a 2% margin.
  • Show your plot.