## 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 = Bp = B c = B m = Ap = C c = B m = Cp = A c = C m = Ap = B c = C m = Bp = B c = A m = Bp = A c = C m = Ap = C c = B m = Cp = B c = B m = Cp = C c = B m = Cp = A c = C m = Ap = A c = B m = Astay: 3332 switch: 6668`

Here is a nice Java applet with a simulation.

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