Introduction

You blew it, and you blew it big! Since you seem to have difficulty grasping the basic principle at work here, I’ll explain. After the host reveals a goat, you now have a one-in-two chance of being correct. Whether you change your selection or not, the odds are the same. There is enough mathematical illiteracy in this country, and we don’t need the world’s highest IQ propagating more. Shame!

Scott Smith, Ph.D. University of Florida

May I suggest that you obtain and refer to a standard textbook on probability before you try to answer a question of this type again?

Charles Reid, Ph.D. University of Florida

These are just two of over 10,000 letters Marilyn vos Savant received in regards to her response of the Monty Hall Problem. What was her response? “Yes; you should switch,” she replied. “The first door has a 1/3 chance of winning, but the second door has a 2/3 chance.”

Game set-up and assumptions

“Suppose you’re on a game show, and you’re given the choice of three doors: Behind one door is a car; behind the others, goats. You pick a door, say No. 1, and the host, who knows what’s behind the doors, opens another door, say No. 3, which has a goat. He then says to you,”Do you want to pick door No. 2?" Is it to your advantage to switch your choice?"

We will investigate the above decision of whether to switch or not to switch.

Assumptions:

  1. The host will always open a door not picked by the contestant.

  2. The host will always open a door which reveals a goat (i.e. not a car).

  3. The host will always offer the contestant the chance to switch to another door.

  4. The door behind which the car is placed is chosen at random.

  5. The door initially chosen by the contestant is chosen at random.

To make your results reproducible include set.seed() in your set-up code chunk. Also, load package tidyverse.

Single game result

Write a function called monty_hall_one_play() that takes no arguments and returns a numeric vector with each element representing the following:

  • the first element is the door behind which the car is hidden (selected randomly from 1:3)

  • the second element is the door initially selected by the contestant (selected randomly from 1:3)

  • the third elment is the door revealed by the host

  • if the contestant selected the door with the car, the host randomly selects one of the two remaining doors

  • if the contestant selected a door different from the door with the car, the host selects the door that is not hiding the car

Below is an example of monty_hall_one_play().

monty_hall_one_play()
[1] 1 1 2

Repeated plays

To evaluate the stay and switch strategies we must repeat the game many times to determine the proportion of wins based on each strategy. To do this, write another function called monty_hall() which has one argument, iter, the number of iterations, and which returns a data frame with iter rows and five columns. This function should call the monty_hall_one_play() function. You will probably want to write some type of loop or try replicate().

The data frame columns that function monty_hall() should return are:

  • car_door, gives the door behind which the car is hidden.

  • contestant_door, gives the door initially selected by the contestant.

  • host_door, gives the door revealed by the host.

  • switch, result of switch strategy; 1 is win, 0 is loss.

  • stay, result of stay strategy; 1 is win, 0 is loss.

Below is a table for how your data frame should be set-up.

car_door contestant_door host_door switch stay
2 1 3 1 0
1 2 3 1 0
2 2 3 0 1
1 2 3 1 0
3 1 2 1 0

Strategy evaluation

Simulation

Conduct a Monte Carlo simulation with 10,000 iterations. Save the result as monty.hall.sim. Use apply() or some dplyr functions to compute the mean of each column. You can now see a simulated win probability for each strategy.

Which strategy appears to be the best based on your simulation?

Visualization

Recreate the plot below to visualize the convergence.

Theoretical result

Derive the theoretical result. Does it match your simulation result?