monty_hall_simulation, an Octave 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).
The computer code and data files described and made available on this web page are distributed under the MIT license
monty_hall_simulation is available in a MATLAB version and an Octave version and a Python version.
Original Python code by Christian Hill. This version by John Burkardt.
octave_simulation, an Octave code which uses 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.