# Monty Hall Python

The Monty Hall Problem is one of my favourite examples of a counterintuitive solution in mathematics.

It works as follows:

• A car (or some other suitable prize) is placed behind one of three closed doors.
• You, as contestant, pick one of the doors.
• The host of the show, Monty Hall, opens one of the other two doors (making sure to pick one without the car)
• You are then given the option to stay with your original pick or to switch to the other unopened door.

Now, the counterintuitive solution is that you double your chances of winning by switching. This is counterintuitive because Monty opening one door hasn't told you anything new about which of the two remaining closed door is likely to have the car behind it.

Here's how I think about it mathematically: when you pick your door, there is a 1/3 chance it's behind the door you picked and a 2/3 chance it's behind one of the other two doors. When Monty opens one of the doors, he hasn't changed that fact: there's still a 2/3 chance it's behind one of the two doors you didn't pick. It's just now he's narrowed down which of the two doors it could be behind. So there's a 2/3 chance it's behind the door you didn't pick that's still closed as opposed to a 1/3 chance it's behind the door you original picked. So you double your chances by switching.

Sound convincing? Well, some people still like to see it played out. So here is a little Python program that will play 1000 games and show you the proportion that would be won by a stayer and the proportion that would be won by a switcher.

The original post had 16 comments I'm in the process of migrating over.