Exercises — Chapter 21: Driver Comparison

Difficulty: ⭐ concepts · ⭐⭐ calculation or short code · ⭐⭐⭐ analysis with judgement · ⭐⭐⭐⭐ open-ended project.

All code exercises run offline on the book's data snapshot (OpenF1 2023 → 2026 R21; Jolpica-F1 1994 → 2026 R21 for qualifying) through toolkit and project/boxbox/ratings.py. Start every script from one of the chapter's scripts in code/; they already have the import header.


Part A — Concepts ⭐

A1. In the model $t_{ij} = T_j(1 + \delta_i)(1 + \varepsilon_{ij})$, which term does the teammate comparison remove, and which terms remain in the log difference of two teammates' times?

A2. Explain in two sentences why the canonical teammate gap uses the best common session. Give a concrete example in which using each driver's best lap of the day would mislead.

A3. A head-to-head of 14–7 and a median gap of −0.119 % (Norris over Piastri, 2026) both say Norris was faster. Which carries more information, and why might you still report both?

A4. Why is the median, not the mean, the canonical summary of a season's teammate gaps? Name the two kinds of event that create the outliers.

A5. List four things that differ between teammates and that the teammate method does not control. For each, say whether it tends to favour a team's lead driver.

A6. Elo uses only win/loss. Give one advantage and one disadvantage of ignoring the margin.

A7. In the driver + car-season regression, which drivers make the driver effects identifiable? What happens to a team whose two drivers never drove for any other team in the data?

A8. The car's share of the spread in predicted Q1 pace was about 30 % in 2025 and 80 % in 2026 in the chapter's model. Explain how the car share can change so much in one year without the drivers changing.

A9. Why does the teammate-chain bootstrap resample races rather than teammate-seasons?

A10. State the chapter's conclusion about Hamilton vs Verstappen in one sentence that a careful statistician would sign.

Answers to Part A (short)

A1. The car term $T_j$ cancels; the difference of the driver shortfalls $\delta_a - \delta_b$ and the difference of the noise terms remain. A2. Track evolution and the knockout format: a Q3 lap is set on a faster track than a Q2 lap. If A is eliminated in Q2 and B reaches Q3, B's Q3 lap would credit B with the grip gained between sessions. A3. The median gap: it knows the size of each win. Report both because the H2H is robust to a single disaster and is what fans and markets use. A4. One crash, mechanical failure or deleted-lap round can produce a multi-percent gap; the median ignores a few such rounds. A5. Setup and parts, run plans and tows, strategy splits, team orders, reliability. Most of these, when they are choices, tend to favour the driver the team prioritises. A6. Advantage: robust to outliers. Disadvantage: wastes information (a 0.01 % and a 0.6 % win count the same). A7. Drivers who change teams; for an isolated team, its car effect and the average of its two drivers cannot be separated (the ridge penalty then splits them arbitrarily, towards zero). A8. The share is a ratio; when the cars converge the total spread shrinks and drivers' (unchanged) differences become a larger fraction. A9. A round is the unit in which both cars of a team are measured together; resampling rounds keeps that pairing and lets every teammate-season median be recomputed. A10. For example: "On career-average qualifying pace measured through the teammate network, Verstappen rates 0.13–0.29 % of a lap ahead of Hamilton depending on the model; the main fit's 95 % interval excludes zero, but two of seven specifications do not."


Part B — Calculations & Physics ⭐⭐

B1. Percent to seconds. Russell's median 2025 qualifying advantage over Antonelli was 0.405 % of the pair-mean lap. Convert it to seconds at Monaco (assume a 71 s pole lap) and at Spa (assume 101 s). Why is this a reason to measure gaps in percent?

Solution

0.405/100 × 71 = 0.288 s; 0.405/100 × 101 = 0.409 s. The same relative advantage is worth 0.12 s more at the longer lap. Pooling seconds across circuits would mix lap length into the driver signal; percent removes it. (The lap lengths here are stated assumptions for the arithmetic.)

B2. Wilson interval. A driver wins a qualifying head-to-head 16–5. Using the Wilson score interval (z = 1.96), compute the 95 % interval for the win share. Compare with the chapter's value for Gasly over Colapinto in 2026.

Solution

p̂ = 16/21 = 0.762, n = 21, z² = 3.8416. Centre = (p̂ + z²/2n)/(1 + z²/n) = (0.762 + 0.0915)/(1.183) = 0.7215. Half-width = z√(p̂(1−p̂)/n + z²/4n²)/(1 + z²/n) = 1.96 × √(0.00864 + 0.00218)/1.183 = 1.96 × 0.1040/1.183 = 0.172. Interval ≈ 0.549 to 0.894, i.e. 55–89 %, matching the chapter's 76 % (55–89).

B3. Elo update. Leclerc (R = 1,765) and Hamilton (R = 1,644) are teammates. With K = 32, what is Leclerc's expected score in their next duel? By how many points does each rating change if Hamilton wins?

Solution

$E_L = 1/(1 + 10^{(1644 - 1765)/400}) = 1/(1 + 10^{-0.3025}) = 1/(1 + 0.498) = 0.668$. If Hamilton wins, Leclerc's S = 0: Leclerc changes by 32 × (0 − 0.668) = −21.4 points and Hamilton gains +21.4.

B4. Chain arithmetic. Using the link values in Figure 11, verify each chain's implied Verstappen − Hamilton gap: Hamilton − Button = −0.271 %, Button − Pérez = +0.003 %, Pérez − Verstappen = +0.525 %. Then explain why the least-squares fit (−0.230 %) is not simply the average of the three chains (−0.451, −0.257, −0.178).

Solution

θ_H − θ_V = (θ_H − θ_Bu) + (θ_Bu − θ_P) + (θ_P − θ_V) = −0.271 + 0.003 + 0.525 = +0.257, so θ_V − θ_H = −0.257 %. The simple average of the three chains is −0.295 %. The fit uses all 386 teammate-seasons and weights them by √n; many longer paths also connect the two drivers, and the chains share a link (Pérez– Verstappen appears in two), so it is not an equal-weight average of three paths.

B5. Standard error of a median. A pair's round-to-round gaps have a spread σ ≈ 0.35 % (in line with the 2026 median |gap|). Using SE ≈ 1.25σ/√k, how many rounds are needed for the SE to fall below 0.1 %? Below 0.05 %? What does that say about separating a pair whose true gap is 0.05 %?

Solution

1.25 × 0.35/√k < 0.1 → √k > 4.375 → k ≥ 20. For 0.05 %: √k > 8.75 → k ≥ 77, more than three seasons. A 0.05 % pair cannot be reliably separated within one season, consistent with Figure 3, where pairs closer than 0.1 % reach only 72 % sign agreement after 12 rounds. (σ = 0.35 % is a stated assumption for the arithmetic.)

B6. Variance shares. In one season the car effects have variance 0.05, the driver effects 0.02 and their covariance is 0.01. Compute the car, driver and covariance shares of Var(car + driver). Then repeat with the car variance cut to 0.01 and everything else unchanged. Relate the answer to 2025 vs 2026.

Solution

Var = 0.05 + 0.02 + 2 × 0.01 = 0.09: car 0.556, driver 0.222, covariance 0.222. With car variance 0.01: Var = 0.01 + 0.02 + 0.02 = 0.05: car 0.20, driver 0.40, covariance 0.40. Shrinking only the car spread halves the car share and doubles the driver share, the same mechanism as 2025 (compressed field, car share 0.28) against 2026 (spread field, 0.80). (Inputs are illustrative numbers.)

B7. Race-pace dilution. The fitted slope of race-pace gap on qualifying gap across 43 teammate-seasons is 0.76. If the true relationship were exactly 1 and the attenuation came only from noise in the qualifying gap, what fraction of the qualifying gap's variance would be noise? (Use slope = Var(true)/[Var(true) + Var(noise)].)

Solution

0.76 = V_t/(V_t + V_n) → V_n/(V_t + V_n) = 0.24: about a quarter of the variance in season qualifying gaps would be noise. In reality noise in the race gap and genuine differences between one-lap and race skill also play a part, so this is one possible decomposition, not a measurement.


Part C — Data & Code ⭐⭐–⭐⭐⭐

C1. Compare these drivers: a full season duel. ⭐⭐ For 2024 McLaren (Norris vs Piastri), use ratings.teammate_gaps(years=2024) and ratings.head_to_head to print the median gap, the H2H and its Wilson interval. Then plot round-by-round gaps in the style of Figure 2. Expected shape: one summary row (the book's tables give Norris −0.126 %, 20–4) and a 24-bar chart.

C2. Analyze this session: race pace. ⭐⭐ Run ratings.teammate_race_pace on the 2026 Mexico City GP (R19). For every team print the gap, laps and compounds. Which teams could not be compared, and why? Then compute the same for the 2026 São Paulo GP (R20) and say whether Mercedes' race-pace gap had the same sign at both. Expected shape: two tables of up to 11 rows (one per team) with gap_s, gap_pct, n_laps, compounds.

C3. Compare these drivers: Elo vs median. ⭐⭐ Using ratings.elo_from_duels(gaps, k=32), extract the pre-duel expected score for every 2026 duel between Antonelli and Russell. Plot the expected score by round and mark the actual winner. Did Elo "learn" the 2026 sign flip, and how many rounds did it take for Antonelli to become the favourite? Expected shape: 21 rows (one per round) with expected_a, score_a; a line chart crossing 0.5 at some round.

C4. Build the analysis: how many rounds? ⭐⭐⭐ Extend code/01_teammate_gaps.py to draw subsets with replacement (a bootstrap) instead of without, and add $k$ = 20 and 24. Compare the curves with Figure 3 and explain the difference at large $k$. Expected shape: three curves, the same three bands; agreement at large k slightly lower than the without-replacement version.

C5. Predict the race: Elo calibration by era. ⭐⭐⭐ Split the Elo duel log (K = 32) into 2006–2013, 2014–2021 and 2022–2026. For each era compute the log loss and the calibration table in the chapter's bins. Is the rating better calibrated in some eras? Suggest a reason tied to how often drivers changed teams. Expected shape: a 3-row table of log loss (the full 2006–2026 value is 0.6176) and three small calibration tables.

C6. Compare these drivers: the network. ⭐⭐⭐ Use ratings.shortest_chains and ratings.chain_fit with ref="alonso" to compare Alonso and Hamilton (former teammates in 2007). Report the direct 2007 gap, the network estimate with a 300-rep bootstrap, and explain any difference between them. Expected shape: the chain list (length 1: they were teammates), the 2007 median (from ratings.pair_seasons) and a network estimate with an interval. (In the chapter's Hamilton-referenced fit, Alonso is +0.075 %, interval −0.046 to +0.197.)

C7. Analyze this session: wet vs dry. ⭐⭐⭐ Change the wet rule in code/03_wet_vs_dry.py from 20 % to 50 % of laps. How many sessions remain (the chapter found 9 at 20 %)? Recompute the median wet delta for Verstappen, Alonso and Norris and the split-half correlation. Does a stricter rule make the conclusion stronger or weaker? Expected shape: a session list (fewer rows), a driver table and one Spearman ρ with its p-value.

C8. Build the strategy: a driver offset for the simulator. ⭐⭐⭐ The project checkpoint converts chain ratings to seconds. Instead, build offsets from the 2026 season only using each team's 2026 median gap: set each team's faster driver to −gap/2 and the slower to +gap/2, in seconds at a 95 s lap. Compare with the chain offsets for the five teams where they differ most. Expected shape: a 22-row table with two offset columns and their difference.


Part D — Strategy & Judgment ⭐⭐⭐

D1. Call the pit stop: team orders in a teammate comparison. You are analysing a race in which the two cars of one team run 1–2 for most of the race, 1.5 s apart. On lap 30 the second car pits first and emerges ahead of the leader after the leader pits on lap 31. Before reading the reveal, decide: should these laps enter the race-pace comparison of Section 21.3? Which laps, if any, would you exclude, and why?

Reveal

The pit laps are already excluded by the canonical clean-lap rule (in- and out-laps). The harder question is the stint before: the second car ran 1.5 s behind its teammate, in the dirty air of a car of identical pace, which slows it. The same-compound method compares both drivers in the same lap window, so the follower's dirty-air penalty counts against them. A defensible choice is to restrict the comparison to laps where each car had more than about 2 s of clear air (the interval column), and to report how many laps that leaves. Team orders cannot be seen in timing data; the honest output is a gap with n and a note that the cars were not racing in independent conditions.

D2. Design the setup: when a car suits one driver. Two teammates have a 0.35 % qualifying gap in one season and 0.05 % the next, after a change of front-suspension concept announced by the team. A team principal asks you whether the slower driver "improved". Lay out what you can and cannot conclude from timing data, and design a comparison (using only this book's data sources) that would separate "driver improved" from "car now suits the driver".

Guidance

What timing data can say: the size of the gap in each season, with intervals, on Saturday and on Sunday. What it cannot say: why it changed. "Driver improved" and "car now suits the driver" predict the same headline gap, so you need a comparison where they predict different things.

  • Across circuit types. If the new concept helps the slower driver mainly in slow corners (a plausible mechanism for front-suspension changes), the gap should close most at low-speed circuits. Split the season's rounds by circuit type (Chapter 10's circuit profiles, or the full-throttle share from telemetry) and compare the gap by type in both seasons. A uniform closing is more consistent with driver development.
  • Across sectors. With OpenF1 sector and mini-sector times (2023+), compare the pair's sector gaps before and after. A change concentrated in one kind of sector points to the car.
  • Before and after within a season. If the concept arrived mid-season, compare the gap in the rounds before and after, with the circuit mix controlled (Chapter 30's before/after design).
  • Against a third driver. If the slower driver had a different teammate in an earlier season, the network fit (21.7) gives an independent reading of their level.

State the conclusion conditionally: "the gap closed by X % (interval); the closing was (or was not) concentrated in slow sectors, which is (or is not) consistent with a car-specific effect".

D3. Hiring decision. A midfield team must choose between two drivers. Driver X beat a weak teammate by 0.45 % over two seasons; driver Y lost to a strong teammate by 0.05 % over three seasons. Use the teammate chain to frame the comparison, say what extra data you would want, and state how you would express the uncertainty to the team principal.

Guidance

Frame both drivers on the network, not on their raw gaps. X's 0.45 % margin is measured against a teammate whose own chain rating may be poor; Y's −0.05 % deficit is measured against a strong one. Fit ratings.chain_fit with any reference and compare θ_X and θ_Y directly, with a race bootstrap. Ask for: the teammates' own connections (how many rounds link them to the rest of the grid), race-pace gaps on the same compound, and the season-by-season trend (is X improving, is Y declining?). Express the result as "X rates ahead of Y by a (interval b to c); the result depends mainly on the link through X's teammate, which rests on n rounds". If the interval includes zero, say so plainly and let other criteria (cost, development feedback, age) decide.

D4. The broadcast claim. A commentator says, "He's the best wet-weather driver on the grid; look at his record in the rain." Using Section 21.4, write a 150-word reply that a fan would understand, including the sample size, one statistic and what would change your mind.

Guidance

A good reply names the sample (nine wet qualifying sessions in four seasons, 2023–2026), the noise (wet teammate gaps are about three times as spread as dry ones: 0.984 % vs 0.349 %), and the replication test (split-half ρ = 0.27, p = 0.26). It acknowledges the strongest case (Verstappen gained on his teammate in 8 of 9 wet sessions) and explains multiple comparisons in plain words: with 20 drivers tested, one such result is expected by chance. It ends with what would change your mind: a longer wet record that replicates across halves, or wet race stints compared on intermediates.


Part M — Mixed / Interleaved ⭐⭐–⭐⭐⭐

M1. (Ch 16 + Ch 21) ⭐⭐ Chapter 16 measured track evolution from Q1 to Q3. Use it to explain why the regression of Section 21.6 uses Q1 for every car rather than each car's best time, and identify one bias that choice introduces for front-running teams.

Answer sketch

Q1 is the only session every car runs, so it is the only like-for-like comparison across all 20–22 cars: a Q3 lap is set on a faster (more rubbered-in) track than a Q2 lap, so mixing sessions would mix track evolution into car effects. The bias: front-running teams often do the minimum needed to progress in Q1 (one run, sometimes a used set), so their Q1 deficit to the session's fastest overstates how far behind they really are. That pushes their car effects towards the average and compresses the car spread, which lowers the estimated car share.

M2. (Ch 20 + Ch 21) ⭐⭐⭐ Repeat the race-pace comparison of 21.3 with the data-driven fuel effect (the book's reference tables give 0.033 s/kg at 100 kg) instead of the 0.03 s/kg assumption. Re-run code/02_race_pace_teammates.py with that value passed through metrics.fuel_corrected(…, s_per_kg=0.033) in a copy of teammate_race_pace. How much do the 43 season medians move? Explain why the answer is "very little".

Answer sketch

Within one lap window both drivers carry almost the same fuel, so the fuel term $s_{kg} \times \text{fuel}(L)$ is nearly identical for the two and cancels in $\beta_1$. Changing 0.03 to 0.033 s/kg changes both drivers' corrected times by almost the same amount. Small differences arise only where the common window spans many laps and the two drivers' laps are unevenly spread inside it.

M3. (Ch 9 + Ch 21) ⭐⭐ Chapter 9 modelled a driver's lap-time noise σ. Use ratings.lap_consistency to estimate σ for both drivers of each 2026 team, and compare the within-team difference with the cross-team spread. What fraction of the cross-team spread could be a car (clean-air) effect?

M4. (Ch 13 + Ch 21) ⭐⭐⭐ The undercut depends on out-lap pace. Using OpenF1 2023–2026, compare teammates' out-lap time relative to their own clean-lap median. Is out-lap performance a stable driver trait (year-to-year Spearman, as in 21.3), or mostly team procedure?

M5. (Ch 17 + Ch 21) ⭐⭐ Chapter 17's lap-1 gains by grid slot can be compared within teams. For 2023–2026, compute each driver's median lap-1 gain minus the teammate's. How many pairs have a difference whose interval excludes zero? What does the answer say about "great starters"?


Part E — Research & Extension ⭐⭐⭐⭐

E1. A time-varying chain rating. Replace the single career θ with a θ that drifts: $\theta_{i,s} = \theta_{i,s-1} + \eta_{i,s}$, with a penalty on $\eta$ (a random walk with ridge smoothing). Fit it on 1994–2026 and plot Hamilton's and Verstappen's θ by season with bootstrap bands. Does the season-by- season comparison in their overlapping years (2015–2026) differ from the career average of −0.230 %?

Hints. Give every driver one parameter per season they raced; write each teammate-season as $y_k = \theta_{a,s} - \theta_{b,s} + \varepsilon_k$ and add penalty rows $\lambda(\theta_{i,s} - \theta_{i,s-1}) = 0$ for every driver's consecutive seasons. Stack them into one least-squares problem. With λ → ∞ you recover the chapter's constant-θ fit; with λ → 0 each season floats free and the network breaks into disconnected pieces. Choose λ by leaving out one season of teammate gaps at a time and predicting it. Report the chosen λ, the season-by-season Verstappen − Hamilton difference with a race bootstrap, and say in which seasons the interval excludes zero.

E2. A Bayesian driver–constructor model. Following the approach of van Kesteren & Bergkamp (2023), fit a hierarchical model of Q1 deficits with driver, constructor-season and round effects, using statsmodels' mixed-effects tools (MixedLM) rather than a ridge penalty. Compare the car share with the chapter's α = 1 and α = 10 results and discuss what the random-effect variances replace.

E3. Race results, not lap times. Bell et al. (2016) rated drivers and constructors on results. Build a results-based teammate chain for 1950–2026 (finishing order between teammates when both were classified) and compare its Hamilton–Verstappen verdict with the qualifying chain. Pay attention to reliability: how will you treat retirements, and how does that choice change the answer?