- Fri 10 August 2018
- Analysis
- #Python, #Statistics

Monty Halls was a game show host of Let's make a deal. The game consisted of presenting a contestant with a choice of 3 doors. Behind one door was something of great value with nothing behind the other doors. After the contestants made his choice, the host would open one of the remaining doors revealing there was nothing behind it. The contestants were then asked if they wanted to change their choice to another door.

The question put forward is should the contestant stick with the door they originally chose or change their selection. This is one of those problems to which the solution isn't intuitively obvious. The chances of selecting the right door is 33% isn't it? Well, the initial decision gave you this chance of winning 33% of the time. But then you were presented with new information. Changing your selection with this new information would make you 2/3 or 66% likely to succeed.

The method normally used to think about this is to picture 100 doors instead of 3 again with one having something of value behind it. Selecting one door gives you 1% chance of success. The host then opens 98 of the other doors, leaving only your selection and one more door closed. Would you still stick to your initial choice? Isn't it more likely that the other closed door is the right one?

Now, even though it is more (or less) explained, is this the way the real world works? We can try playing the game a few thousand times and see which strategy comes out on top.

First let's get this out of the way. There isn't truly random selection. If you run trials on humans regarding choice of colours or letters, some of these will get selected more often than others. The people doing the selecting won't even be aware that they are biased. For the purposes of this model though, selection will be random.

We will define a game as there being 3 choices of doors a, b and c. We will randomly pick the "right" door and randomly pick the door selected by the contestant. If the choice is the same as the right door, the model will return 1, if not it will return 0. The tally of outcomes will be the success of the strategy. All the simulations are doing are comparing the chosen door with the correct door. In the case of changing the doors, the originally selected door is changed to the door that is not opened.

To make sure that the results are not one off freaks statistics, we can run a hundred games a hundred times and compare the averages.

```
import random
import numpy as np
def run_no_change_doors():
doors = {'a', 'b', 'c'}
right_door = set(random.sample(doors, 1))
guessed_door = set(random.sample(doors, 1))
if right_door == guessed_door:
return 1
else:
return 0
def run_change_doors():
doors = {'a', 'b', 'c'}
right_door = set(random.sample(doors, 1))
guessed_door = set(random.sample(doors, 1))
# The opened door is not the guessed door or the right door
opened_door = set(random.sample(doors - right_door - guessed_door,1))
# You're changing your guess based on the open door
changed_door = doors - opened_door - guessed_door
if right_door == changed_door:
return 1
else:
return 0
num_simulations = 100
num_turns_per_simulation = 100
no_change_doors_simulations = []
for i in range(num_simulations):
total = 0
for j in range(num_turns_per_simulation):
total += run_no_change_doors()
no_change_doors_simulations.append(total)
print("Average wins if you didn't change doors is %d%%." % np.mean(no_change_doors_simulations) )
change_doors_simulations = []
for i in range(num_simulations):
total = 0
for j in range(num_turns_per_simulation):
total += run_change_doors()
change_doors_simulations.append(total)
print("Average wins if you changed doors is %d%%." % np.mean(change_doors_simulations))
```

```
Average wins if you didn't change doors is 32%.
Average wins if you changed doors is 67%.
```

As expected the average wins for not changing the selection is 33%, with the average for changing it being 66%. Yay statistics! So the answer to the question is that it is always better to change.