从 Poisson 和二项分布进行模拟
如果我们抛 100,000 枚硬币,每枚正面朝上的概率是 0.2%,则可以用 Poisson(2) 分布来近似。让我们通过模拟来验证。
本练习是课程的一部分
R 中的概率基础
练习说明
- 从 Binomial(1000, .002) 分布生成 100,000 次抽样。将结果保存为
binom_sample。 - 使用
rpois()从近似该二项分布的 Poisson 分布生成 100,000 次抽样。将结果保存为poisson_sample。 - 使用
compare_histograms()函数比较这两个分布。(请记住,该函数需要两个参数:要比较的两个样本)。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Draw a random sample of 100,000 from the Binomial(1000, .002) distribution
binom_sample <-
# Draw a random sample of 100,000 from the Poisson approximation
poisson_sample <-
# Compare the two distributions with the compare_histograms function