開始使用免費開始

從幾何分配進行模擬

在這個練習中,你將把你的 replicationsrgeom() 的輸出進行比較。

本練習屬於課程

R 的機率基礎

檢視課程

練習說明

  • 使用 rgeom() 函式,從成功機率為 0.2 的幾何分配模擬 100,000 次抽樣。將結果存成 geom_sample
  • 使用 compare_histograms() 函式比較 replicationsgeom_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
編輯並執行程式碼