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.
Deze oefening maakt deel uit van de cursus
Statistical Thinking in Python (Part 2)
Oefeninstructies
- Generate
10000bootstrap replicates of \(\tau\) from thenohitter_timesdata 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.5and97.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!
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# 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()