The Monty Hall problem emulation

09 Jul 2012

Since I first heard of the Monty Hall problem it has been itching my intellect.
If you haven’t heard of the problem there is a good explanation of it over on wikipedia.

The idea is that you are on a game show, where there are three doors. You will get to keep whatever is behind the door you choose.
Behind one of them there is a car, and behind the other two there are donkeys.
First you will get to choose a door, but you can not see what is behind it.
After this the host will open another door, behind which he will reveal a donkey.

You are now left with a choice, stay with the door you choose from the beginning or change to the door that the host didn’t open.

Will the change of door increase or decrease your chance of getting the car?

Intuitively I would not think that there would be a difference, but according to wikipedia, and my maths lecturer there will be. If you switch door there is a greater change (2/3) of winning the car, than if you stay(1/3). This seems a bit strange to me so I naturally decided to write up a small script to get some statistics on it.

The script can be found on my gist page on github.

The best part? You call it with


Theory seems to win over intuition again.

Run game. Change everytime. 10000000 iterations.
Wins: 6667411 Loses: 3332589
Run game. Never change. 10000000 iterations.
Wins: 3335638 Loses: 6664362
blog comments powered by Disqus