Probability puzzles
Jump to the first figure ↓Four old puzzles with answers that are hard to believe until you watch them happen. Each panel deals, shuffles or flips with a seed you can change, plays the round through when you press Play, gives the exact answer where there is one, and checks it against thousands of seeded rounds.
1 Where will the kids end up?
At a science museum, kids lay a shuffled deck of 52 big cards end to end and each stands on one of the first five. In turn, each moves on by the value of the card underfoot, ace to 9 at face value and 10 and the court cards as 1, until the next move would run off the end. Before they start, the guide says where they will all stop. Every card's value decides where its walker goes next, so once two kids stand on the same card they walk on together; with steps this short, their paths almost always meet. The guide only has to walk the deck from the first card. This is the Kruskal count.
How often they all end on one card
2 Hiring the best
n applicants come in a random order. Each is interviewed and then hired or turned away for good, judged only against those seen so far, and only the very best will do. Skip the first r, then hire the first who beats everyone before. That hires the best with chance (r/n) Σj = rn − 1 1/j, highest near r = n/e, where it is close to 1/e ≈ 37% for any large n. Knowing how qualities are spread does better: hire the best so far once their quality is high enough for the number still to come. The 50% threshold rule hires the best applicant seen so far when the chance that no one later is better reaches ½.
The chance of hiring the best
3 The 100 prisoners
100 prisoners each have to find their own number among 100 shuffled tickets in 100 numbered boxes, opening at most 50 boxes each and telling the others nothing. If every one of them finds their number, all go free. Opening boxes at random, each succeeds with chance ½, and all of them together with chance 2−100. Instead, each starts at the box with their own number and opens next the box numbered by the ticket inside: they walk round the loop of the shuffle that ends at their own number, so they all succeed exactly when no loop is longer than 50. That happens with chance 1 − Σk = 51100 1/k ≈ 31%. You can also vary the number of prisoners and how many boxes each may open.
The loops of this shuffle
4 Five heads in a row
A bag holds 9 fair coins and 1 with heads on both sides. You draw one and flip it 5 times: 5 heads. What is the chance that the next flip is heads too? Five heads have chance 1/32 with a fair coin and 1 with the two-headed one, so by Bayes' rule the coin is two-headed with chance 0.1/(0.1 + 0.9/32) ≈ 78%, and the next flip is heads with chance 0.78 + 0.22 × ½ ≈ 89%. The simulation repeatedly draws a coin, flips it, and keeps only the draws that started with five heads.
After k heads in a row
How it works
Seeded
Every deal, line of applicants, shuffle and coin comes from the seed, so a seed gives the same play-through and the same simulation for the same settings; the play-through is the first round drawn from it, and the simulation's rounds follow. Each panel runs in a Web Worker. The API provides the same computations.
The exact answers
Hiring by ranks only wins with (r/n) Σj=rn−1 1/j. The threshold rules win with an integral over the best quality seen so far, taken applicant by applicant on a grid fine near 1, accurate to 2 × 10−7; with two applicants it gives the known ¾, and Gilbert and Mosteller's rule approaches their 58.02% as n grows. The prisoners' chance follows one loop at a time: a loop through a prisoner has each length up to n with chance 1/n, and the rest of the shuffle is again a uniform shuffle; it matches every permutation of up to 7 boxes exactly. The coins are Bayes' rule. The Kruskal count has no closed form, only the simulation.