100 candidates are interviewed one at a time in a random order, and after each one he must hire or reject on the spot, knowing only how the people he has met rank against each other. He wins only if he hires the best of all 100.
What is his best strategy, and what are his chances?
Write for the number of candidates. The film's rule has one dial, : let the first go, whatever they are like, then hire the first one who is better than all of them. If nobody is, he is handed the last in the queue.
This is the film's first route. The bar he carries is the best he has seen, so whoever clears it is the best so far: he only ever hires a best-so-far. So he gets the best of all exactly when the best of all is at some place after the cut, and nobody between the cut and was a best-so-far. That second condition says the best of the first is among the first .
The best of all is equally likely to be at any of the places. Given that it is at place , the best of the before it is equally likely to be at any of those places, and of them are in the block he let go. So
which is the claim, written with .
Where the top is, exactly. Moving the dial from to changes the chance by
shrinks as grows, so the chances climb while it is more than 1 and fall once it is less: one hump. The best cut-off is the first at which has dropped to 1 or below. For that is .
This is the film's second route. Measure how far through he is instead of counting: , and the best candidate at . Each term of the sum is , so the sum is a Riemann sum for
Its derivative is , which is zero at , and the height there is . The same number answers how long to wait and how often he wins, because at the peak , so equals . One fact read twice. Over the hundred cut-offs, the film's bars never stray more than 0.0057 from the curve.
The step rule says the same thing in other words. is about , and it drops to 1 when is about .
The film turns one dial and finds its best setting. It does not show that a cleverer rule, one that reacts to what it sees, could not beat it. None can, and the reason is short.
He sees only how each candidate ranks against the ones before. Two facts about a random order:
So hiring someone who is not the best so far never wins, and hiring a best-so-far at place wins with chance . Let be the best chance he can still have after letting the first go. By fact 1 it does not depend on what he saw, and , because from place he could always let one more go. At a best-so-far at place he should hire when . The left side only grows with and the right side only shrinks, so once hiring is right it stays right. The best rule is therefore: let some number go, then take the first best-so-far. That is a cut-off rule, and proof one has found the best cut-off.
Tossing coins does not help either. A rule that picks a rule at random wins with the average of their chances, which is no more than the best of them.
The film plays ten cards, whose qualities come in the order 9, 1, 7, 6, 2, 10, 4, 5, 8, 3. The best is 10.
With he hires the first card, a 9. With the best of the three he lets go is a 9, and the first to beat it is card 6, the 10. With the 10 is inside the block, nobody after it can beat it, and he is handed the last card, a 3.
On this order every cut-off from 1 to 5 wins. He wins whenever the cut falls between the last two best-so-fars, here the 9 at card 1 and the 10 at card 6, and the hump is that window averaged over every order.
| k | Bar | Card | Got | Result |
|---|---|---|---|---|
| 0 | — | 1 | 9 | lost |
| 1 | 9 | 6 | 10 | the best |
| 2 | 9 | 6 | 10 | the best |
| 3 | 9 | 6 | 10 | the best |
| 4 | 9 | 6 | 10 | the best |
| 5 | 9 | 6 | 10 | the best |
| 6 | 10 | 10 | 3 | forced last |
| 7 | 10 | 10 | 3 | forced last |
| 8 | 10 | 10 | 3 | forced last |
| 9 | 10 | 10 | 3 | forced last |
At ten candidates the best cut-off is 3, which wins 39.9% of the time (0.39869), with a hair behind at 0.39825. That is 30% of the way through, not 37%: ten is not yet the limit. At 100 the best is 37 with 0.37104, and the top is flat. Every cut-off from 29 to 45 is within one percentage point of the best, and every one from 26 to 49 within two. The film says that anywhere from a quarter to a half of the way through beats one in three; in fact every cut-off from 22 to 54 does.
The 37% is not the whole story. He hires nobody exactly when the best of all was in the block he let go, so with the dial at that happens with probability exactly : here , or 37.0%. Then he is handed the last in the queue, who is equally likely to be any rank but the first. The rank he ends up with, exactly:
| He ends up with | Chance |
|---|---|
| the best | 37.10% |
| the second best | 13.93% |
| one of the top five | 62.78% |
| one of the top ten | 66.29% |
| the bottom half | 18.69% |
| nobody, so the last in the queue | 37.00% |
The median hire is the 2nd best, and the mean rank is 20.0. Mostly he does very well, and about one time in five he ends up with someone from the bottom half. Every one of those is the forced last candidate: someone he chose, a best-so-far after 37 others, is in the bottom half with probability below .
Pick the number of candidates and the cut-off, and interview. The bars are the exact chance for every cut-off, the gold bar is the best one, and the dashed line is .
| Let go k | Exact | Simulated | Of the way through |
|---|---|---|---|
| 0 | 0.0100 | 0.0120 | 0% |
| 10 | 0.2348 | 0.2268 | 10% |
| 20 | 0.3259 | 0.3207 | 20% |
| 30 | 0.3647 | 0.3600 | 30% |
| 37 | 0.3710 | 0.3795 | 37% |
| 45 | 0.3621 | 0.3630 | 45% |
| 60 | 0.3085 | 0.3030 | 60% |
| 80 | 0.1795 | 0.1860 | 80% |
| 99 | 0.0100 | 0.0110 | 99% |
Any number of candidates. The step rule finds the best cut-off for any :
| N | N/e | Best k | Chance |
|---|---|---|---|
| 3 | 1.1 | 1 | 0.50000 |
| 5 | 1.8 | 2 | 0.43333 |
| 10 | 3.7 | 3 | 0.39869 |
| 20 | 7.4 | 7 | 0.38421 |
| 50 | 18.4 | 18 | 0.37428 |
| 100 | 36.8 | 37 | 0.37104 |
| 1,000 | 367.9 | 368 | 0.36820 |
| 10,000 | 3,678.8 | 3,679 | 0.36791 |
| 1,000,000 | 367,879.4 | 367,879 | 0.36788 |
For every up to 10,000 the script finds the best is rounded either down or up, with between −0.74 and 0.32. It is not always the nearest whole number: for 1,841 of those , rounding to the nearest gives the wrong one, though only by a hair. The best chance falls as grows, and never reaches . That is checked for every up to 10,000, and the next section proves it for every .
The film's rule needs : you cannot let 37% of the candidates go without knowing how many there are. Suppose instead that nobody knows how many will come, only that they arrive at independent random times through the day, which runs from time 0 to time 1. Then let everyone who comes before time go, and hire the first best-so-far after it.
Say come, and the best of them arrives at time . If nobody came before , he hires her. Otherwise the best of those who came before is equally likely to have come at any moment of , so with chance she came before , and then nobody between and was a best-so-far and he hires the best. So the chance, given , is , which is . The first part integrates to , so
The integral is positive, since all the way along it, so at the chance is more than for every . He does not need to know , or even how likely each is: whatever the number, waiting for of the day wins more than of the time. This is Bruss's 1/e-law (1984). One candidate wins 63.2%, which is ; two win 43.2%; a hundred win 0.36788, just under the counting rule's 0.37104. Setting the dial by a count that turns out wrong is far worse:
| Candidates who come | Let 37 go | Wait for 1/e of the day |
|---|---|---|
| 10 | 10.0% | 36.8% |
| 30 | 3.3% | 36.8% |
| 50 | 22.5% | 36.8% |
| 100 | 37.1% | 36.8% |
| 300 | 26.0% | 36.8% |
| 1,000 | 12.2% | 36.8% |
| 10,000 | 2.1% | 36.8% |
This proves the floor. If he does know , he can draw random times himself, sort them, and pretend the candidates arrived at those times. That is the clock rule, a rule that tosses coins, and proof three says the best cut-off does at least as well. So the best cut-off wins more than of the time for every . The script checks the two against each other for every up to 60.
He wants a good one, not the best. Best-or-nothing is what makes 37% the answer. If instead he wants the rank of the one he hires to be small on average, the best rule is different: at each place, hire if the expected rank of this candidate is no worse than what he can expect by going on. Hiring the -th candidate when she ranks -th among the first gives an expected rank of . Working back from the end gives an expected rank of 3.60 at , against the 37% rule's 20.0. However many candidates there are, it never passes 3.8695, the limit found by Chow, Moser, Robbins and Samuels in 1964.
| Candidates | Expected rank, best rule |
|---|---|
| 10 | 2.558 |
| 100 | 3.603 |
| 1,000 | 3.832 |
| 1,000,000 | 3.869 |
He can see scores. The film says he has an ordering and no scores. Suppose each candidate instead comes with a score, drawn independently from a distribution he knows, say uniform between 0 and 1. With a score in front of him and still to come, hiring wins if all score below , and waiting for the next one above wins with chance if of them do. So he hires a best-so-far when
which is a bar that falls as the queue runs out. With , 60,000 seeded runs of that rule get the best 58.3% of the time. The limit, found by Gilbert and Mosteller in 1966, is 0.5802.
The order is not random. Everything rests on the random order. If whoever sends the candidates in can choose the order, no rule can be sure of more than . Let them pick a place at random, send candidates in rising quality up to , and everyone worse after it. Until every candidate is a best-so-far, so nothing he sees tells him where he is, and he wins only if he happens to stop exactly at : chance . Hiring a candidate at random gets that much anyway.
scripts/secretary.mjs reads the film's trials.json and recomputes it: the exact curves at 10, 100 and 1000 candidates, the best cut-offs, the flat top, the table of sizes, and the three runs on the ten cards. Any disagreement stops the build. Then it checks what the film does not show.
The sum, by brute force. Every order of up to 8 candidates is played at every cut-off. The wins, the times he hires nobody, and the whole distribution of the rank he ends up with match the formulas exactly. The wins are compared as whole numbers.
| n | Orders | Best k | Chance |
|---|---|---|---|
| 3 | 6 | 1 | 0.50000 |
| 4 | 24 | 1 | 0.45833 |
| 5 | 120 | 2 | 0.43333 |
| 6 | 720 | 2 | 0.42778 |
| 7 | 5,040 | 2 | 0.41429 |
| 8 | 40,320 | 3 | 0.40982 |
No better rule. From the same 40,320 orders and fewer, the script builds every history of relative ranks he could see, and checks facts 1 and 2 of proof three at every node. It then finds the best rule of any kind by working back from the end, and gets the best cut-off's chance every time. The working back of proof three is run for every up to 1,000 and lands on the step rule's cut-off each time. The step rule itself is checked against the exact curve at every for every up to 300.
Simulation. The film's own Monte Carlo is re-checked against the exact sum, and the script runs its own, seeded so the page is the same page every build:
| Orders | Worst gap, any cut-off | At k = 37 | |
|---|---|---|---|
| the film's own (Python, seed 14) | 200,000 | 1.66 standard errors | 0.37209 |
| this page's (seed 14) | 100,000 | 2.52 standard errors | 0.37364 |
| the exact sum | 0.37104 |
Played literally at over 100,000 orders, that simulation gets the best 0.3726 of the time, hires nobody 0.3711 of the time, and averages rank 20.0. The clock rule is simulated on 60,000 days, each with a random number of candidates from 1 to 200. It wins 0.3718 of the time, against the formula's 0.3697.
What is not checked. The limits, here and 3.8695 and 0.5802 in the variants, are theorems. The script computes the finite values and checks that they approach them, and the full-information limit is quoted, not derived. Proof three holds for every ; the script checks it in full for and by working back up to 1,000. The film's 37.0% for hiring nobody is exact. Its script's 36.9% is the simulated figure, which is fine but not the same thing.
Let one go, and you win half the time. Write the qualities in the order they come, with 3 the best. Of the 6 orders, letting one go wins on 132, 213, 231: 3 of them. Letting nobody or two go wins on two each.
He hires nobody when nobody after the block beats the best of the block. That happens exactly when the best of the block is the best of all, that is, when the best of all is in the block. The best is equally likely to be in any of the places, and of them are in the block.
, which is less than 1, so moving from 3 to 4 loses . And , which is more than 1, so 3 beats 2. The best is 3.
With the integrand is , so . At that is , or 43.2%.