Aisha Bello had two numbers on her screen, and they disagreed.
In This Chapter
- 27.1 Why Simulate? From One Race to Ten Thousand
- 27.2 The Engine: Every Ingredient, Measured
- 27.3 One Race, Then Ten Thousand
- 27.4 Anchor C in Full: The Singapore One-Stop vs Two-Stop
- 27.5 How Many Runs? Convergence and Monte Carlo Error
- 27.6 The Whole Field: When Seconds Become Positions
- 27.7 What Moves the Answer? A Sensitivity Tornado
- 27.8 Validation: The 2026 United States Grand Prix from Its Grid
- 27.9 What the Engine Cannot See
- Spaced Review
- Project Checkpoint: montecarlo.py
- Chapter Summary
- What's Next
Chapter 27 — Monte Carlo Race Simulation: Modeling Every Possible Race Outcome to Find the Optimal Strategy
Aisha Bello had two numbers on her screen, and they disagreed.
The first came from her own code in Chapter 14. She raced a one-stop and a two-stop through 10,000 simulated Singapore Grands Prix, each with randomly drawn safety cars. Her answer was that the two-stop was 9.44 s slower on average and faster in 10.7% of races. The second came from the book's data snapshot. It used the same circuit, the same tyre model, the same hazard and the same 10,000 races, and it said 10.36 s slower and faster in 16.8%.
Aisha: Same question, same data, two answers. One of them is wrong. Ray: Or neither is, and they're answering slightly different questions. Forty years of actuarial work, and I never once saw two models agree to the decimal. Aisha: A 60% difference in the probability isn't a decimal. Ray: No. But look at what they agree on. Both say the two-stop loses. Both say it loses by about ten seconds. Neither says it loses every time. Ines: Then what did happen at Singapore this year?
Here is what happened. On lap 39 of the 2026 Singapore Grand Prix, race control deployed a virtual safety car. Charles Leclerc, second on track on MEDIUM tyres fitted at the end of lap 24, came into the pits and took SOFTs. So did Andrea Kimi Antonelli, on MEDIUMs from lap 23. Max Verstappen, leading on MEDIUMs from lap 32, stayed out. Verstappen won the race on one stop. Leclerc and Antonelli finished second and third on two stops. Lewis Hamilton, on 23-lap-old SOFTs at that moment, stayed out and finished sixth.
So the folklore ("two-stop at Singapore, because of the safety cars") was wrong for the winner and right for second and third. The simulation said the option of a second stop is worth something and the commitment to two stops is not. That is close to what the timing sheet shows. But "close" is not good enough for a strategy tool. We need to know why two careful simulations of the same race disagree, which one to believe, how many simulated races it takes before the answer stops moving, whether a one-car model survives contact with twenty-one other cars, and whether any of this predicts a real race we have not yet seen.
That is this chapter. We build Box Box's race engine, montecarlo.py. It races a whole field lap by lap through drawn safety cars, lap-1 shuffles, retirements, traffic, overtakes and pit stops. Then we use it to:
- treat Anchor C, the Singapore safety-car gamble, in full, reconciling Chapter 14's number with the book's;
- measure how the answer converges as the number of runs grows;
- stress-test every input;
- validate the engine on a real 2026 race simulated from its grid.
The engine will reproduce the book's earlier Anchor C to within Monte Carlo error, and then replace it with the current-data answer. It will then tell us something neither earlier version could: at a circuit where you can barely pass, the "free" safety-car stop is not free.
📊 Analytics Track: Everything, with the code. Sections 27.2 (the engine), 27.5 (convergence) and 27.8 (validation) are the core. You will finish able to build, calibrate and validate a field-level Monte Carlo race simulator.
🎰 Betting Track: Sections 27.1, 27.5 and 27.8, and Case Study 2. A simulator that outputs P(win) is a pricing machine. This chapter shows how to check whether its prices are calibrated, and how it compares with the crude base rate a bookmaker starts from.
🏎️ Fan Track: This is a code-optional chapter on your track. Read 27.1, the prose of 27.4 and 27.6, and Case Study 1, which replays the 2026 Singapore Grand Prix. Skip the code blocks; every result is explained in words after it.
27.1 Why Simulate? From One Race to Ten Thousand
Chapter 12 framed strategy as an optimisation: choose the stops and compounds that minimise race time. Chapter 12's optimiser answers "what is fastest in a clean race?" with closed-form stint costs. It is exact, fast and useful. It is also answering a question that almost never comes up. Of the 91 Grands Prix of 2023–2026 in our data, 72.5% had at least one safety car, virtual safety car or red flag (66 of 91, race control). A clean race is the exception.
Once random events enter, a strategy stops having one race time. It has a distribution of race times, one for every way the race could unfold. Comparing strategies means comparing distributions, and that forces three questions the clean-race optimiser never asks:
- Which summary do we compare? The mean (expected) race time, the median, the probability of beating the alternative, the probability of winning, or the expected championship points? These can disagree, and Section 27.4 shows a case where they do.
- How do we get the distribution? For a single neutralisation we could do the algebra; Chapter 14 did it with
neutralised_stop_gain. For a race with several possible incidents, each of random kind, length and timing, each changing what every car should do next, the algebra becomes hopeless. We simulate. - How much do we trust it? A simulation has two kinds of error. The first is Monte Carlo error: it ran a finite number of races. The second is model error: the simulated world is not the real one. We can make the first as small as we like with more runs. The second needs validation against real races.
📐 Definition: Monte Carlo simulation. A method that estimates a quantity (an expected value, a probability, a distribution) by drawing many random samples from a model of the process and summarising them. For a race strategy: draw $n$ complete races from a probability model of everything we do not control, race each strategy through every one of them, and estimate $E[\text{outcome}]$ by the sample mean. By the law of large numbers the estimate converges to the model's true expectation as $n$ grows, with standard error $\sigma/\sqrt{n}$.
The idea has a respectable pedigree in motorsport research. Heilmeier and colleagues (2020) published a Monte Carlo race simulation for circuit racing with probabilistic accidents, failures and pit stops. Bekker and Lotz (2009) used discrete-event simulation to plan Formula 1 strategies. Our engine is in the same family. It is simpler than a team's, built entirely on free data, and every input is measured in this book or labelled as an assumption.
🧩 Productive struggle. Before any code: at Singapore a two-stop is 10.4 s slower than a one-stop in a clean race (Section 27.4 computes this). A stop under a safety car costs about 0.64 of a green stop (Section 27.2), and a green stop at Singapore costs 23.9 s. Suppose a safety car arrives at exactly the right moment and the two-stop takes one of its stops under it. Does that rescue the two-stop? What about two well-timed safety cars? Write down your guess, and the arithmetic, before you read on.
One way to reason it through
A stop under a safety car saves about 23.9 × (1 − 0.64) ≈ 8.6 s against a green stop. One perfectly timed safety car therefore turns the two-stop's 10.4 s deficit into about 1.8 s, still slower. Two perfectly timed safety cars would turn it into a gain of about 7 s.
But the one-stop can use the same safety car: if it arrives before its single stop, it moves that stop into the neutralisation and pockets the same 8.6 s. A safety car only helps the two-stop relative to the one-stop when it falls where the two-stop can use it and the one-stop cannot, for example after the one-stop has already stopped. That is why the answer needs a simulation, not a back-of-envelope sum. The timing of the incident relative to both plans matters, and so does the chance of a second incident.
What a simulator must contain
A race simulator is a model of everything that moves the finishing order. The classic list of ingredients is random safety cars, weather changes, mechanical failures and first-lap incidents. To those we add the ones that turn time into position: traffic, overtaking and pit-stop cost. Every ingredient needs a number, and the next section measures each one.
| Ingredient | What is random | Where its numbers come from |
|---|---|---|
| Base pace | a car's true pace on the day (optional) | race pace, qualifying (Chapter 20) |
| Tyres | true deg and offset vs the model's estimate | degradation models (Chapter 22) |
| Lap noise | every lap | driver noise model (Chapter 9) |
| Lap 1 | the order after lap 1, lap-1 retirements | real lap-1 outcomes by grid slot (Chapter 17) |
| Neutralisations | start lap, kind, length | race-control hazard and incident library (Chapter 14) |
| Reliability | which cars retire, and when | DNF rates (Jolpica results) |
| Pit stops | each stop's loss, green or neutralised | measured stop losses (Chapters 12 and 14) |
| Traffic | who catches whom, who passes | dirty-air cost (Chapter 20), pass model calibrated to measured passes |
| Weather | rain | not modelled here; dry races only (Chapter 36) |
🔄 Check your understanding. A friend says: "Monte Carlo is just averaging lots of random races, so with 10,000 runs the answer is exact." What is right and what is wrong about that?
Answer
It is right that 10,000 runs make the Monte Carlo error small: the estimate is very close to what the model would say with infinitely many runs. It is wrong to call the answer exact. It is exact only for the model. If the model's degradation, hazard or pass probability is wrong, 10,000 runs give you a precise estimate of the wrong number. More runs reduce sampling error. Only better inputs and validation reduce model error.
27.2 The Engine: Every Ingredient, Measured
This section walks through montecarlo.py piece by piece. The script code/01_engine_ingredients.py measures every input from the book's data and caches the tables later scripts read.
The lap-time equation
On a green lap $L$, car $i$ on compound $c$ with tyre age $a$ has a free-air lap time
$$ t_{i,L} = T_0 + p_i + u_i + f \cdot L + o_c + d_c \, a + w_c \,\mathbb{1}[a = 1,\ \text{after a stop}] + \varepsilon_{i,L}. $$
In words, the lap time is the sum of these terms:
- the race's base lap $T_0$;
- the car's pace offset $p_i$ and, optionally, a random error in that offset $u_i$ (drawn once per race);
- a common fuel and track-evolution term $f$ per race lap;
- the compound's offset $o_c$ against the MEDIUM and its wear $d_c$ per lap of tyre age;
- a warm-up penalty $w_c$ on the second lap of a set fitted at a stop;
- lap noise $\varepsilon$.
For example, take a car 0.109 s off the reference pace, 30 laps into the race, on a 15-lap-old MEDIUM at Singapore. It runs $T_0 + 0.109 + 30f + 0 + 0.0417 \times 15 = T_0 + 0.109 + 30f + 0.626$ s, plus noise. The term $30f$ is the same for every car, so it moves race times but never the order.
⚠️ Common pitfall: mixing fuel conventions. The wear rate $d_c$ and the fuel term $f$ must come from the same fuel correction, or the engine double-counts or loses the fuel effect. In this book's data the raw (uncorrected) MEDIUM and HARD stint slopes are about zero, because falling fuel hides the wear; the toolkit's default correction (100 kg start fuel at 0.03 s/kg, a labelled ASSUMPTION) adds 3.0/N s/lap to every slope (Chapter 22). So:
- deg fitted with the default correction pairs with $f = -3.0/N$;
- deg from a fixed-effects model with its own lap-number term pairs with that model's slope;
- raw deg pairs with $f = 0$.
TyreModelcarries afuellabel so every simulation states which one it used. The Singapore model in Section 27.4 uses the fixed-effects slope (fuel plus track evolution, −0.0418 s/lap in 2026). The validation in Section 27.8 uses default-corrected deg with $f = -3.0/56 = -0.054$ s/lap.
Lap noise. We use the 2026 field noise model of Chapter 9. It has an AR(1) core with $\sigma = 0.288$ s and lag-1 autocorrelation $\rho = 0.413$, plus "error laps": with probability 0.055 a lap is at least 1 s slow, with a mean excess of 2.17 s. The autocorrelation matters. A driver who is a tenth slow on one lap tends to be slow on the next, which spreads 50-lap totals wider than independent noise would.
Neutralisations: when, what kind, how long
The hazard model is Chapter 14's. An incident groups SC, VSC and red-flag windows that overlap or follow within 30 s, and it starts on the leader's lap. Its rate per lap at risk depends on the race phase:
Per-lap incident hazard by phase (race control, 2023-26, red flags in both wordings):
phase events laps_at_risk lam lo hi
lap 1 16 91 0.1758 0.1005 0.2855
laps 2-10 24 744 0.0323 0.0207 0.0480
middle 65 3491 0.0186 0.0144 0.0237
final 10 13 871 0.0149 0.0079 0.0255
all laps 118 5197 0.0227 0.0188 0.0272
Book constant used by the engine (toolkit-window version, as in the data snapshot): {'lap 1': 0.1758, 'laps 2-10': 0.0309, 'middle': 0.0186, 'final 10': 0.0149}
Incident library (kind and length in laps):
size median mean max
kind
RED 14 2.0 2.50 9
SC 52 4.0 4.87 10
VSC 52 1.0 1.73 6
Two versions of the laps 2–10 hazard appear: 0.0323 (24 of 744) and the book constant 0.0309 (23 of 745). The difference is one incident. It comes from the 2026 red-flag messages, which race control wrote as RED FLAG - RACE SUSPENDED with no flag value. Chapter 14 found that wording, and the book's build now reads it. The 2026 Dutch Grand Prix's lap-2 stoppage counts as a separate incident only when that wording is read. The engine keeps the book constant so that Anchor C stays on the snapshot's footing. Section 27.4 measures how much this choice matters; it is small.
On each lap that is not already neutralised, the engine starts an incident with probability $1 - e^{-k\lambda(\text{phase})}$. Here $k$ is the circuit's hazard multiplier (Chapter 14: observed incidents ÷ incidents expected from the all-circuit phase rates). Once an incident starts, the engine draws a kind and length jointly from the library of 118 real incidents. Drawing them together keeps the correlation: VSCs are short (median one neutralised lap), safety cars last about four laps, and red flags vary.

📊 Figure (described): Left: the per-lap incident hazard by phase, 2023–2026, with exact Poisson 95% intervals. Lap 1 (0.176) towers over the rest, and the hazard then falls from 0.032 (laps 2–10) to 0.015 (the last ten laps). Right: incident lengths, stacked by kind. VSCs cluster at one or two neutralised laps, safety cars spread from two to ten, and red flags are few. The engine draws each new incident's kind and length together from these 118 real cases.
Lap 1 is linked to retirements. Chapter 17 found that of 21 races with a lap-1 retirement in 2023–26, 12 had a lap-1 neutralisation; of the 70 without one, only 4 did. A first-lap crash and a first-lap safety car are usually the same event. The engine therefore draws lap 1 first (below). It then sets the lap-1 incident probability to $1-(1-0.571)^k$ if any car retired and $1-(1-0.057)^k$ if none did. It does not use the unconditional 0.176.
What a pit stop costs
A green stop draws its loss from a pool of measured stops at the circuit (the canonical metrics.pit_loss). It does not use a single median, and the reason is in the shape of the pool. At Singapore in 2025–26 the 40 green stops have a median of 23.866 s but a mean of 24.993 s: a few slow stops drag the mean up. Every stop in the simulation can be one of those slow ones.
Under a neutralisation, the loss is the green draw multiplied by a ratio drawn from the measured distribution. We measure each stop relative to the field: (pitting car's in-lap + out-lap) minus the median of the same two laps for cars that did not pit. We then divide by that race's median green stop. This is the measure behind Chapter 14's "field" ratios.
Field-relative stop loss (in-lap + out-lap minus the same laps of cars that stayed out), dry stops 2023-26:
GREEN n = 1917 median loss 22.522 s median ratio to the event's green 1.000 IQR 0.93-1.08 mean ratio 1.120
SC n = 250 median loss 15.814 s median ratio to the event's green 0.639 IQR 0.41-1.00 mean ratio 0.705
VSC n = 203 median loss 17.846 s median ratio to the event's green 0.751 IQR 0.55-1.13 mean ratio 0.903
SC ratio pool after 5-95 % trim: n = 220, median 0.639, mean 0.688
VSC ratio pool after 5-95 % trim: n = 181, median 0.751, mean 0.857
(The engine's decision model plans with Chapter 14's field medians, 0.632 for an SC and 0.771 for a VSC. The pools above give 0.639 and 0.751. The differences are small, and keeping Chapter 14's planning values lets Section 27.4 reproduce Chapter 14 exactly.)
Look at the gap between the planning ratio and the mean of the trimmed pools: 0.632 against 0.688 for an SC, and 0.771 against 0.857 for a VSC. A strategist who plans with a median ratio will, on average, pay more than planned for every neutralised stop. That asymmetry is one of the reasons Chapter 14's number and the book's differ, as Section 27.4 shows.

📊 Figure (described): Right: the distribution of stop losses as a fraction of the same race's median green stop. SC stops (solid) sit left of VSC stops (dashed), which sit left of green stops (dotted), but all three overlap widely. Some SC stops cost almost nothing, and some cost more than a green stop when the timing falls badly. Left: the lap-1 resampler's mean places gained by grid slot, from 69 real ground-effect-era starts. Front-row cars lose a little on average, and the back of the grid gains.
For comparison, the near-field measure of Chapter 14 (each stop against the cars near it on track) gives 12.722 s under an SC and 15.671 s under a VSC, against 22.512 s green. Those are the book's canonical numbers for "what a stop costs under a safety car". The field-relative ratios are the more conservative choice, and Section 27.7 shows that swapping one for the other moves the Singapore answer by about a second.
Lap 1, retirements, and neutralised laps
Lap 1. The engine copies a whole real lap 1. Each simulated start picks one of the 69 ground-effect-era races (2022–25) that had all 20 front slots filled. Every car then takes the fate of the car that started in its slot in that race: a lap-1 position, or a lap-1 retirement. This is Chapter 17's "race" method, vectorised. It keeps the joint structure: two cars cannot both lead, and a pile-up promotes everyone behind it. The check against Chapter 17's start.sample_lap1:
Lap-1 fates matrix, ground-effect era: 69 usable races x 20 slots
slot | P(lead) vectorised / start.sample_lap1 | P(retire) | mean gain
1 | 0.753 / 0.756 | 0.000 / 0.000 | -0.40 / -0.39
2 | 0.218 / 0.211 | 0.000 / 0.000 | -0.32 / -0.42
3 | 0.000 / 0.000 | 0.015 / 0.021 | -0.24 / -0.24
10 | 0.000 / 0.000 | 0.029 / 0.036 | -0.36 / -0.25
20 | 0.000 / 0.000 | 0.028 / 0.033 | +1.52 / +1.58
P(>= 1 lap-1 retirement in a 20-car start): 0.199
The two agree within the sampling error of 2,000 draws. Gaps after lap 1 are drawn per place from a gamma distribution with mean 0.65 s. That figure comes from Chapter 17: the leader-to-P20 spread after lap 1 is 12.36 s across 19 gaps.
Reliability. A car with race-retirement probability $p$ retires on any lap after the first with constant hazard
$$h = \frac{-\ln(1-p)}{N-1}.$$
The hazard is chosen so that the chance of surviving all $N-1$ laps is exactly $1-p$. With the 2026 rate of 18.3% of starters (83 of 453, Jolpica, after 21 rounds) and $N = 62$, $h = 0.0033$ per lap. The engine uses team rates from the season's earlier rounds, shrunk towards the field rate with 10 starts of prior weight. Aston Martin's 2026 rate is far above Mercedes'. Lap-1 retirements come from the lap-1 model, so we subtract its per-starter rate (about 1.5%) from $p$ to avoid counting them twice.
Neutralised laps. Every car laps at the race's base lap × 1.43 under an SC and × 1.16 under a VSC. Both factors are medians over 2023–26 races, measured in script 01. Under a VSC the gaps are frozen; Chapter 14 measured a gap ratio of 1.06 across a VSC. Under an SC each gap $g$ above a floor of 0.44 s shrinks to $0.44 + 0.61(g - 0.44)$ per lap. That reproduces Chapter 14's measured compression: the leader-to-P10 spread falls from 27.9 s to 4.0 s across a median four-lap safety car ($0.61^4 \approx 0.14$; $4.0/9 = 0.44$ s per place). A red flag compresses the field the same way and allows a free tyre change.
Traffic and overtaking
On green laps the engine processes cars in road order. Two rules do the work.
- Dirty air. A car that starts the lap within 1 s of the car ahead loses 0.44 s. That is Chapter 20's "wake" estimate: the cost of following when the car ahead is not slower.
- Catching and passing. If a car's free-air lap would bring it to the line less than 0.3 s behind the car ahead, it attempts a pass. The pass succeeds with probability
$$P(\text{pass}) = \frac{1}{1 + e^{-(\Delta - \theta)/0.25}},$$
where $\Delta$ is its pace advantage that lap (s) and $\theta$ is the advantage that gives a 50% chance. A car that fails is held 0.3 s behind, and a car can pass at most one car per lap.
🧪 Illustrative model: the logistic form, its width (0.25 s) and the 0.3 s minimum gap are assumptions, not measurements. The data do pin down one thing: how many green-flag on-track passes a circuit produces per race (the book's filtered OpenF1 count, Chapter 35).
calibrate_passingsets $\theta$ by bisection so that the simulated race reproduces that count: 29.5 per race at Singapore (2023–26 mean). Matching the count does not validate the shape: who passes whom, and how much faster they must be. Section 27.6 shows that the conclusions at Singapore depend on it.
Decisions: a Bellman table instead of re-planning
The hardest part of a race simulator is the strategist inside it. When a safety car comes out on lap 20, every car must decide whether to pit, and what to fit, given its tyres, its stops so far and the rest of the race. Chapter 14 and the book's Anchor C answer with a one-step look-ahead. On every neutralised lap the car compares two options: pit now at the SC/VSC price, then follow the best green-race plan; or stay out, then follow the best green-race plan. "Best green-race plan" assumes no further incidents.
montecarlo.py solves the same problem once per race by dynamic programming, then looks the answers up. Let $V_L(c, a, j, s)$ be the cheapest tyre-plus-pit cost of laps $L$ to $N$ for a car starting lap $L$ on compound $c$ at age $a$. Here $j$ records how many stops it must still make and may still make, and $s$ records whether it has used two dry compounds yet. Then
$$ V_L(c,a,j,s) = o_c + d_c a + \min\Big\{\underbrace{V_{L+1}(c, a+1, j, s)}_{\text{stay out}},\ \ P_{\text{green}} + \underbrace{\min_{c'}\big[w_{c'} + V_{L+1}(c', 0, j', s')\big]}_{\text{pit at the end of lap }L}\Big\} $$
The table is filled backwards from $V_{N+1} = 0$ (if the rules are satisfied; otherwise $\infty$). Laps past a compound's stint cap get infinite cost. In words: the best you can do from here is this lap's cost, plus the better of staying out or stopping, each followed by the best you can do from there.
The engine stores the two branches, STAY and GO, for every state. On any lap, a car pits if
$$\text{price}(\text{status}) + \text{GO}_L < \text{STAY}_L,$$
where the price is the green, SC or VSC stop loss of the decision model, or 0 under a red flag. On green laps this reproduces the clean-race optimum. On neutralised laps it is exactly the one-step look-ahead. A simulated car therefore decides by a table lookup instead of a fresh optimisation, which is why 10,000 races of 22 cars take seconds.
# project/boxbox/montecarlo.py (decision_table, inner loop): fill the table backwards from the flag
for L in range(N, 0, -1):
Vn = V[L + 1]
stay = np.full((3, A, J, 2), INF)
stay[:, :-1] = Vn[:, 1:] # stay out: same set, one lap older
... # go[c, j, s] = min over c2 of warm[c2] + Vn[c2, 0, j', s']
cont = np.minimum(stay, loss_g + go[:, None, :, :])
V[L] = lapcost[:, :, None, None] + cont # this lap's tyre cost + the better continuation
STAY[L], GO[L], GO_C[L] = stay, go, goc
# inside the race loop: every car, every lap, one lookup
stay = T["STAY"][L][comp, a_c, j, sat]
go = T["GO"][L][comp, j, sat]
price = loss_model[k][:, None] # green / SC / VSC / red price of a stop on this lap
pit = alive & (price + go < stay)
🔍 Why this works. The one-step look-ahead and the Bellman table give identical decisions because a clean-race plan is time-consistent. If stopping on lap 36 is optimal from the start, it is still optimal when you reach lap 20 and nothing has happened. That is Bellman's principle of optimality, and the deterministic green race satisfies it. Re-planning from scratch at every neutralisation therefore finds the same answer as reading the precomputed table at that state. The table is built once, from the point estimates. The simulated cars decide with the model they were given, and the simulated race scores them with the "true" tyres drawn for that race. That separation is deliberate: it is decision-making under model uncertainty, which is what a pit wall does.
🔄 Check your understanding. (1) Why does the engine draw each stop's loss from a pool of real stops, rather than using the median? (2) Why must the decision table be built from the point estimates and not from each race's drawn "true" tyres?
Answer
(1) The pool's mean (24.99 s at Singapore 2025–26) is above its median (23.87 s), and its spread is real: slow stops happen. A strategy that makes more stops is exposed to more draws from the slow tail. Using the median would flatter it.
(2) The strategist does not know the true tyres; they know their model. If the decision table used each race's true values, the simulated car would be making decisions with information no team has, and every strategy would look better than it is. Building the table from the point estimates and scoring with the draws measures what the decision rule is worth when the model is wrong in the ways it really is wrong.
27.3 One Race, Then Ten Thousand
Before we trust averages over 10,000 races, look at one. Script 04_singapore_field.py builds the 2026 Singapore field as it lined up: the grid, each car's starting compound and tyre age, and its measured 2026 race pace (pace.race_pace_table, data-driven fuel correction, traffic laps excluded). It uses the Singapore tyre model of Section 27.4 and the 2026 team retirement rates before round 17. Then it races once, with seed 2026.
One simulated race (seed 2026): incidents 2, statuses on laps [9, 10, 15, 16]
car pos stops first finished
LEC 1.0 2 15 True
VER 2.0 2 15 True
ANT 3.0 2 15 True
HAM 4.0 2 15 True
NOR 5.0 2 15 True
PIA 6.0 2 15 True

📊 Figure (described): The gap to the simulated leader at each line crossing for the top eight finishers of one simulated race. A VSC on laps 9–10 changes nothing. A safety car on laps 15–16 pulls everyone in for a cheap stop and compresses the field: the jagged step at lap 15 is the pit cycle, followed by the queue behind the safety car. A second round of green stops follows in the 30s, and then the race settles. This simulated race is not a replay of the real 2026 race. It is one draw of what the race could have been.
In this draw a VSC on laps 9–10 came too early to tempt anyone. A safety car on laps 15–16 then brought the whole leading group in for a stop at roughly 60% of the green price. A stop that early leaves 46 laps to run, more than a MEDIUM's 43-lap stint cap at Singapore, so every car in the top ten needed a second stop later. Leclerc won it. Change the seed and Verstappen wins, or Hamilton does, or a retirement reshapes everything. The whole point of a Monte Carlo is that this one race means nothing on its own.
The engine is vectorised over races: each lap is computed for all simulated races at once, as NumPy arrays of shape (races, cars). Traffic needs one pass through the running order per lap. On the machine that produced this book's runs, 10,000 simulated 22-car Grands Prix take about nine seconds. Ghost-mode runs (Section 27.4) take a third of a second per 10,000.
📺 On the broadcast: when a commentator says "the strategists will have run thousands of simulations of this race", this is what they mean. Every one of those runs looks like Figure 27.7: a plausible race with its own safety cars, its own lap-1 order and its own retirements. What reaches the pit wall is not one race. It is the summary of thousands, such as "with a safety car before lap 30, a stop now gains us a place 62% of the time." The commentator sees the decision; the distribution behind it stays on the strategist's screen.
🔄 Check your understanding. In the one simulated race of Figure 27.7, every car in the top ten stopped twice. Does that mean the engine "prefers" two-stops at Singapore?
Answer
No. That draw had a safety car on laps 15–16, which made a very early stop cheap. A stop after lap 15 leaves 46 laps, more than the MEDIUM's 43-lap cap, so a second stop became compulsory in practice. One draw shows how the engine reacts to one sequence of events. The preference only appears in the distribution: across 10,000 races, rivals on the flexible policy averaged 1.07 stops.
27.4 Anchor C in Full: The Singapore One-Stop vs Two-Stop
Now the question that has followed us since Chapter 14. Singapore has a reputation as a safety-car circuit, and a safety car makes a stop cheap. Does that make a planned two-stop better than a one-stop at Singapore?
The inputs
code/02_anchor_c_singapore.py measures every input exactly as Chapter 14 and the book's Anchor C did.
Singapore FE tyre model: 4,127 clean laps (stint lap >= 2), four races 2023-26
SOFT deg 0.0324 s/lap (SE 0.0176) offset vs MEDIUM -0.093 s (SE 0.265) cap 37 laps
MEDIUM deg 0.0417 s/lap (SE 0.0073) offset vs MEDIUM +0.000 s (SE 0.000) cap 43 laps
HARD deg 0.0521 s/lap (SE 0.0058) offset vs MEDIUM +0.229 s (SE 0.170) cap 47 laps
lap-number slopes (fuel + track evolution, s/lap): {'2023': -0.0553, '2024': -0.0453, '2025': -0.0506, '2026': -0.0418}
fuel convention: none needed: FE model with a year-specific lap-number term (fuel + evolution)
Green stop pool 2025-26 (80 km/h pit lane): n = 40, median 23.866 s; 2023-24 median 29.658 s (n = 27)
SC ratio pool n = 220, median 0.639, mean 0.688; VSC n = 181, median 0.751, mean 0.857
Hazard: book phase hazards x k = 1.33: {'lap 1': 0.2338, 'laps 2-10': 0.0411, 'middle': 0.0247, 'final 10': 0.0198} -> P(>= 1 incident in 62 laps) = 0.84
The tyre model is a fixed-effects regression on clean laps from the four 2023–26 Singapore races. It includes driver-race effects and a year-specific lap-number slope, and that slope absorbs fuel burn and track evolution together. So no fuel-correction assumption enters these degradation numbers. They are wear rates net of a common lap trend, which is the same for every strategy and cancels.
The hazard multiplier $k = 1.33$ (95% CI 0.89–1.91) pools 2023–26 race control with the 2008–2022 lap-time detector. It implies an 84% chance of at least one SC, VSC or red flag in a 62-lap Singapore race. The green stop pool is the 40 canonical stops of 2025–26, after the pit-lane speed limit rose from 60 to 80 km/h.
The clean race
Clean race one : start SOFT, stops [(36, 'MEDIUM')], tyre + pit cost 54.47 s
Clean race two : start SOFT, stops [(23, 'SOFT'), (46, 'MEDIUM')], tyre + pit cost 64.85 s
Clean race flex: start SOFT, stops [(36, 'MEDIUM')], tyre + pit cost 54.47 s
Clean race: two-stop minus one-stop = +10.38 s
The Bellman table finds the same plans as the book's Anchor C. The one-stop is SOFT to MEDIUM after lap 36, and the two-stop is SOFT–SOFT–MEDIUM after laps 23 and 46. The one-stop is faster by 10.38 s. (In this linear model the order of stints does not change their cost, so MEDIUM-first plans tie exactly. The engine breaks ties in SOFT–MEDIUM–HARD order to match the book's convention.)
The arithmetic of Chapter 12 explains the gap. The critical degradation at which a second stop pays for itself is $d^* = 2(k+1)(k+2)P/N^2$, with $k = 1$ here. With $P = 23.866$ s and $N = 62$ that is $2 \cdot 2 \cdot 3 \cdot 23.866 / 62^2 = 0.0745$ s/lap. Singapore's wear rates are 0.032 to 0.052 s/lap, roughly half the critical value. A second stop buys shorter stints, but at this wear rate shorter stints are not worth a pit stop.
Ghost mode, and why two careful simulations disagreed
The book's Anchor C races one car against the clock. There is no traffic, no track position, no gap compression and no retirement: three identical cars, one per strategy, each in an empty world. The engine reproduces that with ghost_setup. It switches off traffic, lap-1 shuffles, compression, noise and retirements, and makes the three cars share every random draw. In each simulated race the difference between two ghosts is exactly what the strategy choice was worth in that race.
Now we can reconcile Chapter 14 with the book. Chapter 14's simulation differs from the book's in three ways. We switch them on one at a time and run 10,000 races at each step, with the same seed:
Ghost mode, 10,000 simulated Singapore GPs each (seed 42), k = 1.33. Negative = faster than the one-stop.
run E_two P_two_better E_flex P_flex_better P_flex_equal P_flex_worse
A Ch 14 simplified (fixed ratios, point-estimate tyres) +9.53 (+9.35 to +9.69) 8.9% -0.92 (-0.99 to -0.85) 16.4% 78.7% 4.9%
B + stop ratios drawn per stop +10.16 (+9.92 to +10.41) 16.9% -0.81 (-0.91 to -0.71) 16.2% 78.7% 5.1%
C + tyres drawn per race [main, current data] +10.10 (+9.83 to +10.35) 18.9% -0.84 (-0.97 to -0.72) 15.5% 78.7% 5.8%
D C with the snapshot incident library [the book's Anchor C] +10.33 (+10.08 to +10.59) 18.0% -0.49 (-0.60 to -0.37) 12.0% 82.2% 5.8%
(Columns trimmed for width; the full table, with medians and the flexible car's two-stop share, is in code/02_output.txt.)

📊 Figure (described): Left: the mean time cost of the two-stop at each step of the reconciliation, with the book's earlier Anchor C (+10.36 s) dotted. It barely moves: 9.5 s, 10.2 s, 10.1 s, 10.3 s. Right: the probability that the two-stop (blue) or the flexible one-stop (orange) beats the plain one-stop. The two-stop's win probability almost doubles from step A to step B, while the flexible strategy's falls between C and D. Modelling choices move the probabilities a lot and the mean a little. None of them changes the verdict.
Read the ladder step by step.
- Step A reproduces Chapter 14: +9.53 s and 8.9%, against Chapter 14's own +9.44 s and 10.7%. The small differences are Monte Carlo noise and the order of random draws.
- Step B makes each neutralised stop draw its SC/VSC ratio from the measured distribution instead of using the median. The mean cost rises by about 0.6 s and the two-stop's win probability almost doubles, from 8.9% to 16.9%. Both effects come from the shape of the ratio distribution. Its mean (0.688 for an SC) is above the decision model's planning ratio (0.632), so on average a neutralised stop costs more than the decision model expected: the extra 0.6 s. Its spread is wide (IQR 0.41–1.00), so sometimes a stop under a safety car is nearly free. A strategy that makes more neutralised stops buys more of those lottery tickets: the doubled win rate.
- Step C scores each race with "true" tyres drawn from the regression's sampling distribution. The decisions are still made with the point estimates. The mean hardly moves, as it should: random errors with mean zero cancel on average. The spread widens, though, and the two-stop's win share rises to 18.9%. When the true SOFT wears faster than the model thinks, the plan with two SOFT stints suffers more, and occasionally the reverse. Step C is the main result of this chapter on current data.
- Step D swaps the incident library for the one the book's data snapshot used, before the 2026
RED FLAG - RACE SUSPENDEDwording was read. In that library three 2026 red flags were classed as safety cars and the Dutch lap-2 stoppage was missing. The result, +10.33 s and 18.0%, reproduces the mean of the book's earlier Anchor C (+10.36 s, faster in 16.8%) to within Monte Carlo error; the win share is about a point higher because the stop-loss pools have since been rebuilt. The flexible strategy's gain falls from 0.84 s to 0.49 s, against the earlier 0.46 s. Red flags matter to the flexible strategy because a stop during a red flag is free. With four more red flags in the library, the option of an extra stop is worth more.
So the answer to Aisha's question: neither number was wrong. Chapter 14 deliberately simplified (fixed ratios, no parameter uncertainty), which understates how often the two-stop gets lucky. The book's earlier Anchor C used the full uncertainty model on a library that predates the red-flag fix. With today's data the fullest version says: +10.1 s on average, and the two-stop faster in 19% of races. That is the book's headline answer to the Singapore question.

📊 Figure (described): Two cumulative distributions over 10,000 simulated races. The two-stop curve (solid) crosses zero at 19%: in about one race in five the two-stop is faster. Its median is +10.2 s, close to the clean-race +10.4 s (dotted), and its tail reaches past +30 s. The flexible curve (dashed) jumps from about 16% to 94% at zero. In most races the flexible car never uses its option and finishes level with the one-stop. When it does use it, it gains.
Mean, median, probability: three answers to "which is better?"
Percentiles of two - one (s), main run: {5: -10.6, 25: 2.9, 50: 10.2, 75: 16.7, 95: 32.4}
Percentiles of flex - one (s), main run: {5: -11.04, 25: 0.0, 50: 0.0, 75: 0.0, 95: 1.3}
When the two-stop wins it wins by 8.09 s on average; when it loses it loses by 14.41 s
For the two-stop, all three summaries agree. The mean (+10.1 s), the median (+10.2 s) and the probability (19% better) all say "worse". When the two-stop wins it wins by 8.1 s on average; when it loses, it loses by 14.4 s.
For the flexible strategy the summaries diverge in an instructive way. Its median difference is exactly zero, because in 78.7% of races it never uses its option and runs the same race as the one-stop. Its mean is −0.84 s. It is better in 15.5% of races and worse in 5.8%. The worse cases are races where the decision model, planning with point estimates, took an extra stop that the true tyres did not reward. A strategist who looks only at medians will say "no difference". One who looks at means will say "a small gain". One who looks at the probabilities will see a free option that pays roughly three times as often as it costs. The common advice to choose "the strategy that produces the best median result" would miss this entirely: when one option is a zero-cost add-on to another, the median ties and the mean and probabilities separate them.
⚠️ Common pitfall: optimising the median of a mixture. A strategy that is identical to another in most races and different in a few has a median difference of zero, whatever happens in those few races. Medians are robust to outliers, which is exactly the problem when the outliers are the decision. Report the mean, the median, P(better), P(worse) and a few percentiles, as the tables in this section do.
Where in the race does a neutralisation help?
Main run by what happened in the race:
races share E_two P_two_better E_flex P_flex_better
no incident 16.4% 11.56 0.4% 0.00 0.0%
exactly 1 incident 32.2% 10.34 17.8% -0.67 10.1%
2+ incidents 51.4% 9.48 25.5% -1.22 23.7%
>= 1 SC or red 63.3% 9.24 25.8% -1.33 24.4%
VSC only 20.3% 11.59 12.5% 0.00 0.1%
Races with exactly one incident, by its start lap:
first_incident_laps races E_two P_two_better E_flex
1-1 457 10.17 12.5% -0.33
2-10 672 9.80 19.2% -0.76
11-20 392 6.61 29.3% -0.79
21-30 416 12.47 19.7% -0.63
31-40 438 13.06 21.0% -0.63
41-50 422 6.91 23.2% -1.11
51-62 420 13.38 0.0% -0.42
Four facts stand out.
- With no incident (16.4% of races) the two-stop is 11.6 s worse, not the clean-race 10.4 s. The extra 1.2 s is the pool effect from Section 27.2: two green stops drawn from a pool whose mean (24.99 s) is above its median (23.87 s).
- VSC-only races barely help. The two-stop's expected deficit is 11.6 s and the flexible option is worth nothing. A VSC stop at Singapore costs 0.75 of a green stop at the median and 0.86 on average, so it is rarely a bargain.
- A safety car or red flag cuts the two-stop's deficit to 9.2 s and makes the flexible option worth 1.33 s.
- Timing matters more than count. A single incident on laps 11–20 or 41–50 helps the two-stop most: its expected deficit falls to 6.6–6.9 s and its win rate rises to 23–29%. Those windows sit around the two-stop's own planned stops (laps 23 and 46), so it can move a stop into the neutralisation, while the one-stop's planned stop on lap 36 is too far away. An incident on laps 31–40 is close to the one-stop's planned stop and helps the one-stop instead: the two-stop's deficit grows to 13.1 s. An incident in the last 12 laps is too late for anyone.
How much hazard would it take?

📊 Figure (described): Left: the expected cost of the two-stop (solid) and the expected gain of the flexible option (dashed) as the hazard multiplier rises from 0 (no neutralisations) to 3.99 (three times Singapore's estimate). The two-stop's deficit falls from 11.5 s to 8.8 s and never approaches zero. Right: the probability that each beats the one-stop. The two-stop's rises from 0.5% to 27.5%, and the flexible option's from 0% to 33.4%. More hazard makes the option more valuable without making the commitment right.
Hazard sensitivity (ghost mode, main settings):
k label sims p_any E_two P_two_better E_flex P_flex_better
0.000 0 5000 0% +11.47 (+11.31 to +11.63) 0.5% +0.00 (+0.00 to +0.00) 0.0%
0.740 0.74 (SG 2023-26 only) 5000 64% +10.43 (+10.15 to +10.73) 14.1% -0.47 (-0.58 to -0.36) 9.1%
1.000 1.0 (all circuits) 5000 75% +10.23 (+9.89 to +10.57) 16.0% -0.59 (-0.72 to -0.46) 11.7%
1.330 1.33 (main) 10000 84% +10.10 (+9.83 to +10.35) 18.9% -0.84 (-0.97 to -0.72) 15.5%
2.660 2k 5000 97% +9.31 (+8.93 to +9.72) 25.6% -1.23 (-1.47 to -1.01) 27.0%
3.990 3k 5000 100% +8.79 (+8.31 to +9.23) 27.5% -0.99 (-1.30 to -0.69) 33.4%
At three times Singapore's estimated hazard, a neutralisation is virtually certain, and the planned two-stop is still 8.8 s slower on average. This is the result the book's earlier Anchor C reported, and the engine confirms it on current data: no hazard level up to 3× Singapore's flips the mean. Even with the 2023–24 pit loss (29.66 s, 60 km/h pit lane), the two-stop is +16.6 s. The folklore's premise, a "~65% safety-car probability" that makes the two-stop the better expected result, fails twice. The measured probability of a neutralisation is higher (84%, counting SCs, VSCs and red flags), and even so the two-stop loses.
📋 Call the pit stop: 2026 Singapore, lap 39, VSC. You are on the pit wall. The virtual safety car has just been deployed. Four cars matter, and all have made one stop:
- VER leads on MEDIUMs, 6 laps old.
- LEC is second on MEDIUMs, 14 laps old.
- HAM is third on SOFTs, 23 laps old.
- ANT is fourth on MEDIUMs, 15 laps old.
23 laps remain. The model prices a VSC stop at 18.40 s. Which of the four should make a second stop?
What the decision table says, and what happened
text VER: MEDIUM age 6, 1 stop(s) done | model VSC price 18.40 s: stay 17.26, go 6.06 -> stay out (margin -7.19 s) LEC: MEDIUM age 14, 1 stop(s) done | model VSC price 18.40 s: stay 24.94, go 6.06 -> PIT (margin +0.48 s) HAM: SOFT age 23, 1 stop(s) done | model VSC price 18.40 s: stay 29.99, go 6.06 -> PIT (margin +5.53 s) ANT: MEDIUM age 15, 1 stop(s) done | model VSC price 18.40 s: stay 25.90, go 6.06 -> PIT (margin +1.44 s) LEC: MEDIUM age 14, 1 stop(s) done | LEC's measured VSC stop 12.48 s: stay 24.94, go 6.06 -> PIT (margin +6.40 s)"Stay" is the model's tyre cost for laps 40–62 on the current set; "go" is the cost on a new set, excluding the stop. In time terms the table says: VER stays out (a fresh set would save 11.2 s, much less than the 18.4 s stop); LEC pits, barely (+0.48 s); ANT pits (+1.44 s); HAM pits clearly (+5.53 s).
What happened: VER stayed out and won. LEC and ANT pitted and finished second and third. HAM stayed out on his 23-lap-old SOFTs and finished sixth, running 2.4 s per lap slower than LEC over the final 21 laps (Chapter 14). At the price LEC actually paid, 12.48 s, the margin for his stop grows to +6.4 s. The model is pure time, though, and a VSC stop also costs track position. Section 27.6 and Case Study 1 put that back in.
🔄 Check your understanding. In ghost mode the flexible strategy's median gain over the one-stop is exactly zero, yet its mean gain is 0.84 s. Explain both numbers in one sentence each, and say which you would report to a team principal.
Answer
The median is zero because in 78.7% of simulated races no neutralisation made an extra stop worthwhile, so the flexible car ran exactly the one-stop's race. The mean is −0.84 s because in the other 21% it gained (15.5% of races) far more often than it lost (5.8%). Report the mean together with P(better) and P(worse): they describe a cheap option that sometimes pays, and the median hides that.
27.5 How Many Runs? Convergence and Monte Carlo Error
Every number in Section 27.4 came from 10,000 simulated races. Is that enough? Too many? The answer comes from the standard error of a mean:
$$ \text{SE}(\bar x) = \frac{s}{\sqrt n}, \qquad \text{SE}(\hat p) = \sqrt{\frac{\hat p(1-\hat p)}{n}}, $$
where $s$ is the standard deviation of the per-race difference and $\hat p$ an estimated probability. For a 95% interval of half-width $h$, you need $n = (1.96\, s/h)^2$ runs. In words: halving the error costs four times the runs.
code/03_convergence.py tracks the running estimates from the main 10,000-race run.
E[two - one] (s): running estimate and Monte Carlo SE
n estimate se lo hi
10 3.158 3.919 -4.525 10.840
100 9.327 1.154 7.066 11.589
1000 9.963 0.432 9.116 10.810
10000 10.097 0.130 9.842 10.352
E[flex - one] (s): running estimate and Monte Carlo SE
n estimate se lo hi
10 -3.115 2.021 -7.075 0.845
100 -0.522 0.605 -1.707 0.664
1000 -0.531 0.227 -0.975 -0.087
10000 -0.843 0.064 -0.969 -0.718
P(two-stop faster): running estimate and SE
n estimate se lo hi
100 0.1900 0.0392 0.1131 0.2669
1000 0.2110 0.0129 0.1857 0.2363
10000 0.1892 0.0039 0.1815 0.1969
With 10 races the estimated two-stop cost is +3.2 s with a standard error of 3.9 s: useless. With 100 races, the 95% interval for the flexible option's gain still includes zero. By 1,000 the flexible option is distinguishably better than nothing, and by 10,000 its gain is pinned to ±0.13 s.

📊 Figure (described): Left: the running mean of the two-stop (blue) and flexible (orange) differences against the number of simulated races, on a log scale, with 95% Monte Carlo bands. Both wander widely for the first few hundred races and settle after a few thousand. Right: 40 independent runs of 1,000 races each. Their estimates of the flexible gain range from −1.26 to −0.49 s; every run gets the sign right, and none gets the size right to better than about ±0.4 s.
Does the formula match reality? Script 03 runs 40 independent batches of 1,000 races:
40 independent runs of 1,000 races:
E[two - one]: range +9.13 to +10.47 s, SD across runs 0.347 s; formula SD/sqrt(n) 0.407 s
P(two-stop faster): range 16.7% to 21.6%, SD 1.21 points; formula 1.25
E[flex - one]: range -1.26 to -0.49 s, SD 0.208; share of runs with E[flex - one] < 0: 1.00
The observed spread across runs (0.35 s) is a little narrower than the formula's 0.41 s, which is ordinary sampling variation for an SD estimated from 40 runs. So the formula does its job: it tells you, before you run, how wrong a run of a given size is likely to be.
The trick that makes comparisons cheap: common random numbers
Every comparison in this chapter races the strategies through the same simulated races: same incidents, same tyre draws, same stop-loss draws. This is called common random numbers (CRN). The payoff is enormous.
Flexible vs one-stop, 5,000 races:
paired (same races): mean -0.778 s, SE 0.084 s
independent races : mean -6.890 s, SE 3.314 s
variance reduction factor: 1572x fewer runs for the same precision
On independent races, the difference between two strategies is swamped by the difference between races. One run may have had three safety cars and the other none, which changes the race time by minutes. That independent comparison happens to come out at −6.9 s with a standard error of 3.3 s, a meaningless number. The paired comparison removes the race-to-race variation entirely. To match the paired precision with independent runs you would need about 1,500 times as many races.
⚠️ Common pitfall: comparing strategies on separate simulation runs. If you simulate strategy A with one seed and strategy B with another and subtract the means, almost all of the difference is noise from the different races. Always race every candidate strategy through the same random events.
run_manydoes this automatically: batch $b$ uses seedseed + b, and every random number is drawn before the race starts, in a fixed order that does not depend on the strategy. Even so, check that your candidates draw from the random stream identically: a strategy that consumes extra random numbers can de-synchronise the races.
How many runs, then?
Runs needed for a 95% interval of half-width h (paired differences):
two - one h = 1.00 s -> n = 651
two - one h = 0.25 s -> n = 10,406
flex - one h = 1.00 s -> n = 158
flex - one h = 0.25 s -> n = 2,515
flex - one h = 0.10 s -> n = 15,717
P(two faster) = 0.189, h = 1.0 points -> n = 5,894
The answer depends on the question.
- Is the two-stop worse? Its 10 s deficit is large against its per-race SD of 13.0 s, so a few hundred races settle the sign.
- How much is the flexible option worth, to the nearest quarter-second? That needs about 2,500 races.
- A probability to within one percentage point? About 6,000.
The customary "10,000 simulations" is a sensible default for Singapore-sized effects. For a decision that turns on a 0.1 s difference, you would need about 16,000 paired races. Even then you would know the model's answer to a tenth, and nothing about whether the model is right to a tenth.
🔄 Check your understanding. You simulate a strategy decision with 2,000 paired races and find E[A − B] = −0.30 s with a per-race SD of 6.2 s. Is A better? How many races would you need to be confident, at 95%, that the true model difference is within ±0.1 s?
Answer
SE = 6.2/√2000 = 0.139 s, so the 95% interval is −0.30 ± 0.27 s, about −0.57 to −0.03 s: A is better in the model, just. For ±0.1 s you need n = (1.96 × 6.2 / 0.1)² ≈ 14,800 races. That tells you the model's answer to a tenth. Whether the model's inputs are right to a tenth is a separate question, answered in Sections 27.7–27.8.
27.6 The Whole Field: When Seconds Become Positions
Ghost mode answers "which strategy is faster?" A race is won on position, not time. A car that stops under a safety car rejoins behind cars that did not stop, and it has to pass them again. A car that stops twice spends laps in traffic it did not plan for. The safety car shrinks the gaps for everyone. Lap 1 rearranges the grid. Cars break down. None of that exists in ghost mode.
So we put Anchor C into the 2026 Singapore field. Each car has its grid slot, its start tyres, its measured 2026 race pace and its team's 2026 retirement rate. Every rival follows the flexible policy (one or two stops, decided by the Bellman table). Passing is calibrated to Singapore's 29.5 green on-track passes per race, the 2023–26 mean:
2026 Singapore grid, measured race pace (data fuel, traffic excluded) and start tyres:
grid car team pace_gap_s start p_dnf
1 VER red_bull 0.000 SOFT age 0 0.174
2 LEC ferrari 0.016 SOFT age 3 0.126
3 HAM ferrari 0.633 MEDIUM age 0 0.126
4 ANT mercedes 0.109 SOFT age 3 0.126
5 NOR mclaren 0.494 SOFT age 0 0.137
6 PIA mclaren 0.379 SOFT age 0 0.137
...
10 HUL audi 1.321 MEDIUM age 0 0.109
Passing calibrated to Singapore's 29.5 green on-track passes per race (2023-26 mean): threshold 2.95 s/lap, simulated 29.5 passes per race
For three focal cars, Verstappen from pole, Antonelli from fourth and Hülkenberg from tenth, we race the same 10,000 races three times, changing only the focal car's policy:
car grid policy mean_pos median_pos p_win p_podium p_points exp_points d_time_vs_ref p_better_pos p_worse_pos mean_stops
VER 1 one-stop 4.803 1.0 0.517 0.768 0.825 17.839 0.000 0.000 0.000 0.907
VER 1 two-stop 6.755 4.0 0.150 0.456 0.774 11.714 26.449 0.040 0.576 1.845
VER 1 flexible 4.930 1.0 0.511 0.754 0.818 17.569 0.205 0.028 0.038 1.115
ANT 4 one-stop 5.230 3.0 0.098 0.581 0.872 13.394 0.000 0.000 0.000 0.934
ANT 4 two-stop 7.418 5.0 0.029 0.222 0.776 8.671 24.520 0.058 0.620 1.894
ANT 4 flexible 5.376 3.0 0.083 0.568 0.864 13.047 0.265 0.039 0.054 1.153
HUL 10 one-stop 9.914 8.0 0.001 0.012 0.716 3.721 0.000 0.000 0.000 0.928
HUL 10 two-stop 12.420 12.0 0.001 0.008 0.354 1.458 18.481 0.092 0.644 1.865
HUL 10 flexible 9.837 8.0 0.001 0.013 0.725 3.805 -0.884 0.046 0.021 1.097
(Mean positions include retirements, classified last; that is why the pole-sitter's mean is 4.8 while his median is 1. mean_stops below 1 reflects retirements before the first stop.)

📊 Figure (described): For each focal car, the share of 10,000 simulated races finishing in each position under each policy. For Verstappen the one-stop and flexible bars are nearly identical, about 51% wins, while the two-stop's win share collapses to 15% and its distribution spreads down the order. Antonelli's two-stop moves his mode from third to fifth. Hülkenberg's two-stop finishes behind his own one-stop in 64% of races and halves his chance of scoring (35.4% against 71.6%). The two-stop is worse at every grid slot.
What the field adds
The two-stop gets much worse. In ghost mode it lost 10 s. In the field it loses 26.4 s (Verstappen) and 24.5 s (Antonelli) in the races both versions finished. The extra 14–16 s is traffic. After each extra stop the car rejoins behind slower cars at a circuit where a pass needs a big pace advantage, and the dirty-air and held-up laps add up. In position terms, Verstappen's two-stop wins 15.0% of races against 51.7% for his one-stop, and it finishes ahead of his own one-stop in only 4% of them.
The flexible option changes sign at the front. In ghost mode the flexible option gained 0.84 s. In the field, for Verstappen and Antonelli, it loses a little: 0.13 and 0.15 places on average and about 0.3 expected points. It finishes behind its own one-stop slightly more often than ahead. For Hülkenberg in tenth, it still gains (0.08 places, 0.9 s).
Why would a strategy that is never slower in an empty world cost places in a full one? Because the Bellman table optimises time. When a safety car comes, the flexible car compares tyre time and pit cost only. It does not ask whether the stop will drop it behind a car it cannot pass. At the front, the cars that stay out are the car's direct rivals, and passing them back at Singapore is hard. In the midfield there is more to gain and more traffic to lose anyway.
How sure are we? The result depends on the one input the data pin down least: how hard it is to pass.
Value of the flexible option vs passing difficulty (3,000 races per row, seed 47; d_* = flexible minus one-stop; negative d_pos = better):
passing car passes_per_race d_pos_flex d_pts_flex d_time_flex P_flex_ahead P_flex_behind
calibrated (2.95 s/lap) VER 29.0 0.142 -0.319 0.538 0.025 0.039
calibrated (2.95 s/lap) ANT 29.0 0.159 -0.408 0.662 0.032 0.049
1.5 s/lap VER 67.1 -0.023 0.152 -0.402 0.055 0.029
1.5 s/lap ANT 67.1 -0.016 0.050 -0.474 0.062 0.037
0.5 s/lap VER 81.8 -0.075 0.305 -0.668 0.062 0.021
no traffic at all ANT 0.0 -0.173 0.501 -1.114 0.097 0.016

📊 Figure (described): Left: the flexible option's effect on expected finishing position (flexible minus one-stop) for Verstappen and Antonelli as passing gets easier, from the Singapore calibration (29 passes per race) to no traffic at all. It costs about 0.15 places at the calibrated setting and gains 0.15–0.17 places with no traffic. It crosses zero between the calibrated setting and a 1.5 s/lap threshold (about 67 passes per race). Right: the share of races in which the flexible car finishes ahead of (solid) or behind (dashed) its own one-stop. The two lines cross between the calibrated setting and the 1.5 s/lap setting.
Only at the calibrated setting does the option cost places. With a pass threshold of 1.5 s/lap, which roughly doubles the passes per race, the option is already worth something again. So the honest conclusion is conditional. The time value of the flexible option is robust (Section 27.4). Its position value at the front depends on whether a car on fresh tyres can pass a rival on old ones.
The calibration has a known weakness. The calibrated threshold (2.95 s/lap) means a car needs nearly 3 s per lap of advantage for a 50% chance. Most simulated passes happen when the car ahead has an error lap (the 5.5% of laps that are more than 1 s slow), not because one car is systematically faster. Reality is not that harsh. In the real 2026 Singapore race, Leclerc rejoined behind Hamilton after his lap-39 stop and was back ahead of him at the end of lap 46 (OpenF1 positions): a car on fresh SOFTs passed one on 23-lap-old SOFTs within six laps. Matching a pass count is not the same as matching who passes whom. Chapter 35 measures pass probabilities against pace and tyre deltas directly; until then, treat the field-mode verdict on the option as "close to neutral at the front, positive in the midfield, and dependent on the pass model".
🧪 Illustrative model: the field-mode results in this section rest on a pass probability whose shape (logistic in pace advantage, width 0.25 s) is assumed and whose threshold is calibrated only to a pass count. The ghost-mode results of Section 27.4 do not depend on it.
📺 On the broadcast: "Track position is king at Singapore" is one of the oldest lines in the commentary box. The field-mode engine shows what it means in numbers: the same strategy that gains 0.8 s against the clock can cost a tenth of a place or more against rivals, because the time is gained behind cars you cannot pass. When a commentator says a team "didn't want to give up track position" under a safety car, this trade-off is the calculation behind it.
The hazard sweep in field mode tells the same story from another angle. As the hazard multiplier rises from 0 to 3.99, Antonelli's one-stop expected position barely moves (5.18 → 5.21). His flexible option's share of races finishing behind his own one-stop rises from 0% to 18.3%, and the share finishing ahead only to 8.3%. More safety cars give the time-greedy option more chances to give up track position.
🔄 Check your understanding. In ghost mode the flexible strategy can never be slower than the one-stop unless the true tyres differ from the model. In field mode it is finishing behind its own one-stop in 3.8% of Verstappen's races. Name two mechanisms in the field model that make this possible.
Answer
(1) Track position. The extra stop under a safety car drops the car behind rivals who stayed out, and at Singapore's passing rate it often cannot get back past them, even on fresher tyres. (2) Traffic cost. Rejoining in a queue means dirty-air laps (0.44 s each) and being held up, which the time-only decision table does not price. A third, smaller one: the stop draws a loss from the measured distribution, and an expensive draw (a slow stop) can turn the expected gain into a loss.
27.7 What Moves the Answer? A Sensitivity Tornado
A simulator's output is only as good as its least certain input. The quickest way to find that input is a one-at-a-time sensitivity, or "tornado": change each input to a plausible low and high value and see how far the answer moves. code/05_sensitivity.py does this in ghost mode, with 5,000 races per point.
Main settings (5,000 races, seed 46): E[two - one] +10.00 s, P(two faster) 18.7%, E[flex - one] -0.90 s
One-at-a-time sensitivity (low / high value of each input):
input E_two_low E_two_high P_two_low P_two_high E_flex_low E_flex_high swing
Degradation x0.5 / x1.5 (all compounds) 14.883 4.535 0.123 0.303 -0.693 -0.367 10.348
Green stop loss: 2025-26 pool - 4 s / 2023-24 pool (60 km/h) 6.603 16.580 0.226 0.163 -0.579 -1.079 9.977
Incident mix: every incident a VSC / every incident an SC 12.078 9.674 0.095 0.191 0.081 -0.897 2.404
SC/VSC stop ratio: near-field (x0.87) / x1.27 9.642 10.644 0.193 0.166 -0.714 -0.987 1.002
Hazard k: 0.74 (2023-26 only) / 2.66 (2x) 10.457 9.482 0.127 0.253 -0.506 -1.010 0.976
Tyre uncertainty in scoring: off / on (main) 10.035 10.002 0.171 0.187 -0.892 -0.900 0.033
degradation x2.0: E[two - one] -1.17 s, P(two faster) 57.9%
degradation x2.5: E[two - one] -6.62 s, P(two faster) 77.5%

📊 Figure (described): Each row moves one input between a low (circle) and a high (square) value and plots the expected two-stop deficit, with the main setting dotted at +10.0 s. Degradation (×0.5 to ×1.5: +14.9 to +4.5 s) and the green pit loss (−4 s to the 60 km/h pit lane: +6.6 to +16.6 s) dominate. The incident mix, the SC/VSC ratio and the hazard level move the answer by about 1–2.5 s. Tyre uncertainty in the scoring barely moves the mean. No plausible single change crosses zero.
The hazard, the input the folklore cares about, ranks fifth, just behind the SC/VSC stop ratio. Degradation and pit loss decide the question, and that is no coincidence: they are the two terms of Chapter 12's critical-degradation formula. Doubling Singapore's degradation (to about 0.065–0.105 s/lap) flips the mean: the two-stop becomes 1.2 s faster and wins 58% of races. That is exactly where the formula said the line was ($d^* = 0.0745$ s/lap against a mean wear near 0.042). A Monte Carlo of the whole race and a two-line formula agree on where the boundary lies, which is reassuring about both.
One row deserves a second look. If every incident were a VSC, the flexible option would be worth less than nothing (+0.08 s). The reason is that the decision model plans with Chapter 14's median VSC ratio, 0.771, while the true VSC ratios average 0.857. The model expects a VSC stop to be a modest bargain; on average it is barely one; and the stops it triggers lose a little. This is a general lesson. A decision rule built on the median of a skewed cost distribution will systematically overpay. The fix is to decide with the expected cost, or better, to decide with the whole distribution.
🧪 Illustrative model: the low and high values in the tornado are chosen to be plausible, not drawn from measured uncertainty. Degradation ×0.5/×1.5 spans roughly the circuit-to-circuit range of the book's MEDIUM and HARD medians. The pit-loss range spans Singapore's own 2023–24 and 2025–26 regimes. Read the tornado as "which inputs matter", not as a confidence interval.
🔄 Check your understanding. A colleague wants to improve the Singapore answer by collecting another ten years of safety-car history. Using the tornado, explain whether that is the best use of their time, and what would be better.
Answer
Probably not. Halving the hazard uncertainty (k from 0.74 to 2.66 already spans more than its 95% CI) moves the two-stop's deficit by about 1.0 s, and nothing in that range flips the answer. Degradation and pit loss each move it by about 10 s. Better: tighter degradation estimates for the current tyres at this circuit (practice long runs, early-stint race data, Chapter 22) and the current pit-lane time (the 2025 limit change alone moved the answer by 6.5 s).
27.8 Validation: The 2026 United States Grand Prix from Its Grid
Everything so far has been internal: the engine against itself, or against the book's earlier versions of the same model. Now the real test. Can it predict a race it has not seen?
We take the 2026 United States Grand Prix (round 18, Austin, 56 laps, dry) and build the simulation from information available on Sunday morning. Pole-sitter Antonelli won it; Leclerc (from 4th) and Verstappen (from 2nd) completed the podium. code/06_validation_usgp.py (with _common.race_setup) assembles every input from data before the race.
- Pace. Each driver's best qualifying lap, as a gap in percent to pole, converted to a race-pace gap with the season's own relationship. Over the dry 2026 races before round 18 it is $\text{race gap\%} = 0.966 \times \text{quali gap\%}$, with a residual SD of 0.537% of a lap (264 driver-races, 14 races). That residual becomes each car's pace uncertainty: every simulated race draws a fresh error of SD 0.53 s/lap for every car. The model admits it does not know race pace exactly.
- Tyres. Chapter 22's
DegModel, fitted on all earlier dry races, predicts Austin at SOFT 0.057, MEDIUM 0.044 and HARD 0.042 s/lap. These are fuel-corrected at the toolkit default (100 kg, 0.03 s/kg ASSUMPTION), so the engine pairs them with a fuel term of −3.0/56 s per lap. Offsets and warm-up come from Chapter 12's pooled values. - Stops, hazard, reliability, passing. The green stop pool is Austin's 78 stops from 2023–25 (median 21.124 s). The hazard multiplier, $k = 0.69$, comes from Austin's other races, so $P(\geq 1$ incident$) = 0.58$. Retirement rates are each team's rate over rounds 1–17, shrunk towards the field's 19.3%. Passing is calibrated to Austin's 2023–25 mean of green passes times the 2026 increase: $34.7 \times 1.49 = 51.6$ per race, which needs a threshold of 1.78 s/lap.
- Start tyres. Each car's starting compound and tyre age as it lined up on the grid.
clean-race plan, best one-stop: start MEDIUM, stops [(27, 'HARD')], cost 52.85 s
clean-race plan, best two-stop: start SOFT, stops [(16, 'HARD'), (36, 'HARD')], cost 61.71 s
Actual race: neutralised laps [2, 51, 52] (VSC); winner ANT; stops by finishers: {1: 10, 2: 9}
Simulated: mean incidents 0.82, P(>= 1) 0.58; mean stops per finisher 1.15; share of finishers with 2+ stops 0.10; green passes 52.5
We run 10,000 races. Here is the result against the outcome for the top of the order:
grid actual p_win p_podium p_points median_pos p10 p90 p_dnf p_win_hind p_podium_hind grid_p_win grid_p_podium pit
ANT 1 1.0 0.360 0.642 0.875 2.0 1.0 18.0 0.119 0.218 0.577 0.536 0.810 0.180
LEC 4 2.0 0.144 0.458 0.875 4.0 1.0 18.0 0.118 0.354 0.798 0.040 0.341 0.224
VER 2 3.0 0.182 0.490 0.826 4.0 1.0 20.0 0.167 0.340 0.751 0.235 0.721 0.420
HAM 5 4.0 0.077 0.329 0.849 5.0 2.0 19.0 0.133 0.072 0.562 0.016 0.167 0.396
NOR 8 5.0 0.024 0.163 0.793 7.0 3.0 19.0 0.140 0.009 0.129 0.004 0.028 0.315
HAD 3 6.0 0.124 0.415 0.812 4.0 1.0 20.0 0.180 0.005 0.147 0.107 0.552 0.669
PIA 7 7.0 0.013 0.108 0.762 7.0 3.0 19.0 0.140 0.000 0.012 0.004 0.068 0.454
RUS 6 8.0 0.070 0.307 0.855 5.0 2.0 17.0 0.117 0.001 0.019 0.028 0.135 0.769

📊 Figure (described): Each row is a driver, in the order of the actual result, and each column a finishing position. The shading is the share of 10,000 pre-race simulations finishing there; red circles mark the actual result. The circles sit inside the shaded mass for almost every driver. The diagonal band shows that the simulation, like the result, mostly follows the grid with a spread of a few places. Colapinto and Bearman (bottom rows) retired, outcomes the simulation gave only a 15% and 14% chance.
Scoring the forecast
A probability forecast is judged by proper scoring rules, which reward honest probabilities.
📐 Definition: Brier score and PIT. For a yes/no event with forecast probability $p$ and outcome $y \in \{0,1\}$, the Brier score is $(p-y)^2$, averaged over events; lower is better, and always forecasting 0.5 scores 0.25. For a full position distribution, the probability integral transform (PIT) of an outcome is the forecast probability of finishing ahead of the actual position, plus half the probability of finishing exactly there. If the forecasts are calibrated, PIT values across drivers and races are uniform between 0 and 1.
Brier scores over the 22 starters (lower is better):
win simulation 0.0223 hindsight 0.0390 grid base rate 0.0130
podium simulation 0.0499 hindsight 0.0290 grid base rate 0.0413
top 10 simulation 0.0590 grid base rate 0.0636
Log score of the winner: simulation 1.022, grid base rate 0.624
Mean ranked probability score over drivers: 0.0707
Coverage of the 10-90 % position interval: 20 of 22 drivers (expected about 18)
PIT values: mean 0.551 (0.5 = unbiased), share below 0.1 0.00, above 0.9 0.09
What the simulation got right:
- The podium. The three drivers with the highest simulated P(podium) were Antonelli (0.642), Verstappen (0.490) and Leclerc (0.458), exactly the actual podium.
- The order. Twenty of 22 drivers finished inside their simulated 10–90% interval. A calibrated forecast would have about 18 inside it, so if anything the intervals are a little wide.
- The top ten. For top-10 finishes, the simulation beat the grid-slot base rate (Brier 0.059 against 0.064).
What it got wrong:
- The winner. The simulation gave Antonelli a 36.0% chance from pole, against the 53.6% that pole-sitters have won with since 2014. On this race, with a pole-sitter who won, the simple base rate scored better (Brier 0.013 against 0.023).
- The stops. The simulation expected only 10% of finishers to stop twice; in fact 9 of 19 did. The pre-race
DegModelpredicted Austin's wear at 0.04–0.06 s/lap. The race itself showed 0.081 (SOFT and MEDIUM) and 0.057 (HARD), fuel-corrected at the same default, from the book's per-race table. Chapter 12 found that with the race's own (hindsight) wear, the two-stop at Austin was only 3.2 s behind the one-stop. The pre-race model put it 8.9 s behind. As in Chapters 12 and 22, the misses predict too few stops.
The hindsight run uses each driver's actual race pace from this very race, with no pace uncertainty. It sharpens the podium forecast (Brier 0.029 against 0.050) but worsens the winner forecast (0.039). Measured race pace says Leclerc and Verstappen were faster than Antonelli on the day. Antonelli won anyway, from pole, on a track where passing is not free. Even perfect knowledge of pace does not tell you the winner. Position, the start and the 1-in-3 chance of a neutralisation are part of the result.

📊 Figure (described): Left: P(podium) for the ten likeliest podium finishers under three forecasts: the pre-race simulation (blue), the simulation with hindsight race pace (orange) and the grid-slot base rate (grey). The actual podium is marked in red. All three put the right three names near the top; the grid base rate is the most confident about Antonelli and the least about Leclerc. Right: the PIT histogram for the 22 drivers. It is roughly flat, with no drivers below 0.1 and two above 0.9 (the two retirements the simulation thought unlikely).
One race is a single draw. Is the engine calibrated on average? Case Study 2 repeats this procedure for all 15 dry 2026 races from round 3 onwards, 329 driver-races. The headline: the simulation beats the grid base rate on Brier score and log loss for wins, podiums and top tens, but it is consistently under-confident about pole-sitters. Its mean P(win) for the pole-sitter is 0.39, while pole-sitters won 10 of those 15 races. The likely culprit is the 0.53 s/lap pace uncertainty, which is estimated across the whole field and is too wide for the front of the grid.
🔄 Check your understanding. The validation's grid-slot base rate scored better than the simulation on the winner (Brier 0.013 against 0.023) but worse on top-10 finishes. Is that a contradiction?
Answer
No. On this race the pole-sitter won, and a forecast that says "pole wins 54% of the time" is rewarded for its confidence. The simulation spread its win probability over Antonelli, Verstappen, Leclerc and Hadjar because its 0.53 s/lap pace uncertainty is wide. Lower down the order, where qualifying and race pace differ more and retirements matter, the simulation's car-specific inputs beat the grid base rate. One race cannot separate skill from luck; Case Study 2 looks at 15.
📋 Predict the race. Take the 2026 Las Vegas Grand Prix (round 21), which Box Box's checkpoint simulates from its grid (see the Project Checkpoint below). Before you look at the result: which three drivers does the simulation make likeliest to finish on the podium, and does it give the pole-sitter more or less than the 2014–25 pole win rate (53.6%)? Then check the actual top five against the simulated P(podium). Write down which input you would change first if the simulation missed a podium finisher.
What to look for
The checkpoint output lists P(podium) by driver. Compare it with the actual result: Verstappen won from pole, with Norris, Piastri, Antonelli and Gasly next. The most interesting case is Piastri, who started 17th and finished third. A simulation that starts him 17th with a qualifying-based pace will give him a small podium chance. Ask whether the miss is a pace input (his race pace was better than his qualifying suggested) or the engine (the pass model makes it too hard to come through the field at a circuit that produced 180 green passes in 2026).
27.9 What the Engine Cannot See
Every number in this chapter is conditional on the model. Here is what the model leaves out, in rough order of how much it matters.
- Rivals do not react. Every rival follows its own time-optimal table, not a strategy aimed at you. Real strategy is a game: a leader covers an undercut, and a rival splits strategies to cover both options. Chapter 13 measured undercuts against real replies. A game-theoretic engine would let rivals respond to the focal car.
- The pass model's shape is assumed. Section 27.6 shows that this can change a conclusion. Chapter 35 measures pass probabilities from pace and tyre deltas.
- Degradation is linear, and its inputs are the biggest single error source. Section 27.7 showed degradation is the input that decides; Section 27.8 showed the pre-race model under-predicting wear. Cliffs are rare in race data (0.5% of stints end more than 2 s above the linear fit), so linearity is a minor issue. The level of wear is not.
- No tyre management or fuel saving. Drivers manage pace to make a stint last; the model's cars run their free-air pace every lap.
- No weather. Every simulation here is dry. Chapter 36 adds rain probability and track-temperature scenarios.
- Independent events. Retirements and safety cars are independent in the model after lap 1. In reality a retirement often causes the safety car.
- The stint caps are hard rules. The model forbids a stint longer than the 95th percentile of real stints at the circuit; a real team could gamble on a longer one.
- Team-level detail is missing. Double-stacking team-mates, slow stops by team, and penalties are not modelled. Chapter 34 measures stop distributions by team, and Chapter 37 measures penalties.
⚠️ Common pitfall: reading Monte Carlo precision as accuracy. A 10,000-race run reports the two-stop at +10.10 s with a 95% interval of ±0.26 s. That interval is the Monte Carlo error only. The tornado moved the same number from +4.5 to +16.6 s by changing two inputs within plausible ranges. Report the simulation interval and the input sensitivity together, and never let the first stand in for the second.
Spaced Review
From Chapter 12: What is the critical degradation for a second stop in a 62-lap race with a 23.9 s pit loss, and what does it predict about Singapore? Work it out before reading on. $d^* = 2(k+1)(k+2)P/N^2 = 12 \times 23.866/3844 = 0.0745$ s/lap. Singapore's measured wear is about 0.03–0.05 s/lap, so the formula predicts the one-stop. The 10,000-race Monte Carlo agreed, and it flipped the answer only when wear doubled, landing on the formula's boundary. The closed form told us where the line is; the simulation told us how often the race crosses it.
From Chapter 14: Why is a stop under a safety car cheaper, and by how much? Answer first. The field queues behind the safety car at about 1.43 times the normal lap time, so the time spent in the pit lane is a smaller share of what everyone else loses on that lap. The book's near-field measure puts an SC stop at 12.722 s against 22.512 s green. This chapter's engine uses the field-relative ratio (0.629 median), drawn per stop, because its mean (0.676) and spread are what make the two-stop sometimes lucky.
From Chapter 17: How often does the pole-sitter still lead after lap 1, and how does the engine know? Recall it, then check: in the ground-effect era (2022–25) the pole-sitter led after lap 1 in 76.1% of races (70 of 92). The engine's lap-1 resampler copies whole real lap-1 outcomes from the 69 of those races with every front slot filled, and it reproduces P(lead | pole) = 0.753 against Chapter 17's own sampler at 0.756.
From Chapter 22: Which fuel correction does the Singapore tyre model in this chapter use? None. It is a fixed-effects model with its own lap-number term, which absorbs fuel and track evolution together. The validation race uses DegModel rates fuel-corrected at the toolkit's default (100 kg, 0.03 s/kg), paired with −3.0/N s/lap in the engine.
Project Checkpoint: montecarlo.py
Aisha's addition to Box Box this chapter is the race engine every later module plugs into. It lives in project/boxbox/montecarlo.py. It imports neutralisation.py (Chapter 14: phase hazards, the Singapore multiplier, the phase function), start.py (Chapter 17: real lap-1 fates) and driver.py (Chapter 9: the DriverNoise form). The chapter's scripts feed it inputs from strategy.py (Chapter 12: pooled offsets and warm-up, actual_strategies), pace.py (Chapter 20: race pace) and degradation.py (Chapter 22: DegModel). It does not modify any of them.
| Function | What it does |
|---|---|
TyreModel, Policy, Car, RaceSetup |
the inputs, with the fuel convention carried as a label; Car.plan replays a real strategy |
decision_table(tyres, n_laps, loss_g, max_stops=3) |
the Bellman STAY/GO tables every car decides with |
clean_plan(table, policy, start_age, start_compound) |
the clean-race optimum the table implies |
simulate_race(setup, n_sims=1, seed=42, timeline=None, keep_laps=False) |
one batch of races, vectorised; timeline forces the neutralisations |
run_many(setup, n_sims=10_000, seed=42, batch=2_000) |
many batches, reproducible, common random numbers |
summarise(result) |
per car: P(win), P(podium), P(points), P(DNF), positions, points, stops |
compare_strategies(setup, focal, policies, n_sims) |
the same races under each policy for one car |
ghost_setup(...) |
the single-car-vs-clock mode of the book's Anchor C |
calibrate_passing(setup, target_passes) |
the pass threshold that reproduces a measured pass count |
convergence(x, kind, checkpoints) |
running estimate with Monte Carlo standard error |
field_relative_stop_losses(session) |
the stop-loss data behind the SC/VSC ratios |
The demo (code/project_checkpoint.py) builds the 2026 Las Vegas Grand Prix from its grid with pre-race inputs and runs the three main calls:
setup, info = cm.race_setup(2026, 21) # grid, quali pace, DegModel deg, pool, hazard, DNF
one = mc.simulate_race(setup, n_sims=1, seed=7) # one race
r = mc.run_many(setup, n_sims=10_000, seed=42) # ten thousand
s = mc.summarise(r).sort_values("mean_pos")
tab, _ = mc.compare_strategies(setup, pole, {"one-stop": mc.ONE_STOP, "two-stop": mc.TWO_STOP,
"flexible": mc.Policy(1, 3, "flexible 1-3")}, n_sims=5_000)
2026 Las Vegas Grand Prix: 50 laps, 21 cars, k = 1.53, deg (default fuel) S 0.045, M 0.036, H 0.017 s/lap, green pool median 22.39 s (n = 71), pass threshold -1.00 s/lap (target 80 passes/race, simulated 62.0)
run_many, 10,000 races: top 8 by expected position
code p_win p_podium p_points p_dnf median_pos exp_points mean_stops
ANT 0.313 0.644 0.892 0.102 2.0 15.589 1.242
RUS 0.156 0.477 0.881 0.102 4.0 12.689 1.249
NOR 0.169 0.488 0.861 0.124 4.0 12.720 1.219
VER 0.215 0.527 0.840 0.148 3.0 13.365 1.226
LIN 0.033 0.179 0.838 0.073 6.0 7.674 1.248
HAD 0.041 0.211 0.797 0.140 6.0 8.004 1.233
GAS 0.039 0.192 0.797 0.135 6.0 7.755 1.218
LAW 0.008 0.060 0.691 0.077 9.0 4.381 1.245
Actual top 5: ['VER', 'NOR', 'PIA', 'ANT', 'GAS']
compare_strategies for the pole-sitter VER, 5,000 races each (common random numbers):
policy mean_pos median_pos p_win p_podium p_points exp_points d_time_vs_ref p_better_pos p_worse_pos mean_stops
one-stop 5.751 3.0 0.212 0.513 0.839 13.142 0.000 0.000 0.000 0.957
two-stop 6.962 5.0 0.094 0.316 0.817 9.853 13.332 0.067 0.540 1.920
flexible 5.636 3.0 0.220 0.530 0.843 13.427 -1.015 0.060 0.014 1.223
Read the output critically, as Aisha did. The simulation makes Antonelli (grid 6) the favourite on pace, gives the pole-sitter Verstappen a 21.5% win chance, and puts Verstappen, Norris and Russell next on podium probability. Verstappen won, Norris was second, and Piastri, who started 17th, was third; the simulation did not rate him in its top eight. Two inputs explain most of that. The pre-race wear model makes the HARD almost free (0.017 s/lap), and the pass calibration hit its bound: Las Vegas's target of 80 green passes per race (its 2023–25 mean of 54 × 1.49) could not be reached, and even the easiest passing setting gave only 62.0. A car coming through the field from 17th is exactly what such a model under-rates. At Las Vegas, unlike Singapore, the flexible option helps the pole-sitter: −1.02 s and +0.29 expected points against the one-stop. There passing is easy, so an extra safety-car stop costs little track position. That is the Section 27.6 lesson running the other way.
How it plugs in later:
- Chapter 28 adds rule constraints, such as tyre allocations and the two-compound rule by era.
- Chapter 29 adds 2026 energy deployment.
- Chapter 35 replaces the logistic pass model with a measured one.
- Chapter 36 adds weather scenarios to the timeline.
- Chapter 37 adds team- and lap-dependent retirement hazards and penalties.
- Chapter 40 wraps it in
python -m boxbox simulate, with an HTML report built fromsummariseandcompare_strategies.
The architecture stays the same throughout: draw every random event up front, decide with a table, score with the truth.
Chapter Summary
| Concept | Formula / value | Source |
|---|---|---|
| Monte Carlo standard error | $s/\sqrt n$; $\sqrt{p(1-p)/n}$; runs for half-width $h$: $(1.96 s/h)^2$ | Section 27.5 |
| Common random numbers | same races for every strategy; 1,572× fewer runs for the flexible-vs-one comparison | Section 27.5 |
| Retirement hazard per lap | $h = -\ln(1-p)/(N-1)$; 2026: 18.3% of starters (83/453) | Jolpica results, Section 27.2 |
| Incident hazard | lap 1 0.176, laps 2–10 0.031–0.032, middle 0.019, last 10 0.015 per lap; × circuit $k$ | Chapter 14, Section 27.2 |
| Incident library | 118 incidents: SC 52 (median 4 laps), VSC 52 (1), RED 14 (2) | Section 27.2 |
| SC / VSC stop ratio | field-relative, median 0.639 / 0.751, mean 0.688 / 0.857 (trimmed); decisions use 0.632 / 0.771 | Section 27.2 |
| Bellman decision | pit if price(status) + GO < STAY | Section 27.2 |
| Anchor C, ghost, current data | two − one +10.10 s, P(two faster) 18.9%; flexible −0.84 s, better 15.5%, worse 5.8% | Section 27.4 |
| Anchor C, ghost, snapshot library | +10.33 s, 18.0%; flexible −0.49 s (earlier version: +10.36 s, 16.8%, −0.46 s) | Section 27.4 |
| Hazard to flip the mean | none up to 3× Singapore ($k = 3.99$: +8.8 s) | Section 27.4 |
| Field mode, Singapore | two-stop costs 24–26 s and about 2 places at the front; flexible ≈ −0.13 to −0.15 places at the front, +0.08 in the midfield, sign depends on the pass model | Section 27.6 |
| What flips Singapore | degradation × 2 (−1.1 s, two-stop faster in 57%) | Section 27.7 |
| Validation, 2026 USGP | podium = top three by P(podium); 20/22 inside the 10–90% interval; top-10 Brier 0.059 vs 0.064 for the grid | Section 27.8 |
Decision checklist for a Monte Carlo strategy call
- State the fuel convention of every degradation input, and pair it with the matching fuel term.
- Draw stop losses from pools, not medians; check the mean against the median.
- Decide with the point estimates, and score with drawn "true" parameters.
- Race every candidate through the same random events (common random numbers).
- Size $n$ to the question: hundreds for a 10 s effect, tens of thousands for a tenth.
- Report the mean, median, P(better), P(worse) and percentiles, never one of them alone.
- Run ghost mode and field mode. If they disagree, find the mechanism (track position, traffic, passing).
- Tornado the inputs, and fix the biggest one first.
- Validate on races the model has not seen, against a base rate.
What's Next
Our engine knows the physics of a race but not its rules: it has a two-compound rule and stint caps, and nothing else. Chapter 28 turns to the technical regulations that shape the car itself. Box Box's regs.py will add the sporting constraints (tyre allocations, minimum and maximum stops by era) that the engine's decision table must respect. In Chapter 40 the engine becomes the core of the capstone simulator, and every number this chapter produced becomes a test it must keep passing.