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

Exercise

Exercise 5. Monte Carlo simulation for Celtics winning a game

Create a Monte Carlo simulation to confirm your answer to the previous problem by estimating how frequently the Celtics win at least 1 of 4 games. Use B <- 10000 simulations.

The provided sample code simulates a single series of four random games, simulated_games.

Instructions

100 XP
  • Use the replicate function for B <- 10000 simulations of a four game series. The results of replicate should be stored to a variable named celtic_wins.
  • Within each simulation, replicate the sample code to simulate a four-game series named simulated_games. Then, use the any function to indicate whether the four-game series contains at least one win for the Celtics. Perform these operations in two separate steps.
  • Use the mean function on celtic_wins to find the proportion of simulations that contain at least one win for the Celtics out of four games.