Skip to content
ScienceQuest
Maths & Data Simulator School

Monty Hall Problem Simulator

Play the Monty Hall game, then run thousands of rounds and watch staying settle at 1/3 and switching at 2/3. Open the 100-door game to see why.

Simulator

Tap a door, or press its number, to play a round yourself. Space plays and pauses.

The auto-run has not started. 3 doors.

Switching won
The share of the auto-run’s games won by switching to the door the host left closed. It settles towards 2/3, 66.7 percent.
…
Staying won
The share won by keeping the first pick. In every game exactly one of the two strategies wins, so this and Switching won always add up to 100 percent.
…
Games played
Games in this run so far, seed 1990. The same seed always plays the same games in the same order, so a shared link replays this run exactly.
0
Exact chance if you switch
(N − 1)/N with N = 3: your first pick is right 1 time in 3, and whenever it is wrong the host’s rules leave the car behind the one door he keeps closed.
2/3 (66.67%)
Gap from the exact value
How far the switching rate is from its exact value, in standard errors, √(p(1 − p)/n). About 95 percent of runs sit within ±1.96 at any moment, which is the band the chart draws.
…
The door he left, by Bayes
Every door starts with a chance of 1/3. By Bayes’ theorem, once the host has opened his doors the one he left closed has 2/3 and yours still has 1/3.
1/3 → 2/3
The game

One car and a goat behind every other door. The host always leaves one door besides yours closed, so with 100 doors he opens 98.

The standard game has a host who knows. One who opens doors at random, Monty Fall, sometimes shows the car, and those games are void and left out of the win rates.

Run carries a stopped run on to the next of these.

The seed fixes every game the auto-run plays, so the same seed and settings replay the same run. Play deals from a stream of its own, also fixed by the seed.

Win rate as the games add up

  • Switching won
  • Staying won
  • Exact if you switch, 2/3
  • Exact if you stay, 1/3
  • Where 95 percent of runs land
Win rates in percent against games played in the auto-run, 0 games so far: switching in amber and staying in blue, each with its exact value dashed, 2/3 and 1/3, and faint dashed lines either side of each where 95 percent of runs land, narrowing as the games add up.

Citing this tool

Last updated . Add the date you accessed it as well, which a citation of a page that can change asks for. If a specific result matters, cite the permalink from the tool’s share row instead of this page: it reproduces the exact parameters.

Teaching with this? You can put it on a class page or LMS for free, with no ads inside the frame. Get the embed code.

The equation

P(switch wins)=N−1N,P(stay wins)=1NP(\text{switch wins}) = \frac{N - 1}{N}, \quad P(\text{stay wins}) = \frac{1}{N}

Selvin (1975), The American Statistician

The problem, exactly as the host plays it

One of three doors hides a car, the other two goats. You pick one. The host, who knows where the car is, opens one of the other two to show a goat and offers you the third door instead. You should switch: switching wins the car 2 times in 3, and staying wins it 1 time in 3.

That answer holds for a host who follows four rules in every game, and this simulator plays by all four:

  • He knows where the car is, and never opens its door, or yours.
  • He always opens goats: with N doors he opens N − 2 of them, every one a goat.
  • He always offers the switch, to the one other door he leaves closed, whatever you picked.
  • He chooses at random when he has a choice: if you picked the car, the door he leaves closed is any of the others with equal chance.

Most arguments about the puzzle come from changing one of these rules. The statistician Steve Selvin posed it in a letter to The American Statistician in February 1975, and named it the Monty Hall problem, after the host of the television game show it was modelled on, in a second letter that August. It became famous when Marilyn vos Savant answered it in her Ask Marilyn column in Parade on 9 September 1990 and received thousands of letters, many insisting she was wrong.

Using the simulator

The page opens on the auto-run, which plays the game by those rules with a first pick made at random and scores both strategies in every game: amber where switching wins, blue where staying wins, and green for the car itself. The first six games go slowly enough to watch every door, then the run speeds up to 50 games a second and stops at 1,000. Run carries it on to 10,000 and then 100,000, and the speed control sets anything from 1 game a second to as fast as possible.

Tap any door, or for doors 1 to 9 press its number, to play a round yourself. The host opens his doors and you choose to stay with yours or switch to his, by tapping a door, by its number, with the arrow keys and Enter, or with the buttons under the stage. Your rounds are kept apart from the auto-run, as dots of their own, coloured by which strategy would have won the car.

The Doors slider runs from 3 to 100, with a button for each end, and the host can be made to open his doors at random instead. The ledger under the doors holds the last 1,000 games, one dot each, with the first hundred drawn large so the opening games can be counted as they arrive. The chart below plots each strategy’s win rate as the games add up, with its exact value dashed and the band where 95 percent of runs land. The seed fixes every game, so a copied link replays the same run for whoever opens it.

Worked example: the nine equally likely starts

Every game starts with a car door and a first pick, each one of three, so there are nine starts, each with a chance of 1 in 9. Set them out as a grid, the car’s door down the side and your first pick along the top, the way the Punnett Square Calculator sets out every pairing of two parents’ alleles:

Which strategy wins each of the nine starts of the three-door game
Car behind You pick door 1 You pick door 2 You pick door 3
Door 1 Staying wins Switching wins Switching wins
Door 2 Switching wins Staying wins Switching wins
Door 3 Switching wins Switching wins Staying wins

Staying wins only on the diagonal, where your first pick was the car: 3 starts of 9. Off it, the host has to open the only other goat, so the door he leaves closed is the car, and switching wins: 6 of 9. On the diagonal he has two goats to choose from, which splits each of those three starts in two without changing who wins it, so the count stands at 6 against 3, which is 2/3 against 1/3. The simulator’s opening run, seed 1990, shows the same split in practice: switching won 674 of its 1,000 games, 67.4 percent, and staying won 326.

Why 100 doors make it obvious

Set the doors to 100. You pick one, with a chance of 1 in 100 that it hides the car. The host opens 98 of the others, every one a goat, and leaves one closed. He chose that door knowing where the car was: he kept it shut while showing you every goat but one, so it holds the car whenever your first pick was wrong, which is 99 games in 100. On the stage the whole argument is one frame: a wall of 98 open doors and two still closed, yours in blue and his in amber. With the same seed, switching won 991 of the first 1,000 hundred-door games.

Bayes’ theorem for the host’s door

Bayes’ theorem reaches the same answer from what the host does. Say you pick door 1 and he opens door 3. Before he opens anything, each door has a prior of 1/3. The likelihood of his opening door 3 is 1/2 if the car is behind door 1, since he could have opened either goat; 1 if it is behind door 2, since door 3 is then his only goat; and 0 if it is behind door 3. Each prior times its likelihood gives 1/6, 1/3 and 0, and scaling those to add up to 1 gives:

  • P(car behind door 1 | he opens door 3) = (1/6) / (1/6 + 1/3) = 1/3
  • P(car behind door 2 | he opens door 3) = (1/3) / (1/6 + 1/3) = 2/3

Your door keeps the 1/3 it started with and his collects the rest. With N doors the same working gives 1/N for yours and (N − 1)/N for his, the figures on the stage’s pills and in the readout The door he left, by Bayes. The same theorem turns a positive test result into a chance of disease, with a test’s sensitivity and false positive rate as the likelihoods, which the Sensitivity and Specificity Visualizer draws.

When the host does not know

Choose the host who opens his doors at random and he becomes the one Jeffrey Rosenthal called Monty Fall in Math Horizons in 2008, who slips and happens to push a door open. He leaves one of the other doors closed at random, so sometimes he opens the car, and that game is void. A game survives only when the car is behind your door or behind the one he left, 2 chances in N, so with three doors he reveals the car in 1 game in 3, and with a hundred in 98 games in 100.

In the games he does not spoil, the two closed doors are alike: each had a chance of 1/N to begin with, and his random choice was as likely to leave either one. So each holds the car half the time, and switching wins only half the valid games. With seed 1990 the three-door auto-run voided 336 of its 1,000 games, and switching won 338 of the 664 left, 50.9 percent. Only the host’s knowledge changed, and without it his choice carries no information about the car.

How fast the simulation settles

A run’s switching rate is a share estimated from n games, so it scatters about its exact value p with a standard error of √(p(1 − p)/n), and about 95 percent of runs land within 1.96 standard errors of it. For p = 2/3 that band, the faint dashed lines on the chart, is:

The 95 percent band for the three-door switching rate, and the opening run of seed 1990
Games 95 percent band Runs inside it, counted exactly Seed 1990 switching rate
100 66.7 ± 9.2 percent 94.4 percent 64.0 percent
1,000 66.7 ± 2.9 percent 94.8 percent 67.4 percent
10,000 66.7 ± 0.92 percent 95.0 percent 67.05 percent

The band narrows as 1/√n, so each extra decimal place of agreement costs a hundred times as many games: it takes about 8,500 to bring it inside one point either side. The band is the normal approximation, and the share of runs inside it, counted from the binomial distribution, is a little under 95 percent at first. The Gap from the exact value readout gives a run’s distance in standard errors: seed 1990 sits 0.49 above after 1,000 games and 0.74 below after 100,000, when switching has won 66,556 games.

To test a run formally, put its counts into the Chi-Square Calculator against the expected 2 to 1. The opening run’s 674 and 326 against 666.7 and 333.3 give χ² = 0.242 with 1 degree of freedom, and p = 0.62, which is consistent with chance alone. It is the same arithmetic that makes twenty nuclei in the Radioactive Decay Simulator decay in jagged steps while five thousand follow the curve.

Common mistakes

  • Two doors left means 50/50. Only if they are alike, and they are not: yours was chosen before anything was known, and his by someone who knew where the car was and had to avoid it. Two closed doors can carry 1/3 and 2/3, or 1/100 and 99/100.
  • The host’s choice carries no information. It does, because he must avoid the car. When he could have opened either of two goats, nothing is learnt; when he could open only one, the door he skipped is the car. The ignorant host shows the difference: the same doors, opened at random, leave 1/2 and 1/2.
  • Switching only helps sometimes. Switching loses exactly when your first pick was right, 1 time in 3, and nothing tells you when that is. As a rule for every game it wins twice as often as staying, which no single round can show and a few hundred rounds show beyond reasonable doubt.
  • One run proves the point, or disproves it. After 100 games, about 95 percent of runs land anywhere from 57.4 to 75.9 percent, so a run at 60 percent is unremarkable: seed 1990 stood at 64.0 percent after 100 games and 67.4 percent after 1,000.

Model and assumptions

Method
Monte Carlo over individual events
Repeatability
Random, from a seeded generator. A shared link carries the seed, so it replays the same run, game for game, on any machine.

What it assumes

  • The car is placed behind a door chosen uniformly at random, and the auto-run’s first pick is uniform and independent of it.
  • The host knows where the car is, never opens it or the player’s door, opens every other door but one, and always offers the switch to the one he leaves closed.
  • When the player has picked the car, the host leaves closed one of the other doors, chosen uniformly at random.
  • With the host who does not know, the door he leaves closed is chosen uniformly from the others whatever is behind them, and a game in which he opens the car is void and left out of both win rates.
  • Every game takes exactly three numbers from a seeded xorshift32 generator, for the car, the pick and the door left closed, so game k depends only on the seed and k, and a shared link replays the same run.

Where it stops holding. A host who decides whether to offer the switch by what the player picked, which no fixed probability describes, and a host with favourite doors: one who always opens the lowest-numbered goat he can leaves switching at 2/3 overall but at 1/2 or 1 depending on which door he opens, and finding which takes Bayes’ theorem with his habits as the likelihoods. The Sensitivity and Specificity Visualizer is the right tool there.

Numerical accuracy

No integration error: nothing is integrated. Every game is played exactly by its rules, so the only spread is sampling: after n games the switching rate scatters about its exact value p with a standard error of √(p(1 − p)/n), and about 95 percent of runs lie within 1.96 standard errors of it, the band the chart draws. For p = 2/3 that is ±9.2 points after 100 games, ±2.9 after 1,000 and ±0.92 after 10,000, narrowing as 1/√n. A door is drawn by multiplying one of the generator’s 32-bit numbers by the number of doors and rounding down, which favours some doors over others by at most about N in 2³², two parts in a hundred million at 100 doors, far below anything a run can show.

Monty Hall Problem Simulator: the equation P(switch wins) = (N - 1)/N, P(stay wins) = 1/N.
The equation the simulator is built on, with its source. Image © ScienceQuest, CC BY 4.0. Free to reuse with credit and a link to this page; how to reuse it. Download PNG

Common questions

Should you switch doors in the Monty Hall problem?

Yes. Switching wins the car 2 times in 3 and staying wins it 1 time in 3, because your first pick is right only 1 time in 3, and every other time the host’s rules leave the car behind the one door he keeps closed. A few thousand simulated games settle there: the simulator’s opening run of 1,000 games, seed 1990, ends with switching ahead 674 to 326, 67.4 percent to 32.6, and by 100,000 games switching has won 66.6 percent.

Why isn’t it 50/50 when two doors are left?

Because the two doors are not alike. The host knows where the car is and never opens it, so his choice carries information: your first pick keeps the 1/3 chance it started with, and the door he leaves closed collects the other 2/3. Counting shows it. Of the 9 equally likely pairs of car door and first pick, staying wins the 3 where the pick was the car and switching wins the other 6. When the host opens doors at random instead, the two closed doors really are alike, and then it is 50/50.

What happens in the Monty Hall problem with 100 doors?

You pick one door, a chance of 1 in 100. The host opens 98 of the others, every one a goat, and leaves one closed, which holds the car whenever your pick was wrong, so switching to it wins 99 games in 100. In the simulator’s 100-door run with seed 1990, switching won 991 of the first 1,000 games and 99,026 of 100,000.

Does it matter that the host knows where the car is?

Yes, completely. A host who opens doors at random reveals the car in 1 game in 3 with three doors and 98 games in 100 with a hundred, since a game survives only when the car is behind your door or the one he left, 2 chances in N. In the games where he does not reveal it, switching wins only half the time. With seed 1990 and three doors, he spoiled 336 of 1,000 games and switching won 338 of the 664 left, 50.9 percent.

How many games does it take to see the 2/3?

About 95 percent of runs land within ±9.2 points of 66.7 percent after 100 games, within ±2.9 after 1,000 and within ±0.92 after 10,000: the band the simulator’s chart draws, 1.96 standard errors of √(p(1 − p)/n) either side. It narrows as 1/√n, so each extra decimal place takes a hundred times as many games. Even 100 games put switching ahead of staying in more than 999 runs in 1,000.

What if the host only offers the switch sometimes?

Then the answer can be anything. A host who offers the switch only when you have picked the car makes switching lose every time it is offered, and one who offers it only when you have not makes it win every time. The 2/3 needs a host who always opens a goat and always offers the switch, whatever you picked, which is the rule the simulator plays by and the point every careful statement of the puzzle makes.

Who first posed the Monty Hall problem?

The statistician Steve Selvin, in a letter to The American Statistician in February 1975, and he named it the Monty Hall problem in a second letter that August. Marilyn vos Savant’s Ask Marilyn column in Parade made it famous on 9 September 1990, when she answered that you should switch and received thousands of letters, many insisting she was wrong.