शुरू करेंमुफ़्त में शुरू करें

Using replicate() for simulation

Use the replicate() function to simulate 100,000 trials of waiting for the first heads after flipping coins with 20% chance of heads. Plot a histogram of this simulation by calling qplot().

यह अभ्यास पाठ्यक्रम का हिस्सा है

Foundations of Probability in R

पाठ्यक्रम देखें

अभ्यास निर्देश

  • Use replicate() to simulate 100,000 geometric trials. Copy and paste the expression given to you as your second argument to replicate().
  • Plot a histogram by calling qplot() on the replications.

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

# Existing code for finding the first instance of heads
which(rbinom(100, 1, 0.2) == 1)[1]

# Replicate this 100,000 times using replicate()
replications <- 

# Histogram the replications with qplot
qplot(___)
कोड संपादित करें और चलाएँ