從幾何分配進行模擬
在這個練習中,你將把你的 replications 與 rgeom() 的輸出進行比較。
本練習屬於課程
R 的機率基礎
練習說明
- 使用
rgeom()函式,從成功機率為 0.2 的幾何分配模擬 100,000 次抽樣。將結果存成geom_sample。 - 使用
compare_histograms()函式比較replications與geom_sample。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Replications from the last exercise
replications <- replicate(100000, which(rbinom(100, 1, .2) == 1)[1])
# Generate 100,000 draws from the corresponding geometric distribution
geom_sample <- rgeom(___)
# Compare the two distributions with compare_histograms