A number of years ago I had a disagreement with my then girlfriend (future wife) about the Monty Hall problem. It was based on the Let’s make a Deal TV show in the 70’s hosted by Monty Hall. In the game show a contestant would be have the choice of opening one of three doors. Behind one door is a car and behind the other two are goats. You choose a door but before opening Monty shows you a goat behind a door you didn’t pick. You then have the option to change your choice of door. Should you switch or not? My wife said yes but I said of course not. I was a programmer after all, I work with numbers and probability all day. My wife is merely an artist with no match experience. To prove her wrong I wrote a script to simulate millions of door picking combinations. When switching your pick was first suggested as being the best it caused a stir and many people including Phd’s wrote it to chastise the writer. You can read more about this in this Wikipedia article here.

The general outline of the script is to simulate three doors with the car randomly placed behind one. Have two contestants randomly pick a door. If the first contestant does not change their choice. The second one always does. Then wrap a loop around this to simulate millions of choices and see what the results are. Below is the SAS program code.

datagoats; do x=1to1000000; * set this to the number of test runs ; * put car behind the door; door=round((uniform(0)*2),1)+1; * user 1 picks a door and sticks with it; user1Choice=round((uniform(0)*2),1)+1; if user1Choice=door then user1Win=1; else user1Win=0; * user 2 picks a door; user2Choice=round((uniform(0)*2),1)+1; * if user 2 picked right on first try they loose, otherwise wins; if user2Choice=door then user2Win=0; else user2Win=1; output; end;run;procsql; select 'RESULTS' ,sum(user1Win) as user1WinCount ,sum(user2Win) as user2WinCount ,count(*) as num_tries from goats;quit;

When you run the script you will see the first contestant only wins 1/3 of the time. This is consistent with the probability of three doors. The second contestant wins 2/3 of the time. The best way to describe this is that the second contestant is betting they choose wrong the first time.