1. 学习
  2. /
  3. 课程
  4. /
  5. Probability Puzzles in R

Connected

练习

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.

说明 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.