Thursday, February 26, 2015

The Howie Mandel Problem

Now imagine you are on Deal or No Deal, a television show in which there are 26 cases filled with different amounts of cash ranging from a penny to a million dollars.  You start out by picking one case.  Then for each round, the host, Howie Mandel, asks you to eliminate one of the leftover cases, which is opened to reveal the amount inside, after which a mysterious banker offers to buy your case for an amount that varies based on the amounts that are leftover.  You then decide on either taking the money (deal) or playing another round in hopes of getting a better offer from the banker (no deal).


On the rare occasion that you actually get it down to just two cases left in which one of those two cases has the million dollars, Howie will offer you the chance to switch cases.  What should you do?

This problem is similar to the “Monty Hall Problem”, where you are a contestant on Let’s Make a Deal and Monty Hall shows you three doors.  Behind one door is a brand new car, but behind the other two doors are two goats.  You pick a door, but just before it is opened, Monty says he will open a different door other than the door that you picked that has a goat behind it, and then offers you the chance to switch doors.  As proved in a previous blog, you should switch doors because switching gives you a 2 in 3 chance of winning (since your original choice was a 1 in 3 chance, it leaves you with a 2 in 3 chance for the remaining doors, in which one choice is eliminated).


So is the “Howie Mandel Problem” similar enough to the “Monty Hall Problem” that you should switch cases?  Or are the problems different enough so that it doesn’t matter if you switch cases or not, because either case has a 1 in 2 chance of winning?  Once again, I wrote a small computer program in Python that simulated the scenario one million times and kept track of how many times you would win by switching cases out of how many times you would actually be in a situation where you only have two cases left.  The computer program is as follows:

01
#The Howie Mandel Solution
02
#Python 2.7.3
03

04
#Be able to pick a random number later.
05
import random
06

07
#Total number of trials to calculate.  The higher the number, the
08
#  more accurate the probability solution.
09
trials = 1000000
10

11
#Total number of cases
12
cases = 26
13

14
#Keep track of the number of trials which get down to having two
15
#  cases at the end, originally starting at zero.
16
trials_down_to_two_cases = 0
17

18
#Keep track of the number of wins if you switch cases at the end,
19
#  originally starting at zero.
20
trials_won_by_switching = 0
21

22
#Go through each trial one by one.
23
for trial in range(1, trials + 1):
24

25
    #Randomly pick a number between 1 and the number of cases
26
    #  for the case with the million dollars.
27
    case_with_big_money = random.choice(range(1, cases))
28

29
    #Randomly pick a number between 1 and the number of cases
30
    #  for the case you choose first.
31
    case_you_choose_first = random.choice(range(1, cases))
32

33
    #Randomly pick a number between 1 and the number of cases
34
    #  (excluding the case you already chose) for the case
35
    #  you leave for last.
36
    case_you_leave_for_last = random.choice(range(
37
        1, case_you_choose_first - 1) + range(
38
        case_you_choose_first + 1, cases))
39

40
    #If the case with the million dollars is in either the case
41
    #  you choose first or the case you save for last,
42
    #  then the game will get down to only two cases left, so add
43
    #  one to the number of trials down to two cases.
44
    if (case_with_big_money == 1 or case_with_big_money == 2):
45
        trials_down_to_two_cases += 1
46

47
    #If case with the million dollars is in the case you save for
48
    #  last, then add one to the number of trials won by switching cases.
49
    if (case_you_leave_for_last == case_with_big_money):
50
        trials_won_by_switching += 1
51

52
#When all trials have been run, print the number of trials won
53
#  by switching and give the percent.
54
print "Total number of times it will get down to two cases: " + str(
55
    trials_down_to_two_cases) + " out of " + str(trials) + " (" + str(
56
    int(round(trials_down_to_two_cases * 100.0 / trials))) + "%)"
57
print "Total number of wins by switching: " + str(
58
    trials_won_by_switching) + " out of " + str(
59
    trials_down_to_two_cases) + " (" + str(int(round(
60
    trials_won_by_switching * 100.0 / trials_down_to_two_cases))) + "%)"

The outcome after running the computer program is as follows:

>> 
Total number of times it will get down to two cases: 80083 out of 1000000 (8%)
>> 
Total number of wins by switching: 39989 out of 80083 (50%)

Therefore, it makes no difference whether you switch cases or not, because either case has a 1 in 2 chance of winning.  The difference between the “Howie Mandel Problem” and the “Monty Hall Problem” is that in the “Howie Mandel Problem”, the options are being randomly eliminated by the contestant, but in the “Monty Hall Problem”, the options are knowingly eliminated by the host.  That tiny detail makes all the difference! 

Wednesday, February 25, 2015

The Monty Hall Problem

Imagine you are on a television game show and the host shows you three doors.  Behind one door is a brand new car, but behind the other two doors are two goats.  You pick Door #1, but just before it is opened, the host says he will open a different door other than the door that you picked that has a goat behind it, and opens Door #3 which reveals one of the two goats.  The host then offers you the chance to stay with Door #1 or to switch to Door #2.  What should you do?


This problem is called the “Monty Hall Problem” in honor of Monty Hall, the host of Let’s Make a Deal, a television game show which had similar games such as this one.  The “Monty Hall Problem” gained popularity in 1990 when vos Savant, a columnist for Parade Magazine, wrote about the problem and asserted that you should switch doors for a 2 in 3 chance of winning, since your original choice for Door #1 was a 1 in 3 chance, leaving you a 2 in 3 chance for the remaining doors, in which one choice (Door #3) was eliminated.  Her solution and explanation was heavily criticized by many of her readers, including PhD professors, who asserted that it makes no difference whether you switch doors or not, because either way there is a 1 in 2 chance of winning since there is one winning door out of the two leftover door options.

Both solutions seem to make sense, but obviously only one can be correct.  So I wrote a small computer program in Python that simulated the scenario one million times and kept track of how many times you would win by switching doors.  The computer program is as follows:

01
#The Monty Hall Solution
02
#Python 2.7.3
03

04
#Be able to pick a random number for the door with the car.
05
from random import randint
06

07
#Total number of trials to calculate.  The higher the number, the more
08
# accurate the probability solution.
09
trials = 1000000
10

11
#Keep track of the number of wins when you switch doors, originally
12
# starting at zero.
13
trials_won_by_switching = 0
14

15
#Go through each trial one by one.
16
for trial in range(1, trials + 1):
17

18
    #Randomly pick a number between 1 and 3 for the door with the car.
19
    door_with_car = randint(1,3)
20

21
    #If the car is behind Door #1, then the goats are behind Door #2 and #3
22
    if (door_with_car == 1):
23
        door_with_goat_1 = 2
24
        door_with_goat_2 = 3
25

26
    #If the car is behind Door #2, then the goats are behind Door #1 and #3
27
    elif (door_with_car == 2):
28
        door_with_goat_1 = 1
29
        door_with_goat_2 = 3
30

31
    #If the car is behind Door #3, then the goats are behind Door #1 and #2
32
    elif (door_with_car == 3):
33
        door_with_goat_1 = 1
34
        door_with_goat_2 = 2
35

36
    #You choose Door #1
37
    door_you_choose_first = 1
38

39
    #Monty Hall picks a different door other than Door #1 that has a goat
40
    #If Door #3 has no car behind it, Monty Hall opens Door #3 to reveal
41
    #  the goat, which makes Door #2 the door to switch to.
42
    if (door_with_car != 3):
43
        door_revealed_with_goat = 3
44
        door_to_switch_to = 2
45

46
    #If Door #3 has the car behind it, Monty Hall opens Door #2 to reveal
47
    #  the goat, which makes Door #3 the door to switch to.
48
    else:
49
        door_revealed_with_goat = 2
50
        door_to_switch_to = 3
51

52
    #If the door to switch to is the door with the car, then add one the
53
    #  number of trials won by switching doors.
54
    if (door_to_switch_to == door_with_car):
55
        trials_won_by_switching += 1
56

57
#When all trials have been run, print the number of trials won by switching
58
#  and give the percent.
59
print "Total number of wins by switching: " + str(trials_won_by_switching) + (
60
    " out of " + str(trials) + " (" + str(
61
    int(round(trials_won_by_switching * 100.0 / trials)))) + "%)"

If there is a 2 in 3 chance of winning by switching doors, then the above computer program should produce a probability of about 67%.  If there is a 1 in 2 chance of winning by switching doors, then the above computer program should produce a probability of about 50%.  So what are the chances?  The computer program produces the following:

>> 
Total number of wins by switching: 666501 out of 1000000 (67%)

The total number of wins varies slightly when the computer program is run again, but the percentage is the same each time: 67%.  There is a 2 in 3 chance of winning by switching doors.  Vos Savant was correct.  If your original choice for Door #1 was a 1 in 3 chance, this leaves a 2 in 3 chance for the remaining doors, in which one choice (Door #3) was eliminated.  So switching doors gives you a 2 in 3 chance of winning.

Scenario
Door #1
Door #2
Door #3
Result If You Switch Doors
Car is behind Door #1
car
goat
goat
You pick Door #1.
Monty shows the goat behind Door #3.
You switch to Door #2 which has a goat.
You Lose!
Car is behind Door #2
goat
car
goat
You pick Door #1.
Monty shows the goat behind Door #3.
You switch to Door #2 which has a car.
You Win!
Car is behind Door #3
goat
goat
car
You pick Door #1.
Monty shows a goat behind Door #2.
You switch to Door #3 which has a car.
You Win!

There are many different problems related to probability in which the “common sense” answer is actually incorrect.  The Monty Hall problem is one of the most famous ones.  At first glance it seems that there should be no difference between picking between the leftover two doors, but in reality there is a 2 in 3 chance of winning if you switch.  For some reason, human intuition fails at many statistical problems like this one.