Skip to main content

Monty Hall Brain Teaser with .NET simulation

I came across a nice brain teaser which involves some simple probability but it still took me a while to get my head around it! Wikipedia explains the scenario quite well:

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?

First Reaction

Surely it's a 1 in 3 chance, I may as well stick with my original choice.

Most people's first reaction is that it's a 1 in 3 choice and there's no benefit in swapping but it turns out you're always better to switch to increase your odds of winning.

.NET Simulation

Before really understanding why the odds were different I knocked up a quick simulation in C#.

View source on GitHub Results

The results showed that sticking with the same door gave you a 1 in 3 chance in winning but if you always switched you had a 2 in 3 chance of winning.

Explanation

At first it seemed like magic but the reason is actually quite simple.

If you stick with your original guess, it means you have to pick the correct door on your first go. There are three doors and there's only one correct door. Therefore, you have a 1 in 3 chance of picking correctly.

If you switch your choice, it means you have to pick the INCORRECT door on your first choice (because you're going to switch away from it later). This is an easier task as there are 2 incorrect doors. Therefore, you have a 2 in 3 chance of picking incorrectly on your first choice, but that's good because the game show host is going to show you the other incorrect door which leaves you with the correct door to swi

Hello, my name's Lee and I work as a full-stack web developer specialising in Microsoft ASP.NET technologies. I love using Umbraco and also MANAGED, my own interal CMS.

Contact me at lee.gunn@secretorange.co.uk

All skills

Contact

Get in touch to talk about your project or just ask me a question.

lee.gunn@secretorange.co.uk

Skype: lee_gunn