Secretary Problem Colab Notebooks and Teaching Resources

Four guided Google Colab notebooks with mathematical explanations, optimal stopping simulations, and classroom exercises.

Teaching Resources: Google Colab Notebooks

These materials accompany The Secretary Problem Site. Each notebook combines a short mathematical introduction, the stopping rule, Python code that runs in Google Colab, a reproducible simulation, and suggested exercises. You can read and run the material directly in your browser; you do not need to open a terminal or install Python locally.

The notebooks are written for independent study or classroom use. They use Python’s standard library for mathematics and simulations; optional charts use Matplotlib (already available in Google Colab).

Important: A simulated success rate illustrates the mathematical result but does not establish optimality. Exact formulas or backward induction justify the stopping rules presented here.

Classical secretary problem

Derive the exact finite-(n) probability, find the optimal rejection threshold, simulate uniform random permutations, and compare Monte Carlo outcomes with the theoretical curve.

Open in Google Colab · Download notebook (.ipynb)

Last-success problem and Bruss’s odds theorem

Study independent Bernoulli observations, compute the sum-the-odds stopping index, simulate the last-success objective, and compare exact and estimated winning probabilities.

Open in Google Colab · Download notebook (.ipynb)

Postdoc problem: selecting the second best

Solve the finite-horizon problem by exact backward induction over relative ranks, then simulate policies using random permutations to validate the success probability.

Open in Google Colab · Download notebook (.ipynb)

Full-information secretary problem

Derive the first-stage optimal decision for two and three independent uniform observations; simulate success conditional on the initial value and graph the stop–continue crossover.

Open in Google Colab · Download notebook (.ipynb)

Interactive demonstrations on this site

Suggested learning sequence

  1. Begin with the classical notebook to understand random order, records, and the finite-(n) rejection threshold.
  2. Use the postdoc notebook to see how changing the target from the best to the second best changes the optimal decisions.
  3. Compare that relative-rank problem with the full-information notebook, which observes numerical values.
  4. Study the last-success notebook to learn a different optimal-stopping objective and the sum-the-odds rule.

Reproducibility and mathematical tests

Each notebook uses a fixed random seed in its simulations. You can vary the parameters or the number of trials and compare Monte Carlo frequencies with the exact probabilities.

The site’s source repository also contains automated mathematical regression tests for the reference calculations. Those developer tests are kept separate from these student-facing notebooks.

Sources

The foundational work is described in References. The classical and full-information problems draw on Gilbert and Mosteller (1966), and the last-success model uses Bruss (2000). The postdoc notebook uses the relative-rank model presented on the Variants page.


Leer en español