LoslegenKostenlos loslegen

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.

Diese Übung ist Teil des Kurses

Statistical Thinking in Python (Part 2)

Kurs anzeigen

Anleitung zur Übung

  • Generate 10000 bootstrap replicates of \(\tau\) from the nohitter_times data using your draw_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 array bs_replicates, and the list of percentiles - in this case 2.5 and 97.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!

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# 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()
Code bearbeiten und ausführen