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

Exercise

Exercise 2. The Cavs and the Warriors - Monte Carlo

Confirm the results of the previous question with a Monte Carlo simulation to estimate the probability of the Cavs winning the series after losing the first game.

Instructions

100 XP
  • Use the replicate function to replicate the sample code for B <- 10000 simulations.
  • Use the sample function to simulate a series of 6 games with random, independent outcomes of either a loss for the Cavs (0) or a win for the Cavs (1) in that order. Use the default probabilities to sample.
  • Use the sum function to determine whether a simulated series contained at least 4 wins for the Cavs.
  • Use the mean function to find the proportion of simulations in which the Cavs win at least 4 of the remaining games. Print your answer to the console.