Intuitive explanation that does not rely on mathematical formulas for the Monty Hall problem and simulation with Python

The Monty Hall problem is a well-known problem as a paradox of probability. In this article, I'll give you an intuitive explanation that doesn't rely on the most convincing formulas I've come up with.

Monty Hall problem

[Wikipedia](https://ja.wikipedia.org/wiki/%E3%83%A2%E3%83%B3%E3%83%86%E3%82%A3%E3%83%BB%E3%83 Quoted from% 9B% E3% 83% BC% E3% 83% AB% E5% 95% 8F% E9% A1% 8C)

There are three closed doors in front of the player, behind one door is a new prize car, and behind the two doors is a goat, which means off. Players can get a new car by hitting the door of the new car. After the player selects one door, the moderator Monty opens the remaining door with the goat and shows the goat. The player is now told that he may change the door of his choice to the remaining unopened door. Should the player change the door here?

Answer "The player should change the door, because the probability of winning if not changed is $ \ frac {1} {3} $, while the probability of winning if changed is $ \ frac {2} {3. } $. "

Commentary

When the player first chooses one door, the odds of winning any door should be $ \ frac {1} {3} $. Why does that change after the moderator shows one out door?

To understand this, consider the following problem, which is similar to the Monty Hall problem.

  1. Player selects one door
  2. The player is prompted to choose between the "selected door" and the "two remaining doors".

In this case, everyone would choose the latter "two doors left". This is because the probability of hitting the former is $ \ frac {1} {3} $, while the latter is $ \ frac {2} {3} $.

The decisive difference between this problem and the Monty Hall problem is the presence or absence of the act of "showing one of the unselected doors that is out of the way." In the Monty Hall problem, this action establishes one of the "two remaining doors" with a zero probability of winning. To organize this,

--The probability of hitting "the remaining two doors" is $ \ frac {2} {3} $, --The probability of hitting one of the "two remaining doors" is confirmed to be 0

From the above, the probability that the last remaining unselected door will be a hit is $ \ frac {2} {3} $.

Common misconceptions

The odds of hitting any door should be the same. Therefore, if one door is confirmed, the probability that the remaining two doors will be won is $ \ frac {1} {2} $, respectively.

This idea is correct if the problem is as follows.

  1. Player selects one door
  2. The moderator randomly shows one of the three doors (including the one selected by the player).
  3. The player chooses one of the two remaining doors

The decisive difference between this question and the Monty Hall problem is ** "whether the moderator can show the door the player is choosing" **. The Monty Hall problem does not allow the above. This difference doesn't matter if the player's selected door is a hit, but if it's a miss, it has a big impact. If the door selected by the player is out, the Monty Hall problem always discloses the other out door. On the other hand, in the above problem, which out-of-door is chosen is completely random, and no hint is given to hit the winning door.

The above is an intuitive explanation, but I think you can be convinced that the probability of hitting is not $ \ frac {1} {2} $ for the time being.

Simulation with Python

Here is an example of simulation using Python. We played the game 10,000 times and calculated the winning percentages when the door was changed and when it was not changed.

import random
random.seed(1)
doors = ["Hit", "Goat", "Goat"]
stay_wins, change_wins = 0, 0

#Repeat enough trials
loop = 10000
for _ in range(loop):
    #Choose the door first
    choose = random.choice(doors)
    #Wins for the winner with or without changing the door+1
    if choose == "Hit":
        stay_wins += 1
    else:
        change_wins += 1

print("---Win rate---")
print(f"If you do not change the door: {stay_wins / loop}")
print(f"When changing the door: {change_wins / loop}")

Output result


---Win rate---
If you do not change the door: 0.3323
When changing the door: 0.6677

Finally

This is Qiita's first post. Any comments are welcome! !!

Recommended Posts

Intuitive explanation that does not rely on mathematical formulas for the Monty Hall problem and simulation with Python
Let's write a simple simulation program for the "Monty Hall problem"
Workaround for the problem that sys.argv is not passed when executing a Python script with only the file name in Python2.7 on Windows
"Manim" that can draw animation of mathematical formulas and graphs with Python
About the problem that the python version of Google App Engine does not mesh
Examples and solutions that the Python version specified in pyenv does not run
A story that I was very convinced when I wrote the code for the Monty Hall problem and calculated the winning percentage
Workaround for the problem that UTF-8 Japanese mail cannot be sent with Flask-Mail (Python3)
[systemd] How to deal with the problem that fancontrol does not work after suspending
[Pyhton] I want to solve the problem that tkinter does not work on MacOS11
Key input that does not wait for key input in Python
Understanding with mathematical formulas and Python LiNGAM (ICA version)
Information for controlling the motor with Python on RaspberryPi
This and that for using Step Functions with CDK + Python
How to solve the problem that APL does not start after transferring to the actual device on Kivy-iOS
Understand the probabilities and statistics that can be used for progress management with a python program
Workaround for the problem that? Is displayed when checking the version when using non-standard perl | python with pkg version
Solve the Monty Hall problem
Solve the Python knapsack problem with a branch and bound method