เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

Simulating probability of A or B

In the last multiple choice exercise you found that there was a 64% chance that either coin A (60% chance) or coin B (10% chance) would come up heads. Now you'll confirm that answer using simulation.

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

Foundations of Probability in R

ดูคอร์ส

คำแนะนำการฝึกหัด

  • Use rbinom() to simulate 100,000 flips of coin A, each having a 60% chance of being heads.
  • Use rbinom() to simulate 100,000 flips of coin B, each having a 10% chance of being heads.
  • Use these to estimate the probability that A or B is heads.

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

# 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
แก้ไขและรันโค้ด