monty_hall_simulation


monty_hall_simulation, a MATLAB code which simulates the "Let's Make a Deal" game in which Monty Hall has hidden a prize behind one of several doors, and the user wins the prize if the correct door is selected.

The player is asked to select one of the doors. Monty Hall then reveals what's behind one of the other doors, which is never the door hiding the prize. The player is then allowed to change their chosen door, or to stay with the original choice. If the user chose the correct door, the prize is awarded.

As it turns out, it is always to the advantage of the user to switch. There is a 1/N chance that they had chosen the correct door to start with, and if they stick with it, they have a 1/N chance of winning. There is an N-1/N chance that they chose the wrong door, followed by a 1/N-2 chance that they will pick the correct door from the remainder. As it happens, 1/N < (N-1)/N/(N-2).

Licensing:

The computer code and data files described and made available on this web page are distributed under the MIT license

Languages:

monty_hall_simulation is available in a MATLAB version and a Python version.

Author:

Original Python code by Christian Hill. MATLAB version by John Burkardt.

Reference:

Related Data and codes:

monty_hall_simulation_test

matlab_simulation, MATLAB codes which use simulation to study card games, contests, and other processes which have a random element. Usually, the purpose is to try to predict the average behavior of the system over many trials.

Source Code:


Last revised on 26 August 2022.