模拟 A 或 B 的概率
在上一个单选题中,您算出:硬币 A(正面概率 60%)或硬币 B(正面概率 10%)中至少有一个为正面的概率是 64%。现在,您将通过模拟来验证这一结果。
本练习是课程的一部分
R 中的概率基础
练习说明
- 使用
rbinom()模拟硬币 A 的 100,000 次掷币,每次正面概率为 60%。 - 使用
rbinom()模拟硬币 B 的 100,000 次掷币,每次正面概率为 10%。 - 使用这些结果来估计 A 或 B 为正面的概率。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Simulate 100,000 flips of a coin with a 60% chance of heads
A <-
# Simulate 100,000 flips of a coin with a 10% chance of heads
B <-
# Estimate the probability either A or B is heads