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

Waiting for first coin flip

You'll start by simulating a series of coin flips, and "waiting" for the first heads.

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

Foundations of Probability in R

ดูคอร์ส

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

  • Simulate 100 instances of flipping a single coin with a 20% chance of heads, and save it as the variable flips. (Thus, flips should be a vector of length 100).
  • Use which() to find the first case where a coin resulted in heads.

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

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

# Simulate 100 instances of flipping a 20% coin
flips <- ___

# Use which to find the first case of 1 ("heads")
which(___)[1]
แก้ไขและรันโค้ด