1. Learn
  2. /
  3. Courses
  4. /
  5. Foundations of Probability in R

Exercise

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().

Instructions

100 XP
  • 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.