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

Connected

练习

Win probability with "stick"

Let's write some code to simulate the Monty Hall game show. In this exercise, we will have the contestant choose Door #1, "stick" every time, and find the relative frequency of winning after 10000 iterations of the game.

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, using the idea of a counter we discussed previously.

说明 1 / 共 2 个

undefined XP
    1
    2
  • Use the sample function to select one of the doors to have the prize.
  • Check whether the door with the prize matches the door chosen.