2015 年是否異常?
1990 年與 2015 年是棒球賽季中無安打比賽(no-hitter)最多的兩年(各有 7 場)。已知平均每個賽季的無安打比賽數為 251/115,求一個賽季中出現 7 場或以上的機率為何?
本練習屬於課程
Statistical Thinking in Python (Part 1)
練習說明
- 從平均數為
251/115的 Poisson 分佈抽取10000個樣本,指定給n_nohitters。 - 計算結果中大於或等於
7的樣本數量,指定給n_large。 - 計算出現
7場或以上無安打比賽的機率p_large,方法是以n_large除以樣本總數(10000)。 - 按下送出以列印你計算出的機率。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Draw 10,000 samples out of Poisson distribution: n_nohitters
# Compute number of samples that are seven or greater: n_large
n_large = np.sum(____)
# Compute probability of getting seven or more: p_large
# Print the result
print('Probability of seven or more no-hitters:', p_large)