Diego Hernández Jiménez

Welcome to my personal website! Here I share some of my little projects.

Monty Hall problem simulation

I’ve written a simple program that simulates the famous problem. To do that, I’ve taken advantage of some of the object-oriented features in Python.

Description

Suppose you’re on a game show, and you’re given the choice of three doors: Behind one door is a car; behind the others, goats. You pick a door, say No. 1, and the host, who knows what’s behind the doors, opens another door, say No. 3, which has a goat. He then says to you, “Do you want to pick door No. 2?” Is it to your advantage to switch your choice? (Source:Wikipedia) What should you do?

It is often said that it doesn’t really matter what decision is made, because, after all, both doors have the same probability of hiding the prize, which is 1/3. However, intuition is playing tricks on us in this case, because there is indeed an optimal decision. The probabilities aren’t the same. This can be demonstrated, but, better yet, it can be shown empirically.

How? Because probability is considered the “long term” frequency of the occurrence of an event (from the frequentist view), we can simulate the game thousands of times and record the results that produce different decisions. The frequency of wins and loses when switching the choice or staying with the first choice will be good approximations of the real probabilities.

Go and check the complete code on my Github if you want to know the answer!