Sunday, July 20

Monty Hall Problem


Introduction

The Monty Hall Problem is a puzzle named for Mr. Monty Hall, a game show host from the 60's and 70's.  The problem can be summed up as follows:
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?
In the video above there is detail on how to intuitively find the answer where you should always switch.  Most people's intuitive answer is that after Monty Hall shows you the second door, you have a 50% chance of finding the sports car.  While this is true (given two doors, one car), this way of looking at the problem ignores the fact that Monty Hall just revealed a goat to us.  Remember that you had a 2/3 chance of getting a goat on your first pick.  The following table I believe demonstrates the choices well:
Car in Door 1
Car in Door 2
Car in Door 3
Result in picking door #1 and not switching
Result if switching
Car
Goat
Goat
Car
Goat
Goat
Car
Goat
Goat
Car
Goat
Goat
Car
Goat
Car

The program test

Although I was fully convinced that the switch was the right move, I decided to write a little python program to test the scenario in bulk.  This problem is better seen that your odds are better with always switching when you play the game more than once or twice (and not up to "dumb luck").

Hypothesis

Given enough iterations, the success rate of switching should tend to 66% given 3 doors.  

Results

The following table was the output of the python script.  as can be seen below, the percentage to 3 significant figures pans out to 66% victory rate for always switching, 33% for sticking to your guns, and an even 50-50 for randomly switching.

Runs:  10000
Time:  0.72 seconds
Seed:  1
==========================
Always Switch:
Win:    6673
Loss:   3327
Percentage:  66 %
==========================
Never Switch:
Win:    3343
Loss:   6657
Percentage:  33 %
==========================
Sometimes Switch:
Win:    5041
Loss:   4959
Percentage:  50 %
==========================

Code

No comments: