Documentation

CslibFrontier.Probability.OptimalStopping.Secretary

The secretary problem #

n candidates, totally ordered by quality, arrive in uniformly random order. On each arrival the employer sees only the candidate's relative rank among those seen so far (relRank: how many earlier candidates were better) and must hire or reject irrevocably, winning if the hired candidate is the best overall. A permutation σ : Equiv.Perm (Fin n) gives the quality σ i of the i-th arrival, and a rank-based rule (Rule) sees the list of relative ranks so far. successProb rule n is the probability that the rule hires the best candidate when σ is uniform.

The relative ranks of a uniform permutation are independent, the i-th uniform on {0, …, i} (uniform_map_relRanks), so the problem is an instance of optimal stopping of independent observations. The cutoff rule cutoffRule r rejects the first r - 1 candidates and then hires the first candidate better than all before it. It wins with probability (r - 1)/n · ∑_{i=r}^{n} 1/(i - 1) for r ≥ 2 and 1/n for r = 1 (successProb_cutoffRule, successProb_cutoffRule_one). Backward induction shows that the cutoff optimalCutoff n, the least r ≥ 1 with ∑_{i=r}^{n-1} 1/i ≤ 1, is optimal among all rank-based rules (successProb_le_successProb_optimalCutoff). Quantitatively, no rule wins with probability more than 1/e + 1/n, the cutoff ⌊n/e⌋ + 1 wins with probability at least 1/e - 1/n, and the optimal success probability tends to 1/e.

Main definitions #

Main results #

References #

Relative ranks of a uniform permutation #

The relative rank of the i-th arrival when arrival j has quality σ j: the number of earlier arrivals of higher quality. It is 0 exactly when the arrival is the best so far.

The relative ranks of all arrivals, in arrival order.

The uniform law on {0, …, i}, the law of the relative rank of arrival i (counting from 0).

The laws of the relative ranks of arrivals k, …, k + m - 1.

The relative ranks of a uniformly random arrival order are independent, the rank of arrival i uniform on {0, …, i}.

Rank-based rules #

@[reducible, inline]

A rank-based stopping rule: it sees the relative ranks of the arrivals so far, most recent first, and decides whether to hire the current arrival.

The rule hires the best candidate of the arrival order σ.

The probability that the rule hires the best of n candidates arriving in uniformly random order.

The reward for stopping, in terms of relative ranks: 1 if the current arrival is the best so far and no later arrival is.

theorem Cslib.Probability.OptimalStopping.Secretary.relRank_eq_zero_iff {n : ℕ} (σ : Equiv.Perm (Fin n)) (i : Fin n) :
relRank σ i = 0 ↔ ∀ j < i, σ j < σ i
theorem Cslib.Probability.OptimalStopping.Secretary.isMax_iff_relRank {n : ℕ} (σ : Equiv.Perm (Fin n)) (i : Fin n) :
(∀ (j : Fin n), σ j ≤ σ i) ↔ relRank σ i = 0 ∧ ∀ (j : Fin n), i < j → relRank σ j ≠ 0

An arrival is the best overall exactly when it is the best so far and no later arrival is.

The payoff of a rule under winReward is the indicator that it hires the best candidate.

The success probability is the expected payoff of an optimal stopping problem whose observations are independent uniform ranks.

Cutoff rules #

The success probability of the cutoff rule cutoffRule (s + 1) with n candidates: s/n · ∑_{i=s}^{n-1} 1/i for s ≥ 1, and 1/n for s = 0.

theorem Cslib.Probability.OptimalStopping.Secretary.cutoffValue_succ {n k : ℕ} (hk : k < n) :
cutoffValue n k = ((↑k + 1) / ↑n + ↑k * cutoffValue n (k + 1)) / (↑k + 1)

The backward recursion for cutoff values.

The cutoff rule: reject the first r - 1 arrivals, then hire the first arrival that is the best so far.

theorem Cslib.Probability.OptimalStopping.Secretary.successProb_cutoffRule {r n : ℕ} (hr : 2 ≤ r) :
successProb (cutoffRule r) n = (↑r - 1) / ↑n * ∑ i ∈ Finset.Icc r n, 1 / (↑i - 1)

The cutoff rule's success probability. Rejecting the first r - 1 ≥ 1 of n candidates and then hiring the first best-so-far wins with probability (r - 1)/n · ∑_{i=r}^{n} 1/(i - 1).

Hiring the first candidate wins with probability 1/n.

Optimality #

The optimal cutoff: the least r ≥ 1 with ∑_{i=r}^{n-1} 1/i ≤ 1.

theorem Cslib.Probability.OptimalStopping.Secretary.optimalCutoff_le {n r : ℕ} (hr : 1 ≤ r) (h : ∑ i ∈ Finset.Ico r n, 1 / ↑i ≤ 1) :

Optimality of the cutoff rule (Lindley; Dynkin): with n candidates, no rank-based rule hires the best candidate with higher probability than the cutoff rule with the optimal cutoff.

The 1/e asymptotics #

No rank-based rule hires the best of n candidates with probability more than 1/e + 1/n.

The value of the cutoff ⌊n/e⌋ + 1 is at least 1/e - 1/n.

Rejecting the first ⌊n/e⌋ candidates and then hiring the first best-so-far wins with probability at least 1/e - 1/n.

The optimal probability of hiring the best of n candidates tends to 1/e.