<<   >>

48. Monty Hall Problem

The object of the game is to win a car.

Two goats and a car are hidden behind three doors, one item per door. You choose a door. The game-master (Monty Hall), who knows what’s behind the doors, opens one of the other doors, revealing a goat, and offers you the opportunity to change your choice of doors. Your final choice of door is then opened and you get what is revealed.

Should you stick or change?

Many people get this wrong, including people with Ph.D. degrees in mathematics and statistics, including Paul Erdős as recounted in chapter 6 of Paul Hoffman’s The Man Who Loved Only Numbers [130].

Simulation

The present task is to write two simulation programs, one for the strategy of sticking with the original choice and another for the strategy of changing. The argument is the number of simulations of the game; the result is the number of cars won.

stick←{
 c←?⍵⍴3                      ⍝ where the car is hidden
 i←?⍵⍴3                      ⍝ your initial choice of door
 +/c=i                       ⍝ number of cars that you win
}

change←{
 c←?⍵⍴3                      ⍝ where the car is hidden
 i←?⍵⍴3                      ⍝ your initial choice of door
 j←(c×i≠c)+(3|i+1+?⍵⍴2)×i=c  ⍝ your changed choice
 +/c=j                       ⍝ number of cars that you win
}

⍝ if i≠c, Monty Hall opens the other  goat door,  and
⍝     you change to the car door

⍝ if i=c, Monty Hall opens one of the goat doors, and
⍝     you change to the other goat door
   c     ⍝ where the car is hidden
1 0 1 2 2 2 0 2 0 1 2 0 0 0 1 1 1 1 1 0 0 1 1 2 1 2 1 0 ...
   i     ⍝ your choice of door
2 2 1 2 0 2 2 1 0 1 2 0 1 2 0 2 2 1 0 0 2 1 2 2 1 0 0 2 ...
   j     ⍝ your changed choice
1 0 2 1 2 0 0 2 2 0 1 1 0 0 1 1 1 2 1 2 0 0 1 0 2 2 1 0 ...
   stick 1e6
333143
   stick 1e6
332564

   change 1e6
666771
   change 1e6
665859

The Crucial Line

The crucial line in the simulation

   j←(c×i≠c)+(3|i+1+?⍵⍴2)×i=c  ⍝ your changed choice

is in the pattern (p*~b)+q*b where b is a binary condition.

c×i≠c — your original choice i is not equal to the car door c , i.e. is a goat door. Monty Hall would have opened the other goat door, and a switch means a switch to the car door, i.e. to c .

(3|1+i+?y⍴2)×i=c — your original choice i equals the car door c . The analysis can be divided into 3 parts, depending on the value of i , and assumes the existence of a random 0-1 array r .

c i goat doors j
001 2 1+r
3|1+r
3|i+1+r
110 2 3|2+r
3|i+1+r
220 1 r
1+r
3|1+r
3|i+1+r

That is, for each of the three possible values of i the value of j can be computed as 3|i+1+r .

Of course, with your original choice equaling the car door and the strategy being to switch, it doesn’t matter which door Monty Hall opens and thence which door you switch to — the i=c part of the sum should be 0. However, we want the simulation to be as realistic as possible. (See the values of c , i , and j in the previous section.) After all, further analysis eliminates the need to simulate at all, as follows:

Explanations without Simulation

My favorite explanation of why you should change your choice of doors is found on pages 104-105 of Sixty Days and Counting, a novel by Kim Stanley Robinson [131]:

[E]ach box at the start had a one-third chance of being the one. When subject chooses one, the other two have two-thirds a chance of being right. After experimenter opens one of those two boxes, always empty, those two boxes still have two-thirds of a chance, now concentrated in the remaining unchosen box, while the subject’s original choice still had its original one-third chance. So one should always change one’s choice!

Another lucid explanation can be found on page 65 of The Curious Incident of the Dog in the Night-Time, a novel by Mark Haddon [132]. The universe of possible actions and outcomes can be diagrammed as follows:

You choose
the door with
goat 0
behind it
You choose
the door with
goat 1
behind it
You choose
the door with
the car
behind it
Monty Hall opens
the door with
goat 1
behind it
Monty Hall opens
the door with
goat 0
behind it
Monty Hall opens
the door with
goat 0 or goat 1
behind it
You stick You change You stick You change You stick You change
You get
a goat
You get
a car
You get
a goat
You get
a car
You get
a car
You get
a goat

If you change (green), 2 times out of 3 you get a car; if you stick (red), you get a car only 1 time out of 3. The results from the simulations are consistent with this conclusion.

Anecdote

I once introduced APL to a grade 9 math class in a one-hour talk, finishing with a simulation of the Monty Hall problem. Well into the problem, a student opined, “I’ve always wanted to have a goat.” Since then, I have taken care to start the problem description with, the object of the game is to win a car.

From http://xkcd.com/1282


 



Appeared in J in [133].