เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

Simulating from the geometric distribution

In this exercise you'll compare your replications with the output of rgeom().

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

Foundations of Probability in R

ดูคอร์ส

คำแนะนำการฝึกหัด

  • Use the function rgeom() to simulate 100,000 draws from a geometric distributions with probability .2. Save this as geom_sample.
  • Compare replications and geom_sample with the compare_histograms() function.

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

# 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
แก้ไขและรันโค้ด