Friday, July 24, 2009

Monty, Monty...

By now, I'm sure you know about the "Monty Hall problem." It is a wonderful problem because many people, even those knowledgeable about statistics, find it difficult to believe the correct answer. If you don't know the story, here is wikipedia.

The short version:
There are 3 doors, behind one is a prize and behind the other two are goats. You first choose a door, which remains closed. The host must now open one of the other two doors. He does so, and behind this door is a goat. At this point, the host offers you the possibility of changing your choice to the third door. Should you switch?



The intuitive answer is that since there are two unopened doors, and ostensibly no information, they are equally logical choices. But this is not correct. For a detailed discussion, see Grinstead and Snell (example 4.6) or Krauss and Wang (2003 J. Exp. Psychol.: General. 132:3; pdf available for both on Wikipedia).

I wrote a Python simulation for the problem. Here is the output:

p = A  c = A  m = B
p = B c = B m = A
p = C c = B m = C
p = A c = C m = A
p = B c = C m = B
p = B c = A m = B
p = A c = C m = A
p = C c = B m = C
p = B c = B m = C
p = C c = B m = C
p = A c = C m = A
p = A c = B m = A
stay: 3332 switch: 6668


Here is a nice Java applet with a simulation.

And here is a syntax-colored screenshot of my Python code:


No comments: