Friday, March 02, 2018

The Monty Hall Problem Hurt My Pride

Have you ever had one of those days when you swore up and down that you knew in your gut that something was right, but the world was against you, well I just had one of those days.  One of my work buds brought up the movie "21" about these punk kids from MIT who decided to try to bring the "man" down in casinos, or something like that (never saw it). Anyway this movie goes on to explain (horribly) the "Monty Hall Problem".

What's the "Monty Hall Problem"?  I'm glad you asked, but I sure wasn't glad I asked that fateful day late December back in '63.  tl;dr:  there was this game show host named Monty Hall who used to have a 3 door game where a contestant picked a door to win a prize.  One of the 3 doors had a prize (car) and the other two had goats or some other junk. [side note] I would have been very happy to win a pet goat [/side note].  As soon as the contestant picked a door Monty would then take away one of the two other doors knowing full well that the door he was removing was the losing door.  The contestant was then asked if he/she wants to switch.

The movie tries to make us believe that the contestant should ALWAYS swap doors because it will give better odds (66%).  So I said that is total Barney Snicker-doodles.   There are only 2 doors left so your odds of actually winning the prize is 50/50 :duh:. So we had this long winded debate and even resorted to watching a Kahn Academy video.  Statistics, blah blah, statistics.

So even after watching this my gut just wouldn't let me believe it.  So being a slightly able to reason out a problem and program JavaScript, I took to the keyboard to write a program that would simulate 10,000 times a user first picking the door and STICKING with that door and then a person picking a door and SWITCHING.  My hypothesis was that no matter which option was chosen the user would have a 33% chance of winning (1/3 doors).  Well my own fingers don't lie so I wrote it up and it turns out that switching DOES give you an extra 33% possibility.

No Switch Wins count = 3316 = 33.2%
Switch Wins count = 6650 = 66.5%

Every time I ran the program it was very close to these results. Click here for the source of my dishonor (JavaScript).  I'm so unhappy at this point that I will never clean up the code and it will forever be sloppy.

Most importantly I have to state the following publicly:

You were right Frank.


1 comment:

Frank Angelone said...

Always account for variable change! Thank you for that extra 33.33%.