노히터 발생률의 신뢰구간
현대 야구 시대의 노히터 간격(inter-no-hitter intervals)을 다시 살펴봅시다. 최적 매개변수 $\tau$의 부트스트랩 복제본 10,000개를 생성하세요. 복제본의 히스토그램을 그리고 95% 신뢰구간을 보고하세요.
이 연습은 강의의 일부입니다
Python으로 하는 통계적 사고 (2부)
연습 안내
nohitter_times데이터에서draw_bs_reps()함수를 사용해 $\tau$의 부트스트랩 복제본10000개를 생성하세요. 최적의 $\tau$는 데이터의 평균으로 계산된다는 점을 기억하세요.np.percentile()를 사용해 95% 신뢰구간을 계산하세요. 인수로는 배열bs_replicates와 퍼센타일 리스트(여기서는2.5와97.5)를 전달합니다.- 신뢰구간을 출력하세요.
- 부트스트랩 복제본의 히스토그램을 그리세요. 이 부분은 이미 준비되어 있으니, 답변 제출을 눌러 그래프를 확인하세요!
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# 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()