Confidence interval on the rate of no-hitters
Consider again the inter-no-hitter intervals for the modern era of baseball. Generate 10,000 bootstrap replicates of the optimal parameter \(\tau\). Plot a histogram of your replicates and report a 95% confidence interval.
This exercise is part of the course
Statistical Thinking in Python (Part 2)
Exercise instructions
- Generate
10000
bootstrap replicates of \(\tau\) from thenohitter_times
data using yourdraw_bs_reps()
function. Recall that the optimal \(\tau\) is calculated as the mean of the data. - Compute the 95% confidence interval using
np.percentile()
and passing in two arguments: The arraybs_replicates
, and the list of percentiles - in this case2.5
and97.5
. - Print the confidence interval.
- Plot a histogram of your bootstrap replicates. This has been done for you, so hit submit to see the plot!
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Draw bootstrap replicates of the mean no-hitter time (equal to tau): bs_replicates
bs_replicates = ____
# Compute the 95% confidence interval: conf_int
conf_int = ____
# Print the confidence interval
print('95% confidence interval =', ____, 'games')
# Plot the histogram of the replicates
_ = plt.hist(bs_replicates, bins=50, normed=True)
_ = plt.xlabel(r'$\tau$ (games)')
_ = plt.ylabel('PDF')
# Show the plot
plt.show()