Session Ready
Exercise

Writing a function to "switch"

Before we simulate the situation of "switch," let us first write a function to do the reveal in this context. We will then use this function in our next exercise to simulate the win probability when switching.

Recall that if the initially chosen door is correct, then the host will choose one of the other two doors at random to reveal.

If the initially chosen door is incorrect, then the host will simply reveal the other incorrect door. Note that there is nothing random about the reveal in this case.

Instructions
100 XP
  • In the case when the initial choice was correct, use the sample function to randomly choose one of the other doors to reveal.
  • Otherwise, select the only remaining door to reveal.