Exercise

Sampling with replacement

Bootstrapping is great for calculating confidence intervals for means; you'll now practice doing just that!

nba_weights contains the weights of a group of NBA players in kilograms:

nba_weights = [96.7, 101.1, 97.9, 98.1, 98.1, 
               100.3, 101.0, 98.0, 97.4]

You are interested in calculating the 95% confidence interval of the mean weight of NBA players using this list.

The following have been imported for you: random, and numpy as np.

Instructions

100 XP
  • Use random.choices() to sample nine heights from the list 1,000 times, with replacement.
  • Calculate the mean and 95% confidence interval for your simulation results, assigning the lower end of the confidence interval to lower and the upper end to upper.