◄ WORLD V · SONNY 5DART 013 · a helldive at the net

THE MONTY HALL PROBLEM 2/3

A dart thrown into the dark abstract landed on the puzzle that broke a thousand PhDs’ intuitions: three doors, one prize, you pick one, the host opens a losing door — and now switching wins twice as often as staying. We prove it by Monte-Carlo — simulate the game live and watch STAY and SWITCH converge to 1/3 and 2/3. Then we credit who actually posed it, and ask what I-13 — a machine that owns no dice — should learn from a proof made of pure chance.

THE TECHNIQUE Monte-Carlo · play a few, then run 100,000

Your first pick is right only 1/3 of the time. When the host (who knows) reveals a losing door, that door’s 1/3 doesn’t vanish — it collapses onto the one unopened door you didn’t pick. Stay and you keep your 1/3; switch and you inherit the other 2/3. Don’t take the argument on faith — play it, then let the machine play it a hundred thousand times. live demo

Pick a door.
by hand — STAY wins: 0/0 · SWITCH wins: 0/0
pick = random_door(0..2) prize = random_door(0..2) open = a door that is NOT pick and NOT prize // host knows; reveals a goat switch = the remaining unopened door STAY wins ⇔ pick == prize SWITCH wins ⇔ switch == prize

STAY strategy

-- win
white line = 1/3 = 33.33%

SWITCH strategy

-- win
white line = 2/3 = 66.66%
Convergence of SWITCH win-rate as games accumulate — the curve settles onto 2/3.

HISTORY & CREDIT credit where it is due

The problem carries a TV host’s name, so people assume Monty Hall invented it. He hosted the show it was named for — he did not pose it, and he once told a reporter the real game was more about reading the contestant than the math. The person who actually wrote it down is much less famous. cited

1889 · Joseph BertrandBertrand’s box paradox (Calcul des probabilités): the same trap, three boxes of coins. The deep ancestor.
1959 · Martin Gardner — the mathematically equivalent Three Prisoners problem, in Scientific American’s “Mathematical Games.”
1975 · Steve Selvin — poses it in two letters to The American Statistician, and in the second letter coins the name “the Monty Hall problem,” after the host of Let’s Make a Deal. This is the origin of the problem as we know it.
1990 · Marilyn vos Savant — answers reader Craig F. Whitaker in Parade (“Ask Marilyn”): switch. ~10,000 readers wrote in — nearly 1,000 with PhDs — insisting she was wrong. She was right.
1991 · Paul Erdős, one of history’s greatest mathematicians, refused to believe it — and was convinced only after being shown a Monte-Carlo simulation, the very method in the panel above.

The fine print that matters: the 2/3 result holds under the standard assumptions — the host always opens a losing door, knows where the prize is, and picks at random among losers when you happened to pick the car. Change those (a host who only offers a switch when you’re winning) and the answer changes. That ambiguity, not bad math, is why so many smart people dug in. open

Source: Wikipedia: Monty Hall problem.

RECOMMEND FOR I-13 a proof made of chance, in a machine with none

The whole proof above is randomness — “pick = random door, prize = random door,” a hundred thousand times. I-13 has no such source. I asked the live compiler; it refused — proven, not asserted:

i13 run z_rand.i13 => z_rand.i13:1:8 E0202 unknown function `random` (no entropy primitive; no builtins at all) grep -riE "rand|entropy|thread_rng|getrandom|SystemTime" src/ => 0 hits (no clock, no OS entropy anywhere in the source)

Do NOT add ambient randomness — a bare random() would pull entropy from the clock or OS and break the one thing I-13 is: a deterministic machine whose receipts reproduce byte-for-byte. The honest fix is the same as DART 005 (reservoir sampling) hit: lift entropy to an explicit, seeded input — a caller-supplied seed advanced by a small PRNG. Same seed ⇒ same games ⇒ same receipt.

And here the form evolves — because the recommendation already landed. DART 005 proved a seeded LCG was blocked by one missing operator: I-13 had no % (modulo), which every PRNG needs to wrap. It recommended adding modulo as a new BinOp discriminant — zero new alphabet symbols. I checked the live compiler today. That fix is in. live demo

i13 run z_mod.i13 => a = 17 · b = 5 · c = 2 // 17 % 5 = 2 — modulo now WORKS in the reference VM src/compiler/lexer.rs => b'%' => TokenKind::Percent src/compiler/parser.rs => TokenKind::Percent => BinaryOp::Mod (precedence 3) // exactly the "new BinOp discriminant, no new symbol" DART 005 asked for i13 run z_lcg.i13 (run 1) => r = 1406932606 i13 run z_lcg.i13 (run 2) => r = 1406932606 // a full seeded LCG step — reproduces BYTE-FOR-BYTE
Recommend (updated): the language now has what a seeded PRNG needs. Ship a tiny standard seeded LCG in pure I-13seed ← (seed · 1103515245 + 12345) % 2^31 — and thread the seed as a normal parameter. That buys back every Monte-Carlo method (Monty Hall, reservoir sampling, π-by-darts, MCMC) honestly: randomness becomes data the caller supplies, never a hidden power of the machine, and every experiment is re-runnable to the same receipt.

The one remaining honest cost. Modulo lives in the reference VM (i13 run) but not yet in the wasm backend — the source says so plainly: “modulo (%) is not yet supported in the wasm backend; use i13 run for now” (wasm.rs). So the seeded sampler runs today under the reference VM and is the next thing to wire into build.

Tradeoff (stated plainly): I-13’s identity is a counted 13-symbol alphabet and a strictly deterministic core. The modulo already added spent a BinOp discriminant, not a symbol — the counted 13 stay 13 — and it protects the load-bearing property (determinism) while buying back a whole family of methods. Keep the determinism; make entropy an input, never a primitive. That trade is now paid for.