# Did Monty consider that someone might want the goat?

The Monty Hall problem is a classic. I like it because it posed with simple language and hides it’s complexity. The first time you hear the puzzle you have a good chance of answering correctly (5050). However, once you start to think about the reason for your answer you might need to grab a beer and get ready to think a little bit. As the story goes, one of the 20th centuries most famous mathematicians, Paul Erdos, needed several days before he was convinced by the truth of the proposed solution.

For a full description of the game check out the wikipedia page. The version I’m going to describe is stripped down.

There are three doors. Behind one of the doors there is a car and behind the other two doors there are goats. You player is invited to make a guess as to which door hides the car. After making a selection the host will open one of the doors that has a goat. Now, the player is given the opportunity to switch their choice to another door or to stick with their current selection. What would you do?

If you are like Paul Erdos you would initially think that it doesn’t make any difference whether you switch or not. The probability of selecting the car on the first choice is 13. Swapping doesn’t change this basic fact. This is the incorrect intuition that many people have for the problem. The correct solution is that one should always swap.

The best way to show this is with conditional probabilities. In other words, you show that the probability that the car is behind door two given you initially selected door one and the host removed door three is higher than 13. This is done for us on the wikipedia page.

My own intuition for the problem goes as follows:

The probability of getting the car on the first try is 13 and the probability of not getting it is 23.

Now, break down the switching into these two cases:

If you happened to guess right the first time switching will be wrong. This happens 13 of the time.

On the other hand, if you happened to guess wrong on the first try then switching will always get you the correct door. This happens 23 of the time.

It’s really as simple as this. Adopting a strategy of switching will result in getting the car 23 of the time. A big improvement over the 13 that we get from staying.

Another way to demonstrate this without going to conditional probabilities is run a simulation and see what probabilities come out. Run this code in R.

num_trials <- 100000 # number of trials

car     <- sample(1:3, num_trials,replace = T) # set the door with the car
choice  <- sample(1:3, num_trials, replace = T) # set the door choice of the contestant

remove_options <- apply(cbind(car,choice), 1, function (x) setdiff(c(1,2,3), x)) # the door(s) the host can choose to remove
remove         <- lapply(remove_options, function(x) ifelse(length(x) > 1, sample(x, 1), x)) # randomly select a door to remove

swap<- unlist(apply(cbind(choice, remove), 1, function(x) setdiff(c(1,2,3), x))) # always swap door
sum(swap == car)/length(car) # proportion of swapped choices that match the car door


.