比较二项分布的累积分布
如果您掷 1000 枚硬币,每枚硬币正面的概率为 20%,得到不超过 190 个正面的概率是多少?
无论用二项分布本身还是它的正态近似,您都会得到相近的答案。在本练习中,您将用两种方式求解:既用模拟,也用精确计算。
本练习是课程的一部分
R 中的概率基础
练习说明
- 使用上一个练习中提供的模拟结果
binom_sample来估计得到不超过 190 个正面的概率。 - 使用模拟结果
normal_sample来估计得到不超过 190 个正面的概率。 - 使用
pbinom()计算二项分布小于等于 190 的精确概率。 - 使用
pnorm()计算正态分布小于等于 190 的精确概率。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Simulations from the normal and binomial distributions
binom_sample <- rbinom(100000, 1000, .2)
normal_sample <- rnorm(100000, 200, sqrt(160))
# Use binom_sample to estimate the probability of <= 190 heads
# Use normal_sample to estimate the probability of <= 190 heads
# Calculate the probability of <= 190 heads with pbinom
# Calculate the probability of <= 190 heads with pnorm