"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. The player hits the new car door. 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? " ([Wikipedia](https://ja.wikipedia.org/wiki/Monty Hall problem))
The correct answer is "change", and the winning percentage when changed is 66.7%.
When I start studying probability statistics and machine learning, one day it comes out in connection with Bayes' theorem.
The Monty Hall problem (Monty Hall problem) is a problem of probability theory, which is one of the examples of posterior probability or subjective probability in Bayes' theorem. It derives from a game controversy in the American game show show "Let's make a deal," hosted by Monty Hall (real name Monte Halperin). It is a kind of psychological trick, and even if the results derived from probability theory are explained, there are still many people who are not convinced, so it is also called a dilemma or paradox. It is a good example of "a problem in which the answer that seems intuitively correct and the answer that is logically correct are different".
At first, I simply dropped the problem statement into the code and executed it, but after thinking a little, it became the following form, and I was convinced without executing it.
python
from random import randint
itr = 10000
cnt = 0
for i in range(itr):
t = randint(1, 3)
c = randint(1, 3)
if t != c:
cnt += 1
print(cnt/itr)
If the first choice is a loss, you can switch to Atari. The probability of choosing a loss first is 66.7%, so if you switch, the winning percentage is 66.7%.
Recommended Posts