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

Exercise

Win probability with "switch"

Now let us code the situation where the contestant initially picks Door #1, and then upon the goat reveal, they switch to the remaining door.

Again, first, we will code just one iteration. Then, we will incorporate this into a for loop to run the process repeatedly in order to obtain a simulated estimate of the true win probability.

Instructions 1/2

undefined XP
    1
    2
  • Use the reveal_door function that we created in the previous exercise, to simulate the reveal.
  • After the reveal, switch the choice to the remaining door.
  • Check whether the final choice matches the prize door.