The object of the game is to win a car.
Two goats and a car are hidden behind 3 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 chosen 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.
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=: 3 : 0 c=. ?y$3 NB. where the car is hidden i=. ?y$3 NB. your choice of door +/c=i NB. number of cars that you win ) change=: 3 : 0 c=. ?y$3 NB. where the car is hidden i=. ?y$3 NB. your choice of door j=. (c*i~:c)+(3|1+i+?y$2)*i=c NB. your changed choice +/c=j NB. number of cars that you win ) NB. if i~:c, Monty Hall opens the other goat door, and you change to the car door NB. if i= c, Monty Hall opens one of the goat doors, and you change to the other goat door
stick 1e6 333143 stick 1e6 332564 change 1e6 666771 change 1e6 665859
My favorite explanation of why you should change your choice of doors is found on page 65 of The Curious Incident of the Dog in the Night-Time, a novel by Mark Haddon. The universe of possible outcomes can be diagrammed as follows:
You are asked to choose a door |
|||||
You choose the door with |
You choose the door with |
You choose the door with |
|||
You stick |
You change |
You stick |
You change |
You stick |
You change |
You get |
You get |
You get |
You get |
You get |
You get |
If you change, 2 times out of 3 you get a car; if you stick, you get a car only 1 out of 3 times. The results from the simulations are consistent with this conclusion.
Another lucid explanation can be found on pages 104-105 of Sixty Days and Counting, a novel by Kim Stanley Robinson:
[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!
See also
DevonMcCormick, Further Surprises Involving a Man and a Goat, Vector, Volume 21, Number 1, Autumn 2004.
Sylvia Comacho, Chance Misunderstandings, Vector, Volume 23, Number 1, 2008-01.
Contributed by RogerHui.
