开始使用免费开始使用

从几何分布进行模拟

在本练习中,您将把自己的 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
编辑并运行代码