The Monty Hall problem is a probability puzzle named after the host of the game show “Let’s Make a Deal.”

It goes as follows:

You are presented with three doors. Behind one of the doors is a prize, while the other two doors hide nothing. You are asked to choose one of the doors. After you have made your choice, Monty Hall, the host of the show, reveals one of the doors you did not choose, which hides nothing. You are then given the option to stick with your original choice, or switch to the other remaining door.

The question is, should you stick with your original choice, or switch to the other door? Intuitively, it might seem that it doesn’t matter whether you stick with your original choice or switch, since there are only two doors left and one of them hides the prize. However, the correct answer is that you should switch.

To see why this is the case, let’s consider the following simulation. We will simulate the Monty Hall problem 100,000 times, keeping track of whether the prize is behind the door the player originally chose, and whether the player wins by sticking with their original choice or switching to the other door.

import random # Number of simulations to run num_simulations = 100000 # Count of how many times the player wins by sticking with their original choice wins_by_sticking = 0 # Count of how many times the player wins by switching wins_by_switching = 0 for i in range(num_simulations): # Choose a random door for the prize prize_door = random.randint(1, 3) # Choose a random door for the player's choice player_choice = random.randint(1, 3) # Choose a door to reveal that doesn't contain the prize and that the player didn't choose revealed_door = random.choice([door for door in range(1, 4) if door != prize_door and door != player_choice]) # If the player sticks with their original choice, did they win? if prize_door == player_choice: wins_by_sticking += 1 # If the player switches, did they win? if prize_door != player_choice: wins_by_switching += 1 # Print the results print(f"Number of simulations: {num_simulations}") print(f"Wins by sticking: {wins_by_sticking} ({wins_by_sticking / num_simulations * 100:.2f}%)") print(f"Wins by switching: {wins_by_switching} ({wins_by_switching / num_simulations * 100:.2f}%)")

Number of simulations: 100000

Wins by sticking: 33333 (33.33%)

Wins by switching: 66667 (66.67%)

This shows that switching doors gives the player a significantly higher chance of winning compared to sticking with their original choice.

*** They key to understand the 3 Doors orĀ Monty Hall game is to realize that we are choosing the wrong door with a much higher probability than the right one (66 vs 33% aprox), so if we are offered a second chance, **the optimal strategy is to switch our initial choice**.

The reason for this is that when the player initially chooses a door, there is a 1 in 3 chance that they have chosen the door with the prize behind it. After Monty Hall reveals one of the other doors, the probability that the prize is behind the remaining door increases to 2 in 3.

This is because when Monty Hall reveals one of the other doors, he is eliminating one of the two doors that don’t have the prize behind them, leaving the player with a higher chance of winning if they switch to the remaining door.

It’s worth noting that the Monty Hall problem can be counterintuitive, and many people initially find it hard to believe that switching doors gives a higher probability of winning.

However, the results of the simulation and the underlying probability logic demonstrate that this is indeed the case.

## Comments by Luis G de la Fuente