開始使用免費開始

用 binom 來擲更多次硬幣

先前你使用 bernoulli.rvs(),在正面機率為 35% 的情況下,模擬了 10 次擲硬幣。

本練習已從 scipy.stats 載入 binom 物件,你可以使用 binom.rvs(),在每次擲硬幣正面機率為 35% 的條件下,模擬 20 組、每組 10 次的擲硬幣試驗。

本練習屬於課程

Python 機率基礎

檢視課程

練習說明

  • 使用 binom.rvs() 函式,在每次擲硬幣正面機率為 35% 的情況下,模擬 20 組、每組 10 次的擲硬幣試驗。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Set the random seed to reproduce the results
np.random.seed(42)

# Simulate 20 trials of 10 coin flips 
draws = ____.rvs(n=____, p=____, size=____)
print(draws)
編輯並執行程式碼