Joe's Zaizi take-home challenge

Summary

I've written code to play lots of simulations of the Monty Hall problem. The outcomes are visualised in two graphs below.

The two graphs show different things, but they're both here to try and convince you that the "switch" strategy is more successful than the "stick" strategy.

The initial guesses that the simulated player makes are randomised[1] when this page first loads, and each time you click the Simulate button.

Try adjusting the slider below (then click the button) to vary the number of simulations, and see how both graphs vary. (This might or might not help convince you! And >150 simulations might take a moment to load.) 🙂

What the graph above shows:

After games, the stick strategy produced wins, and the switch strategy produced wins.

So, for the games simulated, the switch strategy produced about more wins than the stick strategy.

In other words, the switch strategy is about twice as successful as the stick strategy.

This tallies with vos Savant's solution, which says that "the switching strategy has a 2/3 probability of winning the car, while the strategy that remains with the initial choice has only a 1/3 probability" (source).

But if this calculation from one set of simulations doesn't convince you...

Let's simulate games times:

What this second graph shows:

Each point shows the result of dividing the total number of "switch" wins for a given simulation by the total number of "stick" wins.

Each of the sets of simulated games has a slightly different outcome, but this graph shows us that there's a trend.

The points are clustered around a value of 2. In other words: the total number of wins for the "switch" strategy is consistently about twice that of the "stick" strategy.