Monty Hall Paradox

The Monty Hall paradox is a paradox because it is counter-intuitive even though it is mathematically correct.  This article demonstrates with PHP code how the paradox works.

You as a contestant on a game show get to pick one of three doors.
A big prize is behind just one door, while the other two contain worthless things.  After making your selection, the host reveals one of the doors you did not pick always revealing junk.  You now have a choice to switch your chosen door.

Intuitively, we say that each door has a 33.33% chance of being the prize, but this is only correct in the beginning.

Many believe that after revealing one of the worthless doors, that the two remaining doors have a 50% chance. This is not the case.

After the reveal of a worthless item, the remaining door you did not pick has a 66.67% chance of being the big prize.  The door you picked still has a 33.33% chance.  This is because of two facts:

  • The two doors you did not pick together had a 66.67% chance of being the big prize.
  • And they still do, you just know what is behind one of them.

This is some simple PHP code that runs the Monty Hall experiment.

This script will output something similar to the following:

But what if there were four doors?  Well, just add another options to $Options on line 5.

Why 37.50%?  The logic is the same as it was for three doors.  With four doors, the door you pick has a 25% chance, and the three other doors have a 75% chance of being the winner.  When one of the three doors is eliminated the two remaining doors share a 75% chance of winning.

75% / 2 = 37.50%

This follows with five doors.

80% / 3 = 26.67%

And so on.