1. Learn
  2. /
  3. Courses
  4. /
  5. HarvardX Data Science - Probability (PH125.3x)

Exercise

Exercise 5. American Roulette average winnings per bet

Now create a random variable \(Y\) that contains your average winnings per bet after betting on green 10,000 times.

Instructions

100 XP
  • Run a single Monte Carlo simulation of 10,000 bets using the following steps. (You do not need to replicate the sample code.)
  • Specify n as the number of times you want to sample from the possible outcomes.
  • Use the sample function to return n values from a vector of possible values: winning $17 or losing $1. Be sure to assign a probability to each outcome and indicate that you are sampling with replacement.
  • Calculate the average result per bet placed using the mean function.