Daniel Ray's Blog

Daniel Ray's Blog

I like computer science and programming. I hope you enjoy my blog.

18 Jul 2020

Monty Hall meets Monte Carlo

You are on a game show. You can pick between three doors (A, B, and C). One of the doors has a prize behind it. Each of the other two doors has a goat behind it. If you pick the door that has the prize behind it, then you get the prize. If you pick a door that has a goat behind it, then you better have a lot of goat food.

Because you have no information on where the prize is, you pick a door at random. Monty Hall, the host of the game that you're playing, opens a different door, showing you that it has a goat behind it. He tells you that you can change your pick to the remaining (unopened) door. Do you want to change your pick? Does it even matter if you change you pick?

My intuition said that it does not matter. You are choosing between two doors, so it seemed to me that you have a 50-50 chance either way. However, I had always heard that you should change your pick. So, I wanted to understand why.

So, I designed, implemented, and executed a Monte Carlo simulation of the Monty Hall problem, and now I understand why you should change your pick. In the course of designing the simulation, I gained insight into the structure of the problem.

For concreteness, let's say that you initially pick Door A. Because you picked Door A at random, there is a 1/3 chance that Door A has the prize behind it.

Monty opens a door to reveal a goat behind it. Let's say that he opens Door C. Because Door C has a goat behind it, there is a 0/3 chance that Door C has the prize behind it.

Probabilities have to sum to 1. There is a 1/3 chance that the prize is behind Door A, your initial pick. There is a 0/3 chance that the prize is behind Door C, the door that Monty opened. So, there is a 2/3 chance that the prize is behind Door B, the remaining door.

So, change your pick to the remaining door.

The Monte Carlo simulation that I implemented in C corroborates the above reasoning. Over 100,000 trials, the contestant won approximately 1/3 of the time when they stayed with their initial pick and approximately 2/3 of the time when they changed their pick to the remaining door.

The simulation is up at my GitHub.