从几何分布进行模拟
在本练习中,您将把自己的 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