Session Ready
Exercise

Exercise 2. American Roulette Monte Carlo simulation

Create a Monte Carlo simulation that generates 10,000 outcomes of \(S\), the sum of 100 bets.

Compute the average and standard deviation of the resulting list and compare them to the expected value (-5.263158) and standard error (40.19344) for \(S\) that you calculated previously.

Instructions
100 XP
  • Use the replicate function to replicate the sample code for B <- 10000 simulations.
  • Within replicate, use the sample function to simulate n <- 100 outcomes of either a win (17) or a loss (-1) for the bet. Use the order c(17, -1) and corresponding probabilities. Then, use the sum function to add up the winnings over all iterations of the model. Make sure to include sum or DataCamp may crash with a "Session Expired" error.
  • Use the mean function to compute the average winnings.
  • Use the sd function to compute the standard deviation of the winnings.