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

Simulating coin flips

In these exercises, you'll practice using the rbinom() function, which generates random "flips" that are either 1 ("heads") or 0 ("tails").

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

Foundations of Probability in R

ดูคอร์ส

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

  • With one line of code, simulate 10 coin flips, each with a 30% chance of coming up 1 ("heads").
  • What kind of values do you see?

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

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

# Generate 10 separate random flips with probability .3
แก้ไขและรันโค้ด