Quant techniques · optimal stopping

When to stop looking: the secretary problem and the 1/e rule

You will see N candidates one at a time, in random order. After each one you must hire or reject on the spot, and a rejection is final. You only care about hiring the very best. With 100 candidates, can you do better than a 1% chance? Much better: a simple rule gets the best about 37% of the time, and that stays true however large N is.

1Skip the first r, then hire the first one who beats all of them A cutoff rule. The first r candidates only set a benchmark.
2P(r)=rN∑i=r+1N1i−1P(r) = \dfrac{r}{N}\sum_{i=r+1}^{N}\dfrac{1}{i-1} Exact probability of hiring the best with cutoff r (for r ≥ 1).
3P≈xln⁡(1/x),x=r/N⟹x∗=1/e, P∗=1/eP \approx x\ln(1/x),\quad x = r/N \quad\Longrightarrow\quad x^* = 1/e,\ P^* = 1/e For large N: skip about 37% of the candidates, and succeed about 37% of the time.
The derivation

Win exactly when the best of the past is in the benchmark

Fix a cutoff r. You hire the best candidate if and only if:

  • the best is at some position i>ri > r (probability 1/N1/N for each i), and
  • nobody between positions r+1r + 1 and i−1i - 1 beat the benchmark, i.e. the best of the first i−1i - 1 candidates sits in the first r. By symmetry, that has probability r/(i−1)r/(i - 1).

Adding over i gives step 2:

P(r)=∑i=r+1N1N⋅ri−1=rN∑i=r+1N1i−1P(r) = \sum_{i=r+1}^{N}\frac1N\cdot\frac{r}{i-1} = \frac rN\sum_{i=r+1}^{N}\frac{1}{i-1}

For large N the sum is close to ln⁡(N/r)\ln(N/r), so with x=r/Nx = r/N, P≈−xln⁡xP \approx -x\ln x. Setting the derivative −ln⁡x−1-\ln x - 1 to zero gives x=1/ex = 1/e, and then P=1/e≈0.368P = 1/e \approx 0.368. For N = 100 the exact optimum is r = 37, with P = 37.1%. A simulation of 100,000 runs gave 37.0%.

candidates Nlook-only phase r

P(you pick the best) vs r

One run: candidates in the order they arrive

look only, never hirehire the first one better than all of thosewho you hired
–exact P(best) at this r
–simulated P(best)
–runs where nobody beat the benchmark (stuck with the last)
–optimal r and its P(best)

Move r with N fixed. The curve is flat near the top: anywhere from about 25% to 50% of N gives nearly the best result. Skip too few and the benchmark is weak, so you hire someone early who isn’t the best. Skip too many and the best is often in the skipped group; then nobody beats the benchmark and you’re stuck with the last candidate. That happens with probability exactly r/N.

Why cutoff rules are optimal

Backward induction

At any point, the only candidate worth hiring is one who is the best so far (a “candidate” in the jargon); anyone else can’t be the overall best. If candidate i is the best so far, the chance they’re the best overall is i/Ni/N, which rises with i. The chance of doing better by waiting falls with i. So there’s a point after which you should take any best-so-far, and before which you shouldn’t: a cutoff rule. Optimising the cutoff gives the 1/e answer.

This is the template for every optimal-stopping problem: compare the value of stopping now with the expected value of continuing optimally, working backwards from the end. It’s the same calculation as the American option exercise decision in a binomial tree: exercise when intrinsic value beats continuation value.

import numpy as np

def p_best(r, N):
    if r == 0:
        return 1 / N
    return r / N * sum(1 / (i - 1) for i in range(r + 1, N + 1))

N = 100
best_r = max(range(N), key=lambda r: p_best(r, N))
print(best_r, p_best(best_r, N))          # 37, 0.371

rng = np.random.default_rng(0)
wins = 0
for _ in range(100_000):
    x = rng.permutation(N)                # higher = better
    bench = x[:best_r].max()
    pick = next((v for v in x[best_r:] if v > bench), x[-1])
    wins += pick == N - 1
print(wins / 100_000)                     # ≈ 0.370

Variants worth knowing

  • Full information. If you see actual scores from a known distribution (say uniform), you can do better: about 58% for large N, with a threshold that falls as fewer candidates remain.
  • Minimise expected rank instead of maximising P(best): the optimal rule gives an expected rank of about 3.87 as N → ∞ (Chow, Moriguti, Robbins, Samuels).
  • Unknown N, or arrivals in time. If candidates arrive over a fixed period, skip the first 1/e of the time.
  • Selling an asset. Offers arrive one by one and can’t be recalled: the same structure, often with a cost of waiting.

Where people slip in interviews

  • “Skip half of them.” That gives 35% for large N; 1/e ≈ 37% is optimal, though the curve is flat.
  • Forgetting that the probability doesn’t vanish. P(best) stays near 37% as N → ∞; it doesn’t go to 0.
  • Comparing with the best so far, not the benchmark. After the cutoff, hire the first one who beats everyone seen so far, which is the same as beating the benchmark, since no one after the cutoff has been hired.
  • Ignoring the fallback. If nobody beats the benchmark you get the last candidate, which happens with probability r/N.
Practice

Try these before you open the answer

Warm-upN = 3. What's the best cutoff and the probability of hiring the best?
Show answer

r = 0: 1/3. r = 1: 13(1+12)=12\tfrac13\left(1 + \tfrac12\right) = \tfrac12. r = 2: 23⋅12=13\tfrac23 \cdot \tfrac12 = \tfrac13. Best is r = 1, P = 1/2.

N = 4N = 4. Compare r = 1 and r = 2.
Show answer

r = 1: 14(1+12+13)=1124≈0.458\tfrac14\left(1 + \tfrac12 + \tfrac13\right) = \tfrac{11}{24} \approx 0.458. r = 2: 24(12+13)=512≈0.417\tfrac24\left(\tfrac12 + \tfrac13\right) = \tfrac{5}{12} \approx 0.417. So r = 1.

FallbackWith cutoff r, what's the probability nobody beats the benchmark?
Show answer

That happens exactly when the overall best is among the first r: probability r/N.

Large NShow that P ≈ −x ln x is maximised at x = 1/e.
Show answer

ddx(−xln⁡x)=−ln⁡x−1=0⇒x=e−1\tfrac{d}{dx}(-x\ln x) = -\ln x - 1 = 0 \Rightarrow x = e^{-1}. The second derivative, −1/x-1/x, is negative, so it’s a maximum, with value −e−1ln⁡e−1=1/e-e^{-1}\ln e^{-1} = 1/e.

DiceYou may roll a die up to three times and keep the last roll you make. With optimal stopping, what's your expected payoff?
Show answer

Backwards. One roll left: 3.5. Two rolls left: stop on 4, 5 or 6 (above 3.5), so 12×5+12×3.5=4.25\tfrac12 \times 5 + \tfrac12 \times 3.5 = 4.25. Three rolls left: stop on 5 or 6 (above 4.25): 13×5.5+23×4.25=14/3≈4.67\tfrac13 \times 5.5 + \tfrac23 \times 4.25 = 14/3 \approx 4.67.

StretchCandidate i is the best of the first i. What's the probability they're the best of all N?
Show answer

The best of all N is equally likely to be in any position. Given the best of the first i is at a particular place, the chance that the overall best is among the first i is i/N. So P=i/NP = i/N.

The optimum for N = 100 was checked against 100,000 simulated runs. The figure computes the exact curve and simulates 20,000 runs in your browser.