Appendix D — Statistical Methods Reference
This appendix is the toolbox laid out on one bench. Every statistical method the book uses has an entry here, and every entry has the same five parts:
- The idea: what the method does, in a sentence or two of cricket.
- The formula, written once, with the symbols the chapters use.
- When to use it, and when not to. Most of the mistakes in cricket analytics come from a good method used on the wrong question.
- A minimal runnable example on real data. The output is pasted from a run, not typed.
- Where the book uses it, with links to the chapters and the real numbers they found.
All the examples live in one script, appendices/code/d_methods.py. It uses the toolkit (toolkit/cricdata.py, venues.py) and the Crease modules you built chapter by chapter. Run it from the book folder:
python appendices/code/d_methods.py # every section, about a minute once the cache exists
python appendices/code/d_methods.py D06 D19 # just the sections you want
On a Windows console, set PYTHONIOENCODING=utf-8 first (see Appendix A). Seeds are fixed, so you'll get the same numbers. The complete output is saved next to the script as appendices/code/d_output.txt. The excerpts below are pasted from it.
Where an example reproduces a number a chapter already reported, the entry says so. Where it gives a slightly different number, the entry says why: usually a different filter or a different random draw. Every figure about a real player or match comes from the book's data snapshot (Cricsheet, downloaded 18 November 2026). Two examples are pure simulations: a hypothetical league season in D.27 and a bankroll model in D.29. Both are labelled.
🏏 Fan Track: Read the "idea" and "when not to" paragraphs of D.1–D.9 and D.12–D.13. They are the difference between reading cricket numbers and being fooled by them.
📊 Analyst Track: Use the contents table as a checklist when you design a study. The ⚠️ pitfalls are the ones that bit this book's own analyses.
🎰 Betting Track: D.11, D.13, D.14, D.19 and D.29 are the core of Chapter 35.
Contents
| § | Method | Chapters that use it |
|---|---|---|
| I | Describing and measuring uncertainty | |
| D.1 | Rates and ratios: pooled v averaged, average v runs per innings | 1, 4, 5, 8, 10, 14 |
| D.2 | Sampling distributions, standard errors, confidence intervals | 6, 8, 11, 22 |
| D.3 | The bootstrap, and why you resample innings or matches, not balls | 6, 13, 15, 20, 35 |
| II | Signal, noise and shrinkage | |
| D.4 | Reliability: split-half, season-to-season, the k constant, "balls until half signal" | 6, 8, 10, 12, 14, 16, 25, 31 |
| D.5 | Regression to the mean | 6, 8, 25, 38 |
| D.6 | Normal–normal (empirical Bayes) shrinkage and Bayesian updating | 6, 11, 12, 13, 22, 25, 31, 34, 38 |
| D.7 | Beta–binomial shrinkage of a rate | 6, 10, 35 |
| D.8 | Luck share: how much of a table is coin-flips | 6, 14, 24 |
| D.9 | Simpson's paradox and direct standardisation | 4, 6 |
| III | Testing claims | |
| D.10 | Hypothesis tests and multiple comparisons (Bonferroni) | 10, 16, 22, 35 |
| D.11 | Power: how many matches or bets before an effect is visible | 22, 35 |
| IV | Predicting, and checking the predictions | |
| D.12 | Logistic regression | 9, 13, 14, 16, 20, 22, 24 |
| D.13 | Scoring rules and calibration: Brier, log loss, reliability curves | 9, 20, 24, 29, 33, 35, 36 |
| D.14 | Train/test splits by match and by time; leakage | 14, 15, 20, 24, 25, 35 |
| D.15 | Gradient boosting, and why trees don't extrapolate | 20, 24 |
| V | Time, state and sequence | |
| D.16 | Survival analysis: Kaplan–Meier, log-rank, Cox | 10 |
| D.17 | Markov chains and expected-runs tables (and WPA, leverage) | 9, 19, 20, 27, 30, 31 |
| D.18 | Resource functions (the Duckworth–Lewis form) | 19, 23 |
| D.19 | Elo ratings | 20, 24, 28, 35 |
| VI | Projection | |
| D.20 | Marcel projections | 25, 34, 36 |
| D.21 | The delta method for aging | 25 |
| D.22 | League translation factors | 26, 34, 36 |
| VII | Value and decisions | |
| D.23 | Runs above replacement and runs per win | 13, 21, 34 |
| D.24 | Integer programming and the assignment problem | 21, 31, 36 |
| D.25 | Difference-in-differences and natural experiments | 15, 21, 22, 23 |
| D.26 | Clustering | 15 |
| D.27 | Monte Carlo simulation: innings, tournaments, batting orders, fields | 14, 19, 27, 28, 29, 30, 32, 33, 36 |
| D.28 | Intraclass correlation | 36 |
| D.29 | The Kelly criterion and bankroll simulation | 35 |
| D.30 | Choosing a method: a decision table | — |
Symbols used throughout: $n$ is a sample size (balls, innings, matches); $\bar x$ an observed mean; $\mu$ a league or population mean; $\sigma$ the spread of a single unit (one ball); $\tau$ the spread of true talent between players; $p$ a probability; $k$ the number of units a prior is "worth".
Part I — Describing and measuring uncertainty
D.1 Rates and ratios
The idea. Almost every cricket statistic is a ratio: runs per dismissal (average), runs per ball (strike rate), runs per over (economy), balls per wicket (bowling strike rate). Two choices decide whether a ratio tells the truth. Is it a pooled ratio (total runs ÷ total balls) or an average of ratios (the mean of each innings' strike rate)? And is its denominator the right one: outs, innings, or balls?
Formulas (the book's canonical definitions, Appendix C):
$$\text{average} = \frac{\sum \text{runs}}{\sum \text{outs}}, \qquad \text{SR} = 100 \times \frac{\sum \text{runs}}{\sum \text{balls faced}}, \qquad \text{economy} = 6 \times \frac{\sum \text{runs conceded}}{\sum \text{legal balls}}$$
$$\text{pooled rate} = \frac{\sum_i y_i}{\sum_i n_i} \quad \neq \quad \frac{1}{m}\sum_i \frac{y_i}{n_i} = \text{mean of rates}$$
A pooled rate weights each innings by its balls. The mean of rates gives a 2-ball innings the same vote as a 60-ball one.
Use when. Pooled ratios are the default for every career or season figure in the book. Don't average per-match strike rates or economies unless you mean to weight every match equally (you almost never do). Don't use batting average when not-outs are common: the denominator then counts something other than innings. For a lower-order finisher, runs per innings or balls per dismissal tells you more.
Example.
k = batting_summary(only_player(ipl, "V Kohli")).loc["V Kohli"]
t = innings_table(only_player(ipl, "V Kohli"), "V Kohli") # crease.uncertainty
faced = t[t["balls"] > 0]
print(100 * t.runs.sum() / t.balls.sum(), (100 * faced.runs / faced.balls).mean())
d = innings_table(only_player(ipl, "MS Dhoni"), "MS Dhoni")
print(d.runs.sum() / d.outs.sum(), d.runs.sum() / len(d))
Kohli IPL: 9,336 runs, 6,926 balls, 231 outs -> average 40.42, SR 134.80
pooled SR (sum runs / sum balls) 134.80
mean of per-innings SRs (275 innings faced) 120.14 <- short innings get the same vote as long ones
Dhoni IPL: 5,439 runs, 242 innings, 142 outs, not-out share 41.32%
average (runs/outs) 38.30 v runs per innings 22.48 -> ratio 1.70
Kohli's mean of per-innings strike rates is 14.7 points lower than his real strike rate. His short innings are slow, so they drag the unweighted mean down. Dhoni's average is 1.70 times his runs per innings because 41.32% of his IPL innings ended not out. That is exactly Chapter 4's figure.
In the book. Chapter 1: among the 58 IPL batters with at least 1,500 balls, average and strike rate correlate only 0.16. Chapter 4: the Dhoni inflation; across the same 58 batters, average correlates 0.06 with runs above par but strike rate 0.73. Chapter 8: boundary-ball % alone explains 76% of IPL strike-rate variance. Chapter 10: in Tests the right companion to average is balls per dismissal (Spearman 0.77 with average; strike rate 0.07). Chapter 5 and Chapter 14 define the format- and phase-specific versions.
⚠️ Common pitfall: same name, different denominator. Chapter 11's "matchup dismissal" counts bowler-credited dismissals of the striker. It excludes run-outs, so it is not the canonical "outs". Always state the denominator.
D.2 Sampling distributions, standard errors and confidence intervals
The idea. A strike rate from 100 balls is one draw from the strike rates that batter could have produced over those 100 balls. The sampling distribution is the spread of those possible values. Its standard deviation, the standard error (SE), shrinks only with the square root of the sample. Four times the balls buys half the uncertainty.
Formulas. For a mean of $n$ independent balls with per-ball SD $\sigma$:
$$\text{SE}(\bar x) = \frac{\sigma}{\sqrt{n}}, \qquad \bar x \pm 1.96 \cdot \frac{\sigma}{\sqrt n} \ \text{ (an approximate 95 percent interval)}$$
For a rate $p$ (dismissals per ball, wins per match):
$$\text{SE}(\hat p) = \sqrt{\frac{\hat p(1-\hat p)}{n}}$$
For small counts, or a rate near 0 or 1, use an exact binomial interval (scipy.stats.binomtest(...).proportion_ci()) or a Beta posterior (D.7).
Use when the units are roughly independent and $n$ is not tiny. Don't treat balls within one innings as independent. A batter's balls in a given innings share the pitch, the match situation and his form that day, so ball-level SEs are slightly too narrow. Resample innings instead (D.3). Don't read a 95% interval as "95% chance the true value is inside". It is a statement about the procedure. For a probability statement about one player, use a Bayesian posterior (D.6, D.7).
Example (IPL 2023–26, every ball faced):
balls faced 66,914: mean of 100 x runs = SR 150.2; per-ball SD of 100 x runs = 181.0
n = 30 balls: SE of a strike rate = 33.1 SR points; 95% half-width 64.8
n = 100 balls: SE of a strike rate = 18.1 SR points; 95% half-width 35.5
n = 300 balls: SE of a strike rate = 10.5 SR points; 95% half-width 20.5
n = 1000 balls: SE of a strike rate = 5.7 SR points; 95% half-width 11.2
striker dismissal rate per ball faced p = 0.0517 (one out every 19.4 balls)
n = 100: SE 0.0221; 95% range of the rate 0.0083–0.0950 -> balls per dismissal 10.5–120.8
n = 500: SE 0.0099; 95% range of the rate 0.0323–0.0711 -> balls per dismissal 14.1–31.0
A whole IPL season for a top-order batter is about 300 balls. That leaves a strike rate uncertain by about ±20 points. The dismissal rate is worse: even 500 balls leave "balls per dismissal" anywhere from 14 to 31. This one table is the reason Part II of this appendix exists.
In the book. Chapter 6 introduces the per-ball distributions by format: IPL 2023–26 mean 1.50 runs per ball, SD 1.81. Chapter 11 draws the "luck band" funnel: 88.2% of batter–bowler pairs with 12+ balls sit inside the 95% band that luck alone would produce. Chapter 22 gives every toss percentage an interval (IPL 51.6%, 48.8–54.4).
D.3 The bootstrap
The idea. When the formula for an SE is awkward (a ratio, a difference of ratios, a model's ROI), simulate the sampling distribution instead. Draw the data again with replacement, recompute the statistic, repeat thousands of times, and read the interval off the percentiles. The art is choosing what to resample. Resample the independent unit (innings, matches, players), not the ball.
Formula (percentile bootstrap of a pooled ratio over clusters $i = 1..m$):
$$\hat\theta^{(b)} = \frac{\sum_{i \in S_b} y_i}{\sum_{i \in S_b} n_i}, \quad S_b = m \text{ clusters drawn with replacement}, \qquad \text{CI} = \big[q_{0.025}(\hat\theta^{(b)}),\ q_{0.975}(\hat\theta^{(b)})\big]$$
Use when you need an interval for anything computed from data, as long as you have at least 10–20 clusters. Don't trust it with a handful of clusters. Chapter 6's example: Sanju Samson's five innings at the 2026 T20 World Cup gave a bootstrap interval half the width of a sensible one. Don't resample balls when innings are the unit. Don't bootstrap across time when the question is about the future: use an out-of-time test (D.14).
Example (crease.uncertainty.ratio_ci):
t = innings_table(only_player(r, "V Kohli"), "V Kohli") # r = IPL 2024-26
ratio_ci(t["runs"], t["balls"], scale=100.0, n_boot=5000, seed=6)
Kohli IPL 2024–26: 2073 off 1340 in 46 innings; SR 154.7, innings-bootstrap 95% 146.4–162.8
ball-level bootstrap (wrong unit) 95% 145.7–163.6
average 57.58, 95% 43.50–77.10 (36 outs)
The innings bootstrap reproduces Chapter 6's 154.7 [146.4–162.8]. The ball-level version happens to be similar here, but it rests on the wrong assumption. Look at the average's interval: 36 outs leave a 34-run-wide range. Averages are much noisier than strike rates.
In the book. Chapter 6: Brook − Root Test average difference 2.64 [−11.7, 17.9], Brook ahead in 63.6% of resamples. Chapter 15: a by-match bootstrap for the DRS difference-in-differences (D.25). Chapter 20: a chase bootstrap for the IPL chaser miss, +0.077 (90% +0.045 to +0.110). Chapter 35: an honest backtest ROI of +10.1% with interval −3.2 to +24.0. The interval, not the point, is the finding. Chapter 13: the recency tilt 1.87 : 1 (bootstrap 90% 0.99–3.32).
Part II — Signal, noise and shrinkage
D.4 Reliability, the k constant and "balls until half signal"
The idea. A statistic is reliable if it repeats: measure the same players twice, on separate samples, and the two measurements agree. Split-half reliability splits each player's balls at random into two halves and correlates the halves across players. Season-to-season reliability correlates one season with the next. Both rise with sample size, and for a per-ball rate they follow one curve, controlled by one number, $k$.
Formulas. If true talent varies between players with SD $\tau$ and one ball has noise SD $\sigma$, the expected correlation between two independent samples of $n$ balls is
$$r(n) = \frac{n}{n + k}, \qquad k = \frac{\sigma^2}{\tau^2}$$
At $n = k$, $r = 0.5$: half the spread you see between players is real. That is why the book calls $k$ "balls until half signal". Two related identities:
$$\text{Spearman–Brown (doubling the sample):}\quad r_{2n} = \frac{2 r_n}{1 + r_n}$$
$$\text{disattenuation (correlation of the true values):}\quad r_{\text{true}} = \frac{r_{\text{observed}}}{\sqrt{\rho_1 \rho_2}}$$
where $\rho_1$ and $\rho_2$ are the reliabilities of the two measures being correlated.
Use when you need to know whether a metric measures a player or the dice, before you build anything on it. Don't compare reliabilities computed on different filters. Chapter 6 and Chapter 8 give different season-to-season batting-average reliabilities (0.23 v 0.209) because they select players differently. Don't select players on balls when you're measuring a dismissal rate: Chapter 25 shows this manufactures a near-zero split-half r. Select on innings.
Example (IPL 2008–26, crease.uncertainty.split_half and fit_k, Chapter 6's grid of sample sizes):
split-half SR, n = 25 balls per half: r = 0.343
split-half SR, n = 50 balls per half: r = 0.412
split-half SR, n = 100 balls per half: r = 0.536
split-half SR, n = 150 balls per half: r = 0.624
split-half SR, n = 200 balls per half: r = 0.665
split-half SR, n = 300 balls per half: r = 0.682
split-half SR, n = 400 balls per half: r = 0.718
split-half SR, n = 600 balls per half: r = 0.763
fitted k = 94 balls (r = n / (n + k); 'balls until half signal' = k)
predicted r at 50/120/500 balls: 0.35, 0.56, 0.84
Spearman–Brown: r at 100 balls 0.536 -> at 200 balls 2r/(1+r) = 0.698 (measured 0.665)
Disattenuation (Ch 31 numbers): raw r 0.22 / sqrt(0.53 x 0.28) = 0.57
Chapter 6 reported $k \approx 98$ balls for strike rate. This run's random splits give 94, and that gap is itself a lesson: $k$ is an estimate with its own noise. Spearman–Brown slightly over-predicts here because the pool of eligible batters changes as $n$ grows (only batters with $2n$ balls qualify).
In the book.
| Statistic (chapter) | Reliability / k |
|---|---|
| IPL strike rate, split-half (Ch 6) | k ≈ 98 balls |
| IPL dismissal rate, split-half (Ch 6) | k ≈ 554 balls |
| IPL season-to-season r: SR / average / bowling average (Ch 6) | 0.48 / 0.23 / 0.07 |
| Season-to-season: batting average least, boundary-run % most (Ch 8) | 0.209 / 0.572 |
| Test conversion rate, split-half → Spearman–Brown (Ch 10) | 0.28 → 0.44 |
| Test batting average, split-half → Spearman–Brown (Ch 10) | 0.44 → 0.61 |
| Partnership "chemistry", IPL split-half (Ch 12) | r 0.154 (reliability 0.27) |
| IPL wicket rate, year to year (Ch 14) | 0.16 |
| Test bowling economy / strike rate, repeatability (Ch 16) | 0.814 / 0.414 |
| IPL SR+, alternate-innings split-half (Ch 25) | r 0.231 → k 381 balls |
| Powerplay v death bowling skill, noise-corrected (Ch 31) | raw 0.22 → 0.58 |
Chapter 31's 0.58 comes from unrounded reliabilities; the 0.57 above uses the rounded ones. For single-match totals such as fantasy points, the same idea is expressed as an intraclass correlation (D.28).
D.5 Regression to the mean
The idea. Extreme performances are partly extreme talent and partly extreme luck. Next time the luck is redrawn, so the extremes come back toward the middle. Nothing has to change in the player for this to happen. If you then "explain" the fall (pressure, the price tag, the captaincy), you have explained noise.
Formula. When season $N$ and season $N+1$ are equally reliable, the best linear forecast is
$$\hat y_{N+1} = \mu + r \cdot (y_N - \mu)$$
so a fraction $1 - r$ of every deviation from the mean is expected to vanish. The fitted slope is $r$ multiplied by the ratio of the two seasons' SDs. Regression to the mean is the frequentist face of shrinkage (D.6).
Use when you judge any change after selecting on an extreme: hot starts, slumps, the "breakout" auction buy, last season's best and worst teams. Don't treat regression as a force acting on players. It is a property of selection plus noise. Don't use it to deny real change: Chapter 25 found Vaibhav Suryavanshi's 2026 season 43 points above his projection (z 3.8). Some extremes are real.
Example (IPL batters with 150+ balls in consecutive seasons):
strike_rate pairs 489: r = 0.476; N+1 = 67.75 + 0.505 x N
average pairs 489: r = 0.232; N+1 = 25.56 + 0.240 x N
top-10% SR seasons (>= 162.5): 174.1 -> 158.5 next season; 78% fell
This reproduces Chapter 6 exactly. About half of a strike-rate deviation survives into next season; about a quarter of an average deviation does.
In the book. Chapter 6's hot starts: about 31% of a five-innings excess survives, and the hot-start group's average of 66.83 became 37.21. Chapter 25, with an index measured against par: only 20% survives, and the top-10% SR+ seasons went 131.7 → 115.2, with 86% falling. Chapter 38: next season keeps 0.312 of last season's SR+, and after a 15+ point fall 75.9% rose the following year. Chapter 8 ranks metrics by how much they regress.
D.6 Normal–normal (empirical Bayes) shrinkage and Bayesian updating
The idea. The best estimate of a player's true rate is a weighted average of his record and the league's. The weight on his record grows with his sample. "Empirical Bayes" means the league prior, its mean and its spread $\tau$, is estimated from the data itself.
Formulas. With prior $\mu$, true-talent SD $\tau$, per-ball SD $\sigma$ and $n$ balls averaging $\bar x$:
$$\hat\theta = \frac{n \bar x + k\mu}{n + k} = \mu + \frac{n}{n+k}(\bar x - \mu), \qquad k = \frac{\sigma^2}{\tau^2}$$
The shrinkage factor $n/(n+k)$ is the reliability from D.4. Estimate $\tau^2$ by the method of moments: the observed variance of player rates minus the variance noise alone would produce,
$$\hat\tau^2 = V_w(\bar x_i) - \frac{\sigma^2 m}{\sum_i n_i}$$
where $m$ is the number of players and $V_w$ is the variance of the players' rates weighted by balls. Updating a prior $N(\mu_0, s_0^2)$ with $n$ observations gives the posterior
$$\text{precision} = \frac{1}{s_0^2} + \frac{n}{\sigma^2}, \qquad \text{posterior mean} = \frac{\mu_0 / s_0^2 + n\bar x / \sigma^2}{\text{precision}}$$
Use when you rank, compare or forecast players with unequal samples, which is always in cricket. Shrink toward the right group: league par for a phase, the bowling type's league rate for a matchup (Chapter 11's hierarchical version), replacement level for a selection optimiser (Chapter 21). Don't reuse one $k$ everywhere. Within-season description and next-season forecasting want different amounts (Chapter 6: about 100–190 balls v about 300–400). Don't shrink toward a mean the player clearly doesn't belong to. A specialist opener's powerplay strike rate should shrink toward powerplay par, not the all-phase mean.
Example (IPL 2026, batters with 30+ balls; k_method_of_moments, shrink_normal):
sigma2 = (100 * f["runs_batter"]).var() # per-ball variance, IPL 2026
mm = k_method_of_moments(t["strike_rate"], t["balls"], sigma2)
t["shrunk"] = shrink_normal(t["strike_rate"], t["balls"], league, mm["k"])
IPL 2026: league SR 156.34; per-ball variance sigma^2 = 34798; 101 batters >= 30 balls
SD observed 24.0 = noise 14.8 + true 18.8 (in quadrature) -> k = sigma^2/tau^2 = 98 balls
name balls strike_rate shrunk
V Suryavanshi 327 237.3 218.6
FH Allen 163 214.1 192.4
Priyansh Arya 172 211.6 191.5
Abhishek Sharma 275 204.7 192.0
Urvil Patel 64 201.6 174.2
This reproduces Chapter 6's 2026 figures: $k$ = 98, Suryavanshi 237.3 → 218.6, Urvil Patel 201.6 → 174.2. Patel's 64 balls earn a 0.40 weight, and Suryavanshi's 327 earn 0.77.
In the book.
| Application | Shrinkage constant | Chapter |
|---|---|---|
| IPL season SR (description) | k 98–188 balls by season | 6 |
| Next-season SR forecast | k ≈ 300–400 balls | 6 |
| Batter v bowling type, SR / dismissal (men) | k_sr 303, k_dr 1,956 balls | 11 |
| Same, women | 269 / 2,905 balls | 11 |
| Partnership chemistry, Abhishek Sharma & Head | +20.4 → about +5.5 SR+ points | 12 |
| IPL net runs per ball by phase, 2023–26 | 558 / 255 / 106 balls (powerplay / middle / death) | 13 |
| IPL venue first-innings effect | k = 75 games | 22 |
| Marcel SR+ (fitted on past seasons) | k ≈ 371 balls | 25 |
| Bowling skill, general / phase interaction (men) | k_g 701, k_i 5,184 balls | 31 |
| Auction value projection | k = 28 matches | 34 |
| Death-over SR (pooled men's leagues) | k = 158 balls | 38 |
The flagship result is Anchor D. Quinton de Kock against off-spin in men's T20 cricket, 2015–2026: 1,226 balls, raw SR 112.9, shrunk SR 115.5 (90% interval 108.5–122.4) against an expected 125.8. Chapter 11's out-of-sample test is the reason the book always quotes the shrunk figure: mean squared error 404 for raw matchups, 220 for ignoring matchups entirely, 208 for shrunk. Raw small-sample matchups are worse than no matchups at all.
Bayesian updating with an explicit prior appears in Chapter 6. Samson's 2026 World Cup posterior was 178.5 [161.1–195.8] under an "open-minded" prior and 157.5 [149.3–165.8] under a "sceptical" one. Chapter 25 settled the question out of sample: the sceptical prior wins (RMSE 12.68 v 13.72), and the best fixed prior strength is about 419 balls.
🔍 Why this works. Efron and Morris's (1975) baseball example made the point that shrinking every player toward the group mean beats using each player's own average, in total, even though it is wrong for some individuals. Each estimate borrows strength from the others. Cricket's small samples make the gain larger than in baseball.
D.7 Beta–binomial shrinkage of a rate
The idea. For a yes/no rate (dismissed on this ball, converted this fifty, won this match), the natural prior is a Beta distribution. It updates by simple counting. The prior acts like $a$ extra successes and $b$ extra failures added to the player's record.
Formulas. Prior $\text{Beta}(a, b)$, data $s$ successes in $t$ trials:
$$\text{posterior} = \text{Beta}(a + s,\ b + t - s), \qquad \hat p = \frac{s + a}{t + a + b}$$
$a + b$ is the prior's worth in trials (the beta–binomial version of $k$). Fit $a$ and $b$ by matching the population mean $m$ and the true-talent variance $v$ (observed variance minus binomial noise):
$$a + b = \frac{m(1-m)}{v} - 1, \qquad a = m(a+b), \qquad b = (1-m)(a+b)$$
A credible interval comes straight from the Beta posterior's quantiles (beta_interval).
Use when the rate is a proportion and samples are small: dismissal rates, conversion rates, catches per chance, a team's win rate. Don't use it when the outcome isn't binary (runs per ball has a long right tail; use D.6). Don't fit the prior on a population selected by the outcome, for example only batters who averaged over 40.
Example (WPL career batters with 60+ balls; dismissal rate shrunk with the Beta prior, runs per ball shrunk with $k$ = 100 balls, shrunk average = shrunk runs per ball ÷ shrunk dismissal rate, as in Chapter 6):
65 batters; prior mean 0.0508 per ball; Beta(a = 13.4, b = 250.9) -> worth a + b = 264 balls
league runs per ball 1.300; runs-per-ball shrinkage k = 100 balls
EA Perry 972 runs, 731 balls, 15 outs: average 64.80; dismissal rate 0.0205 -> 0.0286 (90% 0.0204–0.0377); shrunk average 46.45
NR Sciver-Brunt 1348 runs, 936 balls, 27 outs: average 49.93; dismissal rate 0.0288 -> 0.0337 (90% 0.0256–0.0427); shrunk average 42.37
H Kaur 1193 runs, 820 balls, 26 outs: average 45.88; dismissal rate 0.0317 -> 0.0364 (90% 0.0275–0.0462); shrunk average 39.56
This reproduces Chapter 6 exactly: Perry 64.80 → 46.45, Sciver-Brunt 49.93 → 42.37, Harmanpreet 45.88 → 39.56. Perry's 15 dismissals are not enough to sustain an average of 64.80. Her 90% interval for the dismissal rate runs from 0.0204 to 0.0377, almost a factor of two.
In the book. Chapter 10: Test conversion (100s ÷ fifty-plus scores) has a pool rate of 33.7% and a prior worth 56 fifty-plus scores. Kohli 49.2% raw → 41.7% shrunk (90% 34.4–49.3). Chapter 35: "top team batter" prices, shrunk with $k$ = 20 toward the opener base rate (Gill 24 of 60 → 0.355). Chapter 14's expected-wickets model measures batter quality as a Beta-shrunk dismissal rate (prior worth 150 balls).
D.8 Luck share: how much of a table is coin-flips?
The idea. Even if every team were equally good, a 14-game season would spread win percentages purely by chance. Compare the observed spread of win percentages with the spread coin-flips alone would produce. The difference is true skill.
Formulas. For team-seasons with $g_i$ decided games:
$$\sigma^2_{\text{luck}} = \frac{1}{m}\sum_i \frac{0.25}{g_i}, \qquad \sigma^2_{\text{true}} = \sigma^2_{\text{obs}} - \sigma^2_{\text{luck}}, \qquad \text{luck share} = \frac{\sigma^2_{\text{luck}}}{\sigma^2_{\text{obs}}}$$
The number of games after which a record is half skill is $k_{\text{games}} = 0.25 / \sigma^2_{\text{true}}$, the same "half signal" idea as D.4.
Use when you judge how much a league table, a captain's record or a model's accuracy can tell you. Don't read a high luck share as "results are random". It means a single season can't separate teams whose true strengths are this close. Don't forget the schedule: in internationals, strong teams play weak ones more often, so this simple version understates skill (Chapter 24).
Example (IPL 2008–26; crease.uncertainty.luck_share):
166 team-seasons, mean 14.7 decided games
SD of win%: observed 13.7 pts, luck alone 13.1, true 4.0 -> luck share 92%; a record is half skill after 159 games
This reproduces Chapter 6. An IPL team would need about 159 decided games, more than ten seasons with an unchanged squad, before its record was even half skill.
In the book. Chapter 6: men's full-member T20Is have a luck share of 59%. Chapter 14: luck explains 64% of the career spread in wickets above expected in the IPL and 40% in women's T20Is. Chapter 24 turns the luck share into a ceiling. With an IPL luck share of 0.916 and a true-strength SD of 0.040, a model that knew every team's true strength would call only 54.3% of IPL matches. That is why Elo's 47.6% (D.19) is less shocking than it looks.
D.9 Simpson's paradox and direct standardisation
The idea. A player can be better in every subgroup and still worse overall, because the two players' records are spread across the subgroups in different proportions. Direct standardisation removes the paradox by putting everyone on a common mix.
Formula. With subgroup rates $r_{j}$ and a common set of weights $w_j$ (summing to 1):
$$\text{standardised rate} = \sum_j w_j r_j$$
The pooled rate uses the player's own weights, so the comparison mixes skill with role.
Use when groups have very different mixes of phases, venues, oppositions or eras. Don't standardise to a mix nobody plays. A finisher standardised to the league's phase mix is a hypothetical player, so report both numbers and say which question each answers.
Example (IPL career strike rates by phase; crease.uncertainty.standardise):
SR ball share %
phase powerplay middle death powerplay middle death
batter
RG Sharma 126.43 122.51 181.14 36.8 47.9 15.3
MS Dhoni 81.94 100.47 174.97 1.8 48.1 50.1
overall SR: RG Sharma 132.92, MS Dhoni 137.45
league ball mix %: powerplay 31.3, middle 46.2, death 22.5
standardised to the league mix: RG Sharma 136.9, MS Dhoni 111.4
Rohit is faster in every phase, yet Dhoni's overall rate is higher because half his balls came at the death. On a common mix, Rohit leads 136.9 to 111.4, exactly Chapter 6's figures. Chapter 6 rounds the league mix as 31.4 / 46.1 / 22.5; the standardised values agree to the decimal place.
In the book. Chapter 4: Bumrah was cheaper than Ashwin in every IPL phase but dearer overall (7.34 v 7.20), and the data hold 40 such bowler pairs. Chapter 6: Younis Khan beats Williamson in Test averages both home and away but trails overall, because Pakistan's "home" Tests were played in the UAE (a neutral venue in the toolkit). Anchor C (Rohit's ODI average of 58.46 in wins v 36.01 in losses) is a cousin of the same problem, selection on the outcome, treated in Chapters 1, 4 and 6.
Part III — Testing claims
D.10 Hypothesis tests and multiple comparisons
The idea. A hypothesis test asks: if there were no effect, how surprising would data like these be? The answer is the p-value. Test many things and some will look surprising by chance. A multiple-comparison correction raises the bar to match. Bonferroni is the simplest: with $m$ tests, require $p < \alpha/m$.
Formulas. For $k$ successes in $n$ trials against a null probability $p_0$, the exact binomial test sums the probabilities of outcomes at least as extreme as $k$. The normal approximation is
$$z = \frac{\hat p - p_0}{\sqrt{p_0(1-p_0)/n}}$$
$$\text{Bonferroni:}\quad \text{reject } H_j \text{ if } p_j < \frac{\alpha}{m}, \qquad \text{expected false positives with no effects anywhere} = m\alpha$$
Other tests in the book: Fisher's exact test (2×2 tables), the log-rank test (survival curves, D.16), a permutation test (shuffle the labels, recompute the statistic), and Wald tests on regression coefficients (D.12).
Use when you have a pre-stated question and a null worth rejecting. Don't test a hypothesis you found by looking at the same data. Chapter 10 flags its Root conversion split (Fisher p 0.0027) as post hoc for exactly this reason. Don't read p > 0.05 as "no effect". Check the interval and the power (D.11). Don't forget the hidden tests: every system, filter or subgroup you tried counts toward $m$.
Example. Does the toss winner win more often? Decided matches in 18 limited-overs competitions, internationals between full members only:
decided toss_won pct p p<0.05 Bonferroni p<0.0028
comp
psl 350 205 58.5714 0.0016 True True
t20s_female 687 378 55.0218 0.0094 True False
ilt 132 78 59.0909 0.0449 True False
cpl 436 238 54.5872 0.0617 False False
bbl 647 343 53.0139 0.1351 False False
ipl 1218 628 51.5599 0.2891 False False
...
odis_male 1965 976 49.6692 0.7866 False False
lpl 137 67 48.9051 0.8644 False False
hnd 375 189 50.4000 0.9178 False False
pooled: 5,649 of 11,050 = 51.1%; 3 of 18 below 0.05 (expected by chance 0.9); 1 survive Bonferroni
PSL exact 95% CI for the toss winner's win rate: 53.2–63.8%
This reproduces Chapter 22: toss winners won 51.1% of 11,050 decided matches, and only the PSL (58.6%) survives Bonferroni. Three nominal "significant" results against 0.9 expected by chance is mild evidence that something is going on somewhere. Bonferroni then says where we can be confident. The toss is randomised, so a toss effect is causal. The decision after the toss is not randomised (D.25).
In the book. Chapter 16: dot-ball "pressure" does not raise the next-ball wicket odds (OR 0.848 per +10 striker dots, controlled). Chapter 22: IPL captains field 14.4 points more often in evening games (p 0.0013), yet evening chasers win less. Chapter 35 shows multiple comparisons at their most expensive: the top 10 of 115 IPL "systems" returned +57.0% in sample and −16.1% out of sample.
⚠️ Common pitfall: the garden of forking paths. You don't have to run 18 formal tests to have a multiple-comparisons problem. Trying three filters, two eras and a different minimum-balls cut, and reporting the one that "worked", is the same thing. Write the analysis plan down first, or confirm on data you didn't explore.
D.11 Power: how many matches or bets before an effect is visible?
The idea. Power is the chance a study detects an effect that is really there. Small effects need enormous samples. In cricket, the sample you want often doesn't exist.
Formulas. Sample size for a one-sample proportion test (two-sided $\alpha$, power $1-\beta$, true $p_1$ against null $p_0$):
$$n = \left(\frac{z_{1-\alpha/2}\sqrt{p_0(1-p_0)} + z_{1-\beta}\sqrt{p_1(1-p_1)}}{p_1 - p_0}\right)^2$$
For a betting edge $e$ per unit staked at decimal odds $o$, with win probability $p = (1+e)/o$, the per-bet SD of returns is $o\sqrt{p(1-p)}$. To be $z$ standard errors from zero you need
$$n \approx \left(\frac{z \cdot o\sqrt{p(1-p)}}{e}\right)^2$$
Use when you plan a study, or judge whether a null result means anything. Don't run a study you can't power and then report "no effect". Report the interval instead.
Example (crease.betting.bets_needed and the formula above):
edge 2% at evens (decimal 2.0): ~9,601 bets for a 1.96-SE result
edge 5% at evens (decimal 2.0): ~1,533 bets for a 1.96-SE result
edge 10% at evens (decimal 2.0): ~381 bets for a 1.96-SE result
a true toss edge of 52% needs ~4,903 decided matches for 80% power, two-sided 5% (IPL has 1,218)
Chapter 35's figure: a 5% edge at evens needs about 1,533 bets, roughly 21 IPL seasons of one bet per match. The second line explains Chapter 22's IPL toss result. The IPL's 51.6% (48.8–54.4) cannot distinguish "no effect" from a real two-point edge. The whole competition is a quarter of the sample needed.
Part IV — Predicting, and checking the predictions
D.12 Logistic regression
The idea. Model the log-odds of a yes/no outcome (win, wicket, chase successful) as a straight line in the predictors. The output is a probability between 0 and 1. Each coefficient is the change in log-odds per unit of its predictor, and its exponential is an odds ratio.
Formulas.
$$\log\frac{p}{1-p} = \beta_0 + \beta_1 x_1 + \dots + \beta_q x_q, \qquad p = \frac{1}{1 + e^{-(\beta_0 + \beta^\top x)}}$$
Fitted by maximum likelihood, which is the same as minimising log loss (D.13). $e^{\beta_j}$ is the odds ratio for +1 unit of $x_j$.
Use when the outcome is binary and you want calibrated probabilities with interpretable effects. Logistic regression is the book's default win-probability engine. Don't expect it to capture interactions or thresholds you didn't give it: add terms (Chapter 20 uses log terms and interactions of runs needed, balls left and wickets). Don't read coefficients causally when the predictors were chosen by captains (D.25).
Example. P(chaser wins | target) in the IPL, fit on 2008–22, tested on 2023–26. Model 2 measures the same first-innings total against its scoring environment: the mean of the previous 60 IPL first-innings totals, using only past matches.
fit = sm.Logit(tr["y"], sm.add_constant((tr["total"] + 1 - 160) / 20)).fit()
fit2 = sm.Logit(tr["y"], sm.add_constant((tr["total"] - tr["env"]) / 20)).fit()
train 893 matches (chasers won 54.6%), test 282 (chasers won 52.8%)
Coef. Std.Err. P>|z|
const 0.3726 0.0769 0.0
target_z -0.7076 0.0621 0.0
odds ratio per +20 runs of target: 0.493
P(chaser wins): target 160: 0.592, target 180: 0.417, target 200: 0.261, target 220: 0.148
model 2: the same total measured against its scoring environment (previous 60 IPL first innings):
Coef. Std.Err. P>|z|
const 0.2421 0.0748 0.0012
rel_env_z -0.7126 0.0624 0.0000
Every extra 20 runs of target roughly halves the chaser's odds (OR 0.493). The test set shows (D.13) that the absolute-target model is badly wrong after 2023, because a target of 200 no longer means what it did in the higher-scoring Impact Player era. Model 2 carries the same information in relative terms and transfers across eras. This is a miniature of Chapter 20's central finding: the env_par feature beats an era flag.
In the book. Chapter 20: WP v1 is a logistic regression on state + target + environment + Elo gap. Chapter 14: the context-only expected-wickets (xW) model has an out-of-fold AUC of 0.617. Chapter 16: the pressure test. Chapter 22: IPL chase ~ toss + home + era (home OR 1.19, p 0.015; pseudo-R² 0.0046). Chapter 13: runs per win from a match-level logistic (D.23). Chapter 24: the pre-match bake-off (logistic, random forest and XGBoost tie).
D.13 Scoring rules and calibration
The idea. A probability forecast should be judged by a proper scoring rule, one you can't game by hedging. The book uses two: the Brier score (mean squared error of the probability) and log loss (it punishes confident mistakes hardest). Calibration asks a separate question: when the model says 70%, does it happen 70% of the time? A reliability table (or curve) bins the forecasts and compares forecast with outcome.
Formulas. For forecasts $p_i$ and outcomes $y_i \in$ {0, 1}:
$$\text{Brier} = \frac{1}{N}\sum_i (p_i - y_i)^2, \qquad \text{log loss} = -\frac{1}{N}\sum_i \big[y_i \log p_i + (1-y_i)\log(1-p_i)\big]$$
Reference points: a coin (always 0.5) scores Brier 0.2500 and log loss 0.6931. The Murphy decomposition over forecast bins $j$ (with $\bar y$ the overall rate) is
$$\text{Brier} \approx \text{REL} - \text{RES} + \text{UNC}$$
$$\text{REL} = \sum_j w_j (\bar p_j - \bar y_j)^2, \qquad \text{RES} = \sum_j w_j (\bar y_j - \bar y)^2, \qquad \text{UNC} = \bar y(1-\bar y)$$
Reliability (REL) is the calibration error, so lower is better. Resolution (RES) is how far the bins' outcomes spread from the base rate, so higher is better. Uncertainty (UNC) depends only on the outcomes.
Calibration slope and intercept: regress $y$ on $\text{logit}(p)$ with a logistic model. Perfect calibration gives intercept 0 and slope 1. A slope below 1 means overconfident forecasts, and an intercept above 0 means the event happens more often than forecast.
Use when you evaluate any probability: win probability, match odds, fantasy "top scorer" chances. Don't use accuracy (did the favourite win?) as the only score. It ignores confidence. Don't judge calibration on the training data.
Example (the two logistic models of D.12 on the 282 IPL test matches, 2023–26):
Brier log loss mean forecast − observed (pts)
model
coin (0.5) 0.2500 0.6931 -2.8369
base rate (train) 0.2495 0.6922 1.8104
logit: target 0.2285 0.6586 -16.3494
logit: target + env 0.1940 0.5712 -0.7646
reliability table, logit: target (test 2023–26)
n forecast observed
bin
(-0.001, 0.2] 84 0.117 0.286
(0.2, 0.3] 52 0.245 0.423
(0.3, 0.4] 31 0.352 0.484
(0.4, 0.5] 33 0.447 0.667
(0.5, 0.6] 31 0.551 0.742
(0.6, 0.7] 22 0.643 0.864
(0.7, 0.8] 14 0.733 0.857
(0.8, 1.0] 15 0.874 0.800
calibration intercept +0.769, slope 0.868 (perfect: 0, 1); binned Brier parts: reliability 0.0307, resolution 0.0451, uncertainty 0.2492
reliability table, logit: target + env (test 2023–26)
n forecast observed
bin
(-0.001, 0.2] 30 0.131 0.100
(0.2, 0.3] 33 0.255 0.273
(0.3, 0.4] 38 0.353 0.368
(0.4, 0.5] 36 0.452 0.556
(0.5, 0.6] 34 0.551 0.529
(0.6, 0.7] 30 0.642 0.567
(0.7, 0.8] 34 0.754 0.824
(0.8, 1.0] 47 0.876 0.851
calibration intercept +0.042, slope 0.940 (perfect: 0, 1); binned Brier parts: reliability 0.0029, resolution 0.0587, uncertainty 0.2492
The absolute-target model under-forecasts chasers by 16 points on average, and in almost every bin. Its intercept of +0.769 says so in one number. Measuring the total against its environment cuts the reliability term tenfold (0.0307 → 0.0029) and raises resolution. That makes a simple point: a better-calibrated model is not necessarily a vaguer one.
In the book. Chapter 9: WP v0 scores Brier 0.1252 out of time and underrates IPL chasers by 13.4 points. Chapter 20: WP v1 scores 0.1143, with reliability/resolution 0.0006/0.1328 against v0's 0.0011/0.1222. Calibration is that chapter's threshold concept. Chapter 24: pooled T20 calibration slope 0.796. Chapter 29: fourth-innings Test chases, simulator 0.3267 → 0.3178 with host weather, direct model 0.2996. Chapter 33: a "declaration-set target" flag takes Brier from 0.2996 to 0.2741. Chapter 35: the IPL Elo favourite scored Brier 0.2576, worse than a coin. Chapter 36: P(top fantasy scorer) Brier 0.0393 against 0.0400 for a uniform guess.
D.14 Train/test splits by match and by time; leakage
The idea. A model's real error is its error on data it has never seen, in the way it will be used. Leakage is any route by which information about the test outcome reaches training. In cricket the usual route is the match. Balls from the same innings share an outcome (the final total, the result), so splitting rows at random puts near-copies of each test match in the training set. The cure is to split by match (whole matches in or out) and, for anything used to forecast, by time (fit on the past, test on the future).
Formulas. Notation for the three designs:
$$\text{random rows: } (i \in \text{train}) \perp \text{match}(i); \qquad \text{by match: } \text{match}(i) \in M_{\text{train}} \text{ or } M_{\text{test}}; \qquad \text{by time: } \text{date}(i) < t_0 \le \text{date}(j)$$
In scikit-learn, use GroupShuffleSplit / GroupKFold with groups=match_id, or a date cut.
Use when you evaluate any model, always. Don't compute features from the whole dataset (season averages, "career" ratings, scaling constants) and then split. Every feature must be computable as of the moment of prediction ("past-only", shift(1)). Don't tune on the test set.
Example. Predict an IPL first innings' final total from every legal-ball state (2015–26). We add one innocent-looking match-level feature: env, the past-only scoring environment. It is constant within a match and almost unique to it, so it acts as a match identifier.
90,203 ball states from 763 innings; target = the innings' final total
features: legal, score, wkts
split model train MAE test MAE
random rows (LEAKS) random forest 12.52 17.18
random rows (LEAKS) linear 16.76 16.85
by match random forest 12.62 17.52
by match linear 16.87 16.44
by time (<2023 | 2023+) random forest 11.61 21.41
by time (<2023 | 2023+) linear 15.61 19.69
features: legal, score, wkts, env
split model train MAE test MAE
random rows (LEAKS) random forest 2.07 5.37
random rows (LEAKS) linear 16.51 16.59
by match random forest 1.45 18.34
by match linear 16.66 16.02
by time (<2023 | 2023+) random forest 1.73 21.93
by time (<2023 | 2023+) linear 15.61 19.68
With the match identifier available, the random forest looks brilliant on a random split (5.4 runs). It has memorised which match ends where. Split by match and it is worse than a straight line (18.3 v 16.0). Split by time and both models get worse again, because 2023–26 scoring is higher than anything in training (D.15). The linear model can't memorise, so it barely notices the leak. Leakage hurts flexible models most.
In the book. Chapter 20's version is starker: the same flexible model scored Brier 0.0185 on a random-ball split and 0.1933 split by match. Chapter 14 and Chapter 15 catch leakage from the simulated tracking layer: xW AUC 0.648, and an LBW model AUC 0.823 that falls to 0.503 with shuffled labels. Chapter 35: a backtest that peeked at the season's final table returned +37.0% against +10.1% honestly. Chapter 24 flags announced IPL XIs since 2023 (12 names including the Impact substitute) as a small leak. Chapter 25 and Chapter 26 fit every constant on seasons before the target.
D.15 Gradient boosting, and why trees don't extrapolate
The idea. Gradient boosting builds a forecast from hundreds of small decision trees, each fitted to the errors of the ones before. It captures interactions and thresholds automatically and is often the most accurate model on tabular data. But every tree predicts a constant within each leaf, and the leaves are defined by the training range. Beyond the largest value it has seen, a tree-based model predicts flat. When cricket changes (scoring inflation, new rules), that is a structural weakness.
Formula. After $M$ rounds with learning rate $\eta$:
$$F_M(x) = F_0 + \eta\sum_{m=1}^{M} h_m(x), \qquad h_m \text{ fitted to the residuals (negative gradient) of } F_{m-1}$$
Each $h_m$ is piecewise constant, so $F_M$ is piecewise constant too. It is flat outside the convex hull of the training $x$.
Use when relationships are non-linear, interactions matter, and the future looks like the past. Don't use it alone when the test data will sit outside the training range. Feed it relative features (a total against its environment) or pair it with a model that extrapolates. Don't assume flexibility means accuracy. Tune depth and leaf size inside the training years, as Chapter 20 does.
Example. Predict an IPL first-innings total from the powerplay score (one wicket down), training on 2008–22:
train 2008–22: 927 innings; powerplay score max 84, 99th pct 75
test 2023–26: 284 innings; 10 above the training maximum
predicted final total, 1 wicket down after 6 overs:
score wkts linear gbm
40 1 161.6 165.2
50 1 171.1 172.3
60 1 180.6 190.9
70 1 190.2 208.1
80 1 199.7 195.9
90 1 209.2 200.5
100 1 218.8 200.5
110 1 228.3 200.5
125 1 242.6 200.5
all test innings n 284: mean error (forecast − actual) linear -16.6, gbm -18.8
PP score > 75 n 30: mean error (forecast − actual) linear -27.0, gbm -38.4
Above 90 the boosted model predicts 200.5 whatever the powerplay score: 100/1 and 125/1 get the same forecast. Both models under-forecast the 2023–26 era (D.14), but on the 30 innings with record powerplays the tree model misses by 38 runs against the line's 27.
In the book. Chapter 20: a GBM with WP v1's features scored Brier 0.1191 against the logistic 0.1143, and its chase probabilities flatten beyond an environment of about 173 (the 99th percentile of pre-2023 training was 172.7). That is the 🔍 "why trees can't extrapolate" box. Chapter 24: with only Elo, team-sheet strength and home as inputs, tuning picks depth-1 trees and XGBoost ties logistic regression.
Part V — Time, state and sequence
D.16 Survival analysis: Kaplan–Meier, log-rank and Cox
The idea. "How long does an innings last?" is a survival question, and not-out innings are censored: we know the batter lasted at least that long, not how long he would have lasted. Dropping not-outs, or treating them as dismissals, biases the answer. The Kaplan–Meier estimator uses every innings correctly.
Formulas. At each ball count $t_j$ where dismissals happen, with $d_j$ dismissals among $n_j$ innings still alive:
$$\hat S(t) = \prod_{t_j \le t}\left(1 - \frac{d_j}{n_j}\right)$$
The hazard $h(t)$ is the dismissal probability on the next ball given survival so far. The log-rank test compares two survival curves. Cox regression models covariates multiplicatively on the hazard, $h(t \mid x) = h_0(t) e^{\beta^\top x}$, so $e^{\beta_j}$ is a hazard ratio.
Use when the outcome is a duration with censoring: balls survived, overs to the next wicket, partnership length. Don't compute "share of innings reaching 100 balls" naively when many innings are not out. Don't read a Cox hazard ratio as constant over the innings without checking. Hazards in cricket fall sharply once a batter is set (Chapter 10's hazard tables).
Example (men's Tests, crease.test_batting.km_summary built on lifelines):
innings dismissals median_balls P(>=50) P(>=100) P(>=200)
batter
KS Williamson 195 176 69.0 0.575 0.371 0.165
SPD Smith 227 199 68.0 0.610 0.358 0.168
JE Root 309 283 57.0 0.543 0.336 0.098
M Labuschagne 123 114 56.0 0.559 0.304 0.083
V Kohli 210 197 58.0 0.547 0.300 0.121
Smith naive share of innings reaching 100 balls 0.313 (227 innings, 28 not out) v Kaplan–Meier 0.358
log-rank Smith v JE Root: p = 0.097
log-rank Smith v V Kohli: p = 0.067
This reproduces Chapter 10's survival table. The naive share undercounts Smith by 4.5 points because 28 of his innings ended not out, some of them short of 100 balls. Neither log-rank test clears 0.05. The curves differ, but not decisively on these samples. (Chapter 10 reports Smith v Kohli as p 0.068; this run gives 0.067, a rounding difference.)
In the book. Chapter 10: hazard by balls faced (1.719% per ball over the first 10 balls → 1.198% at 80–89), no "nervous nineties", and a Cox model with hazard ratios away 1.091, third innings 1.212 and fourth innings 1.275 (concordance 0.532). Chapter 5: half of top-order Test innings end within 41 balls.
D.17 Markov chains and expected-runs tables
The idea. Treat an innings as moving through states (balls left $u$, wickets in hand $w$). From each state, the next ball leads to another state with some probability: a dot, a single, a four, a wicket. That is a Markov chain, and it rests on one assumption: the future depends on the present state, not on how you got there. The expected-runs (ER) table gives the average runs still to come from each state. Counted directly from data, it is noisy in rare states. Computed from the chain by backward recursion, it is smooth everywhere.
Formulas. Expected runs to come satisfies the recursion over outcomes $o$ with probabilities $P_o(u, w)$:
$$ER(u, w) = \sum_o P_o(u,w)\Big[r_o + ER\big(u - \ell_o,\ w - d_o\big)\Big], \qquad ER(0, w) = ER(u, 0) = 0$$
where $r_o$ is the runs, $\ell_o$ = 1 for a legal ball (0 for a wide or no-ball) and $d_o$ = 1 for a wicket. From the table:
$$\text{value of a ball} = \text{runs} + ER(\text{after}) - ER(\text{before}), \qquad \text{price of a wicket} = ER(u-1, w) - ER(u-1, w-1)$$
Win probability added (WPA) is the same bookkeeping with a win-probability table in place of ER. Leverage is the win probability per run at a state (Chapter 31).
Use when you value a ball, a wicket or a decision by the state it leaves behind. Don't forget what the Markov assumption drops: the batters' identities, the pitch, and the innings' own scoring environment. Chapter 19's chain rebuilt the right mean but too narrow a spread until each innings was given its own "tilt". Don't use a table from one era for another. IPL par moved from 163.4 to 190.3.
Example (men's T20 pool, complete first innings; crease.states):
8,917 complete first innings; mean total 159.5, SD 38.3
counted expected runs still to come after 10 overs, by wickets lost:
wkts_lost 0 1 2 3 4 5 6 7
n 460.0 1580.0 2508.0 2285.0 1284.0 516.0 183.0 62.0
mean 100.2 96.7 91.7 84.7 76.8 62.8 52.0 39.0
Markov chain (exact backward recursion): par from ball 1 = 159.4; after 10 overs: 0 down 105.2, 2 down 91.9, 4 down 73.6
value of a wicket at 10 overs, 2 down: ER(60, 8 left) − ER(60, 7 left) = 8.2 runs
These are Chapter 19's base numbers: par 159.5, chain par 159.4, and the raw 10-over, 0-down cell of 100.2 (the book's smoothed, anchored table shows 99.4). Note how few innings reach the 7-down cell (62). That is why the chapter blends the counted table with the chain.
In the book. Chapter 9: WP v0 is an empirical lookup table. At Newlands (Anchor A) it gives Sri Lanka 0.649 at 116/2 and 0.246 at 118/4, and Imran Tahir's bowling WPA is +0.525. Chapter 19: the ER table, the chain, run values and Expected Runs Added (Klaasen +279.7 batting, Bhuvneshwar Kumar +212.5 bowling, IPL 2023–26 first innings). Chapter 20: WP v1 and WPA (Prasanna +0.573, Tahir +0.462). Chapter 31: leverage weights of powerplay 0.73, middle 0.87, death 1.55 and over 20 2.29. Chapter 27 uses the chain as a ball-by-ball simulator for live score projection and milestone probabilities. Chapter 30 replaces the "wickets lost" index with batter identities, giving each batter his own outcome probabilities by phase. See D.27.
D.18 Resource functions (the Duckworth–Lewis form)
The idea. A side's resources are its remaining overs and wickets, combined into one number: the share of a full innings' expected runs still available. Duckworth and Lewis (1998) proposed a functional form for expected further runs. A resource table is that function divided by its value at the start.
Formulas (the published two-factor form, with parameters fitted to this book's data):
$$Z(u, w) = Z_0 F(w)\Big[1 - e^{-b u / F(w)}\Big], \qquad F(0) = 1$$
$$R(u, w) = 100 \times \frac{Z(u, w)}{Z(N, 0)}$$
where $u$ is overs left, $w$ wickets lost and $N$ the full allocation. A stoppage that takes overs away costs $R(\text{before}, w) - R(\text{after}, w)$. The public Standard-Edition target rules, with Team 1 score $S$ and resources $R_1$, $R_2$:
$$\text{if } R_2 < R_1: \ \text{par} = S \cdot \frac{R_2}{R_1}; \qquad \text{if } R_2 > R_1: \ \text{par} = S + G \cdot \frac{R_2 - R_1}{100}; \qquad \text{target} = \lfloor \text{par} \rfloor + 1$$
Use when you need a fair target after lost overs, or a currency for "how much innings is left". Don't reproduce or claim the ICC's Professional Edition. Its tables are not public, and Chapter 23 fits its own. Don't use a 50-over shape for T20 without checking. The chapter found the re-based ODI table within 2.2 resource points of a T20 table on average, but up to 8 off after early wickets.
Example (men's ODIs between full members, 2002–26; crease.resources):
1,726 complete innings; Z0 = 306.4, b = 0.0377; weighted RMSE 2.50 runs, R² 0.9988
F(w) for w = 0..9: 1.000, 0.851, 0.744, 0.596, 0.482, 0.364, 0.269, 0.173, 0.100, 0.041
resources remaining (% of a full 50-over innings):
wkts_lost 0 2 4 6
overs_left
50 100.0 80.8 55.7 31.6
40 91.8 76.2 54.4 31.6
30 79.8 68.5 51.4 31.2
20 62.4 55.9 44.9 29.8
10 37.0 34.9 30.8 23.9
Sydney 1992 on this table: R1 96.3%, resources lost 7.57 pts -> target 233 (South Africa on 231 need 2 off 1 ball)
This reproduces Chapter 23's fit exactly. At the 1992 World Cup semi-final the scoreboard famously showed 22 needed off 1 ball, under the most-productive-overs rule. This book's resource table would have asked for 2.
In the book. Chapter 23: the T20 fit (b 0.0532), ODI resources moving only 1.15 points between eras while totals rose 20.4 runs, and the book's tables setting targets higher than the official ones in 95.7% of 70 clean comparisons (median +6 runs). Chapter 19: the two IPL eras differ by 11.0 runs per state but only 1.2 resource points. Resources travel between eras; runs don't.
D.19 Elo ratings
The idea. Every team carries a rating. Before a match, the rating gap gives a win probability. After it, both ratings move by $K$ times the surprise (result minus expectation). The system is self-correcting, needs only results, and every forecast uses only past matches.
Formulas.
$$P(A \text{ beats } B) = \frac{1}{1 + 10^{-(R_A - R_B + H)/400}}, \qquad R_A' = R_A + K\big(S_A - P\big), \qquad R_B' = R_B - K\big(S_A - P\big)$$
$H$ is a home advantage in rating points (+H for the home side). $S_A$ is 1 for a win, 0 for a loss and 0.5 for a tie (or draw). Between seasons, optionally regress each rating a fraction $\lambda$ of the way to the mean, because franchise squads change. Tune $K$, $H$ and $\lambda$ by log loss on years before the test period.
Use when you want a strong, transparent pre-match baseline, the yardstick every richer model must beat. Don't expect much where true strengths are close: see the IPL below and D.8. Don't confuse Elo with the ICC rankings, which use a points-average system (described in Chapter 24; it forecasts about as well as Elo).
Example (crease.match_model.elo_history; the tuned settings of Chapters 24 and 35):
ipl: K 10, home 50, season regress 0.25: favourite won 47.6% of 286; Brier 0.2576, log loss 0.7085; median favourite p 0.560
t20s_male (full members): K 20, home 25, season regress 0.0: favourite won 64.1% of 323; Brier 0.2219, log loss 0.6369; median favourite p 0.645
worked update: 1600 v 1500 -> P = 0.640; if the underdog wins with K = 20 the ratings move 12.8 points each way
Both lines reproduce Chapter 35 and Chapter 24 exactly. Out of time, the IPL Elo favourite won less than half the time. Full-member men's T20Is behave the way the "60–65%" folklore suggests. The difference is the luck share (D.8), not a bug.
In the book. Chapter 24: Elo by competition, 2023–26 out of time. Men's ODIs 61.2%, women's T20Is 71.9%, women's ODIs 72.9%, decided Tests 67.7% (Tests K 60, home 150, plus a draw model). Announced XIs add almost nothing. Chapter 20 feeds the Elo gap into WP v1 (walk-forward, K 20). Chapter 28 uses Elo-style pre-match probabilities as the engine of a tournament simulator (D.27). Chapter 35: the illustrative bookmaker in backtests is walk-forward Elo plus a 5% margin.
Part VI — Projection
D.20 Marcel projections
The idea. The name is borrowed from Tom Tango's deliberately simple baseball projection system, "Marcel". Forecast next season as a weighted average of the last three seasons (recent seasons count more), shrunk toward the league by a fixed number of balls, adjusted for aging if you have it. Its value is as a benchmark. Anything fancier has to beat it out of time.
Formulas. For a player with seasons $Y-1, Y-2, Y-3$ (index values $x$, balls $n$) and weights 5/4/3:
$$\bar x_w = \frac{5 n_1 x_1 + 4 n_2 x_2 + 3 n_3 x_3}{5 n_1 + 4 n_2 + 3 n_3}, \qquad n_{\text{eff}} = \frac{5 n_1 + 4 n_2 + 3 n_3}{5}$$
$$\hat x_Y = \frac{n_{\text{eff}} \bar x_w + k \mu}{n_{\text{eff}} + k}$$
In this book $x$ is an index against par inside its competition, year and phase (SR+, out+, econ+), so league inflation doesn't leak into the forecast. $k$ and $\mu$ are fitted on earlier target seasons and then frozen.
Use when you need a next-season forecast with honest intervals for any player with history. Don't use it across leagues without translation factors (D.22): Chapter 25's pooled, untranslated projections were biased by +4.5 SR+. Don't expect it to see a genuine leap (a teenager's breakout). Its job is to be right on average.
Example (crease.projection: fit on IPL target seasons 2011–18, test on 2019–26):
fitted k = 371 balls, prior 100.0
rmse mae n coverage
proj 13.37 10.00 619.0 0.8
last 19.63 13.55 619.0 NaN
career 17.86 12.27 619.0 NaN
league 14.13 10.59 619.0 NaN
This reproduces Chapter 25. Marcel beats "last season" by 6.3 SR+ points of RMSE, and its 80% intervals cover 80%. Simply predicting league par (14.13) beats last season (19.63), and beats the raw three-season record too. That is regression to the mean at work (D.5).
In the book. Chapter 25: all 36 weightings land between 13.35 and 13.52, so the amount of regression matters and the weights barely do. Bowling economy is projectable (k ≈ 487 legal balls), but wickets are not (k ≈ 3,204; Marcel equals par at 32.7). Suryavanshi's 2027 projection is SR+ 125.7 (113.2–138.1) after 151.8 in 2026. Chapter 34 runs the projection for auction value (k = 28 matches). Chapter 36 runs it pre-season for fantasy simulations.
D.21 The delta method for aging
The idea. To learn how players change with age (or career year), you can't just average everyone's performance at each age. Only the good players survive to age 34, so the old-age average is flattered. That is survivor bias. The delta method instead uses each player's change between consecutive years, averages those changes at each step, and chains them into a curve. Every pair compares a player with himself.
Formulas. For each career year $c$, using players observed in both $c-1$ and $c$ (weighted, for example, by the harmonic mean of the two years' balls):
$$\Delta_c = \text{weighted mean over players of } \big(x_{i,c} - x_{i,c-1}\big), \qquad \text{curve}(c) = \sum_{j=2}^{c}\Delta_j$$
Use when you estimate aging or experience effects from observational careers. Don't forget that the delta method has its own bias. Players who had a lucky year are more likely to keep playing, and then regress (D.5), which pushes the curve down. Chapter 25 therefore also checks the residuals of a Marcel projection by career year. Don't claim an age curve without birth dates: Cricsheet's people register has none, so the book uses career year.
Example (men's T20 pool, batters whose first appearance in the data is 2010 or later; crease.projection.delta_curve):
players naive curve n_pairs
career_year
1 606 0.00 0.00 NaN
2 536 3.63 -1.72 216.0
3 539 3.78 -2.19 241.0
4 603 4.65 -3.16 282.0
5 518 4.20 -6.02 305.0
6 464 5.58 -6.11 274.0
7 432 4.59 -7.58 275.0
8 355 4.07 -10.16 257.0
9 328 5.98 -8.88 232.0
10 254 5.91 -10.20 180.0
after 9 career years: naive +6.0, delta method -8.9
The two methods disagree in sign. The naive curve rises because the batters still playing in year 9 are the good ones. The delta curve falls because returning players regress from their lucky seasons. Chapter 25 resolves it with projection residuals, which stay mostly within ±1.2 SR+ points across career years: in T20 batting, experience effects after Marcel are small.
D.22 League translation factors
The idea. An SR+ of 110 in the T20 Blast and one of 110 in the IPL are not the same achievement. The bowling is different. A translation factor is the exchange rate: the index a player who is average (100) in the reference league would post in another league. Estimate it from players who appear in both leagues, ideally in the same season, so ability is held fixed.
Formulas (Chapter 26's multiplicative model, with player-season fixed effects):
$$E[R_{ul}] = P_{ul} \times a_u \times f_l, \qquad f_{\text{ref}} = 1, \qquad \text{index in reference units} = \frac{\text{index in league } l}{f_l}$$
Here $R_{ul}$ is the runs of unit $u$ (one player in one season) in league $l$, $P_{ul}$ the runs a par batter would have made on the same balls, $a_u$ the unit's ability and $f_l$ the league factor.
Solved by alternating ratio-of-sums updates (the Poisson maximum-likelihood equations), with each $f_l$ shrunk toward 1 by 300 balls of pseudo-data. The naive alternative is a ratio of matched-pair means:
$$\hat f_l^{\text{naive}} = \frac{\bar s_l}{\bar s_{\text{ref}}}$$
where $\bar s_l$ and $\bar s_{\text{ref}}$ are the matched players' mean SR+ in each league, weighted by the harmonic mean of each player's two ball counts.
Use when you project a player into a league he hasn't played much of (auction scouting, overseas signings, domestic-to-IPL promotion). Don't use raw strike-rate ratios: they mix league strength with scoring environment (SA20's raw ratio is 0.956, its strength factor 1.076). Don't trust a factor built on few crossover players. Chapter 26's SMAT factor rests on 56 players, and the SMAT data end in December 2024.
Example (men's T20, 2021–26, IPL = 1; crease.translation):
naive matched pairs, Blast and IPL in the same year: 43 player-seasons; SR+ 106.7 v 102.2 -> factor 1.044
factor units players
league
t20i_assoc 1.337 260 153
bpl 1.176 171 98
sma 1.147 100 57
lpl 1.121 142 89
ntb 1.110 443 181
psl 1.084 275 126
sat 1.076 152 81
cpl 1.073 251 114
bbl 1.061 257 119
t20i_fm 1.051 699 273
ilt 1.048 190 116
mlc 1.037 155 82
hnd 1.032 366 149
ipl 1.000 376 147
translate: a Blast SR+ of 120 = 108.1 in IPL units; an associate-T20I SR+ of 120 = 89.8
This reproduces Chapter 26. The naive Blast factor (1.044) is well below the joint model's (1.110), because the handful of players good enough to play both leagues in one year are not a typical sample. The joint model uses every crossover in the network.
In the book. Chapter 26's backtest of IPL SR+ for 2019–26 is the proof: pooled untranslated history had a bias of +2.07 (RMSE 13.00), and translated history −0.04 (RMSE 12.86). Women's factors use WPL = 1 (WBBL 1.014, full-member T20Is 1.088, associate T20Is 1.670). Chapter 34 applies the factors to overseas and uncapped buys, and Chapter 36 to WPL projections.
Part VII — Value and decisions
D.23 Runs above replacement and runs per win
The idea. Value is measured against the player you'd get for nothing: replacement level, the kind of player available at the base price. Runs above replacement (RAR) counts a player's runs, net of the cost of his dismissals, above what a replacement would have made on the same balls. Runs per win converts runs to wins, and wins can then be priced in ₹.
Formulas (Chapter 13's batting version):
$$\text{net runs} = \text{runs off the bat} - \sum_{\text{dismissals}} v(\text{over}), \qquad \text{RAR} = \text{net} - (\bar r_{\text{league}} + \delta_{\text{repl}}) \times \text{balls}$$
$v(\text{over})$ is the run value of a wicket in that over, by era. $\delta_{\text{repl}}$ is the era-and-phase replacement offset: the 20th percentile of the true-talent distribution, estimated by method of moments (D.6), not a raw percentile.
$$\text{WAR} = \frac{\text{RAR}}{\text{runs per win}}, \qquad \text{runs per win} = \frac{1}{\partial P(\text{win}) / \partial \text{runs}}$$
The derivative is an average marginal effect from a match-level logistic regression of the result on the total (D.12).
Use when you compare contributions across roles and phases, or put a price on them. Don't mix currencies. Chapter 13's batting RAR and Chapter 21 / Chapter 34's all-skills RAR use different replacement levels. Pant's 2025 middle overs are −28.5 on one scale and 0.0 on the other. Don't treat a single season's RAR as talent. Shrink it (D.6).
Example (crease.valuation_batting):
runs per win, IPL 2022–26 (match level): 140.2; season-level check 96.1
replacement offsets (net runs per ball v league) and k by era × phase:
offset sd_true k
era phase
2008-22 death -0.179 0.247 62.767
middle -0.093 0.128 281.178
powerplay -0.073 0.101 644.966
2023-26 death -0.116 0.202 106.091
middle -0.102 0.151 255.343
powerplay -0.099 0.149 557.994
balls runs outs wicket_cost rar repl strike_rate balls_per_out rar_per_100
name phase
Aniket Verma middle 82 139 4 27.85 26.46 1.03 169.51 20.5 32.3
RR Pant middle 108 141 8 57.99 -28.52 1.03 130.56 13.5 -26.4
This is Anchor B exactly as Chapter 13 settled it. In the IPL 2025 middle overs, Pant (₹27 crore) is at RAR −28.5 and Aniket Verma (₹30 lakh) at +26.5. The caveats always travel with it: the gap did not persist in 2026, and Pant was the better death-overs batter in both seasons. The two runs-per-win methods disagree (140.2 v 96.1). Every WAR and rupee figure scales with that choice, but rankings don't.
In the book. Chapter 13: the market paid ₹35.7 crore per batting win above replacement, and Gill leads RAR for 2022–26 with 656. Chapter 21: all-skills RAR per match for IPL 2024–26, Kohli 14.2 and Narine 13.8. Chapter 34: ₹12.5 crore per win across all skills, and ₹27 crore for Pant needed 21.4 RAR per match.
D.24 Integer programming and the assignment problem
The idea. Many cricket decisions are allocations under rules: 20 overs to bowlers with a 4-over cap and no consecutive overs, 11 players to a squad with role and overseas limits, a fantasy XI under a budget. With yes/no decision variables, a linear objective and linear constraints, these are integer linear programmes (ILP), and solvers find the provable optimum. The assignment problem (one job per worker) is the special case the Hungarian algorithm solves quickly, but it can't express "not in consecutive overs".
Formulas (the bowling plan; $V_{b,o}$ is bowler $b$'s value in over $o$, $x_{b,o} \in$ {0, 1}):
$$\max \sum_{b,o} V_{b,o} x_{b,o} \quad \text{s.t.} \quad \sum_b x_{b,o} = 1 \ \text{for all } o, \qquad \sum_o x_{b,o} \le 4 \ \text{for all } b, \qquad x_{b,o} + x_{b,o+1} \le 1$$
In Python: scipy.optimize.milp (HiGHS) for the ILP, scipy.optimize.linear_sum_assignment for the assignment problem.
Use when a decision is a combination subject to hard rules, and the values are estimated well enough to be worth optimising. Don't optimise raw small-sample values. Shrink them first (D.6), or the optimiser chases noise. Chapter 31's raw phase records had an out-of-sample error of 1.765 against 1.053 for shrunk general skill. Don't present the optimum as certain. Report the cost of the plan you'd actually use against the optimum (Chapter 31's audit).
Example (Chapter 31's Mumbai Indians 2026 attack, using the chapter's published values per over by phase, rounded to two decimals; unweighted runs, no leverage):
Hungarian (4-over cap only): value 10.53 runs; 11 consecutive-over pairs (illegal)
MILP (cap + no consecutive overs): value 10.43 runs; status Optimization terminated successfully. (HiGHS Status 7: Optimal)
1:Ghaz 2:Boul 3:Chah 4:Boul 5:Chah 6:Boul 7:Bumr 8:Ghaz 9:Boul 10:Bumr 11:Ghaz 12:Bumr 13:Ghaz 14:Pand 15:Bumr 16:Pand 17:Chah 18:Pand 19:Chah 20:Pand
Bumrah's overs: 7, 10, 12, 15
Chapter 31 reports 10.56 (Hungarian, with the same 11 illegal pairs) and 10.45 (MILP) from unrounded values. The rounding accounts for the 0.02–0.03 differences. On unweighted runs, Bumrah's middle-overs value (1.62) is almost his death value (1.63), so the plan spends him in the middle. Weight the overs by leverage for a side defending a total (D.17), as Chapter 31 does, and the optimiser puts him in overs 14, 16, 18 and 20.
In the book. Chapter 21: an XI optimiser with role constraints (milp). Every IPL 2026 optimum uses exactly five bowlers, and the Impact Player rule halves the all-rounder premium (0.70 → 0.35 runs per match). Chapter 31: the bowling plan, the Bumrah question and the Anchor D overlay (planning around de Kock and Rickelton's off-spin weakness gains 3.62 runs). Chapter 36: fantasy lineups under role and credit constraints.
D.25 Difference-in-differences and natural experiments
The idea. To estimate the effect of a change (DRS arriving, a rule, a coach), compare the change in the treated group with the change in a comparison group over the same period. The comparison group's change stands in for what would have happened anyway. A natural experiment is any situation where something close to random assignment happened without anyone designing it. The coin toss is the cleanest one cricket has.
Formula.
$$\text{DiD} = \big(\bar y_{T,\text{after}} - \bar y_{T,\text{before}}\big) - \big(\bar y_{C,\text{after}} - \bar y_{C,\text{before}}\big)$$
Its key assumption is parallel trends: without the treatment, the two groups would have moved together. Check the pre-period trends. Get the interval by bootstrapping whole matches within each cell (D.3).
Use when a change hits one group and not another at a known date. Don't use a simple before/after with no comparison group: everything else that changed gets credited to your treatment. Don't treat a choice as a natural experiment. The toss is random, but the decision to bowl first is not (Chapter 22's "decision information value").
Example. Did DRS in India (from Rajkot, 9 November 2016) raise the LBW share of wickets? Men's Tests from 2010, India against elsewhere:
tests wkts lbw lbw_share_%
india after
False False 258 7953 1337.0 16.8
True 349 11255 1761.0 15.6
True False 29 882 208.0 23.6
True 46 1460 310.0 21.2
DiD = (India after − before) − (elsewhere after − before) = -1.2 pp; 95% bootstrap by match -5.1 to +2.7
This is Chapter 15's natural experiment: DiD −1.2 points, no detectable LBW rise. The chapter's bootstrap draws gave an upper bound of +2.6; this run's give +2.7. The interval is wide because India hosted only 29 Tests in the "before" window.
In the book. Chapter 21: Impact Player, with the top-order share of IPL overs bowled set against men's T20Is (a DiD of −14.7 points). Chapter 22: the toss as a randomised experiment, and chasers who chose to chase against those sent in (both 54.7% in the IPL). Chapter 23: matches shortened before the start as a natural experiment for resource tables (T20 innings scored 1.003× the T20 table's prediction). Chapter 10's England case study sets England's change from June 2022 against other full-member Tests over the same windows, and Chapter 33 tracks England's declarations across the same date.
D.26 Clustering
The idea. Clustering groups observations that resemble each other without being told the groups: delivery types from ball-tracking, batting styles from profiles. k-means assigns each point to the nearest of $k$ centres and moves the centres to the means. A Gaussian mixture model (GMM) allows soft membership and oval clusters. Choose $k$ with the silhouette score (k-means) or BIC (GMM), and with cricket sense.
Formulas.
$$\text{k-means: } \min_{C_1..C_k} \sum_{j=1}^{k}\sum_{i \in C_j} \lVert z_i - c_j \rVert^2, \qquad \text{silhouette}(i) = \frac{b_i - a_i}{\max(a_i, b_i)}$$
where $a_i$ is the mean distance to $i$'s own cluster and $b_i$ the mean distance to the nearest other cluster. Standardise features first ($z$-scores), or the feature with the biggest units dominates.
Use when you want to describe structure, find comparable players, or label delivery types. Don't treat clusters as real categories when the silhouette is low. Continuous variation always "clusters" into whatever $k$ you ask for. Don't cluster on outcomes and then "discover" that clusters differ in outcomes.
Example (IPL 2023–26 batters with 300+ balls; features: dot %, boundary-ball %, balls per dismissal, share of balls in the powerplay and at the death):
k = 2: silhouette 0.307
k = 3: silhouette 0.280
k = 4: silhouette 0.241
k = 5: silhouette 0.230
k = 6: silhouette 0.261
75 batters; cluster profiles (k = 3):
dot_pct boundary_ball_pct balls_per_out pp_share death_share strike_rate n
cluster
0 30.7 20.4 27.2 32.4 16.6 151.5 20
1 33.2 20.3 18.7 9.4 36.3 151.9 31
2 37.3 24.5 19.4 57.5 4.5 158.0 24
cluster 0: V Kohli, Shubman Gill, B Sai Sudharsan, KL Rahul, JC Buttler, H Klaasen
cluster 1: S Dube, N Pooran, R Parag, Dhruv Jurel, RK Singh, MP Stoinis
cluster 2: YBK Jaiswal, P Simran Singh, Ishan Kishan, RG Sharma, AM Rahane, Abhishek Sharma
Three recognisable roles emerge: anchors who rarely get out, middle- and lower-order finishers, and powerplay attackers who accept more dots for more boundaries. The silhouettes (0.23–0.31) are low, though. These are regions of a continuum, not species, and the borderline cases (Klaasen with the anchors) show it.
🧪 Simulated data: Chapter 15's delivery clustering (k-means and GMM on pitch length, line and speed) runs on the toolkit's simulated tracking layer: real outcomes, simulated locations. It teaches the method. Its clusters are not facts about real bowlers. A franchise with the real Hawk-Eye feed would cluster real release and bounce data the same way.
D.27 Monte Carlo simulation
The idea. When a quantity is too tangled for a formula (a total after 10 more overs of random events, a champion after a league and three playoff rounds, the best batting order among millions), simulate it. Draw the random events from a model, play the thing out thousands of times, and count. Accuracy improves with the square root of the number of runs, and the model behind the draws matters far more than the number of runs.
Formulas. For an outcome $Y$ from $N$ independent simulations:
$$\hat P(Y \in A) = \frac{1}{N}\sum_{s=1}^{N} \mathbf{1}\big[Y^{(s)} \in A\big], \qquad \text{SE} = \sqrt{\frac{\hat P(1-\hat P)}{N}}$$
At $N$ = 10,000 a probability near 0.5 is good to about ±1 point (95%). Rare events need more runs, or importance sampling.
Use when outcomes depend on sequences, rules and interactions: innings, matches, tournaments, bankrolls. Don't trust a simulator you haven't checked against reality: compare its spread with the real spread (Chapter 19's chain was too narrow until innings got their own scoring environment) and backtest it out of time. Don't report more decimals than the model deserves.
Example 1: an innings (IPL 2023–26 Markov chain from D.17, with innings tilt 0.04, 10,000 simulations each):
IPL 2023–26 chain, 91/1 after 10 overs, 10,000 sims: median 204, 80% range 180–230, P(200+) 59.5%
IPL 2023–26 chain, 91/5 after 10 overs, 10,000 sims: median 170, 80% range 139–194, P(200+) 6.2%
Chapter 19's hook reported medians of 204 and 170 for these states, with 180–231 and P(200+) 59.8% from 91/1. The small differences come from the chapter's exact fitting run. Four wickets at the halfway mark cost about 34 runs of median.
Example 2: a league (pure simulation):
🧪 Simulated data: Eight hypothetical teams whose true win probabilities against an average side are drawn with SD 0.040, the IPL's true-strength spread from Chapter 24. They play a double round robin (14 games each) and then the IPL playoffs: Qualifier 1, Eliminator, Qualifier 2, Final. Match probabilities come from the log5 rule. No real team is modelled.
SIMULATED league, 20,000 seasons: the truly best team tops the table 23.7%, wins the title 22.7%, misses the playoffs 32.1% (a random team wins 12.5%)
With strengths as close as the IPL's, the best team wins the title less than a quarter of the time and misses the playoffs nearly a third of the time. That is the quantitative content of Theme 6: variance is not failure.
In the book. Chapter 14: Bumrah's 4 wickets against 14.78 expected in IPL 2026 is a ≤4-wicket season in about 0.06% of simulations. Chapter 27: a ball-by-ball innings simulator for live score projection and fifty/hundred probabilities, with its real error measured after 6, 10 and 15 overs. Chapter 28: 10,000+ simulations of real tournaments (the IPL 2026 league and playoffs, a men's T20 World Cup) from pre-tournament match probabilities, with in-tournament updating. Chapter 29 and Chapter 33: Test session and fourth-innings simulators for declarations. Chapter 30: batting-order search. Each candidate order is scored by simulating innings with player-specific outcome probabilities by phase, and the permutations are pruned so the search stays feasible. Chapter 32: field-placement optimisation, choosing fielder positions to minimise expected runs against a batter's (simulated) shot-zone distribution and comparing attacking and defensive fields by win probability. Chapter 36: fantasy-points simulation (Kohli before the 2026 final: mean 87.2, p90 194) and a simulated contest field. Chapter 35: bankroll paths (D.29).
D.28 Intraclass correlation
The idea. When each player has many single-match observations (runs per innings, fantasy points per match), the intraclass correlation (ICC) is the share of the variance in one observation that is due to who the player is. It is the single-match version of reliability (D.4), and it gives "matches until half signal" in the same way.
Formulas (one-way random effects, ICC(1)). With $k$ players, $N$ observations, between-player mean square MSB and within-player mean square MSW:
$$n_0 = \frac{N - \sum_i n_i^2 / N}{k - 1}, \qquad \text{ICC} = \frac{\text{MSB} - \text{MSW}}{\text{MSB} + (n_0 - 1) \text{MSW}}, \qquad \text{matches for half signal} = \frac{1 - \text{ICC}}{\text{ICC}}$$
The reliability of a mean of $m$ matches is $m \cdot \text{ICC} / [1 + (m-1)\text{ICC}]$, which is Spearman–Brown again.
Use when you ask how much one game tells you about a player: form guides, fantasy picks, "he always scores against them". Don't compare ICCs across different populations. A pool of only regulars has less between-player spread, and so a lower ICC.
Example (IPL 2024–26, runs per innings faced, batters with 10+ such innings):
114 batters with >= 10 innings faced, 2,848 innings; MSB 2208, MSW 516, n0 24.9
ICC(1) = 0.116; between-batter SD 8.2 runs v within SD 22.7
innings until half the spread of a batter's mean is real: (1 − ICC)/ICC = 7.6
About 12% of the variation in a single innings is the batter. The rest is the day. A "form" judgement from the last five innings is mostly noise.
In the book. Chapter 36: single-match fantasy points in IPL 2024–26 have a player share (ICC) of only 0.078 (within SD 44.0, true between-player SD 12.8), so about 12 matches are needed for half signal. That is why the last-five-matches form rule lost to the simulator (MAE 38.3 v 35.4). Fantasy points carry even less player signal than runs because they add wickets and catches, which are noisier still.
D.29 The Kelly criterion and bankroll simulation
The idea. If you genuinely have an edge, how much should you stake? Kelly (1956) showed that the stake maximising the long-run growth rate of a bankroll is a fixed fraction of it, proportional to the edge. Full Kelly is also brutally volatile, and staking more than Kelly lowers growth. Bankroll simulation shows the cost.
Formulas. For a bet at decimal odds $o$ that wins with probability $p$:
$$\text{edge} = p o - 1, \qquad f^{\ast} = \frac{p o - 1}{o - 1}, \qquad g(f) = p \log\big(1 + f(o-1)\big) + (1-p)\log(1 - f)$$
Implied probability from a price is $1/o$. The bookmaker's overround is $\sum_j 1/o_j - 1$. "De-vigging" rescales the implied probabilities to sum to 1 (the multiplicative method).
Use when you size bets after you have demonstrated an edge out of time (D.11, D.14). Don't use full Kelly with an estimated edge. If the true edge is smaller than you think, you're over-betting. Fractional Kelly (half or less) is the practitioner's norm. Don't treat any of this as encouragement to bet. Betting is illegal in most Indian states; Chapter 35 covers the law and responsible-gambling resources.
Example (crease.betting):
🧪 Simulated data: The bankroll paths are pure simulation, 2,000 paths of 1,000 independent bets with a true 5% edge at evens. The two-way price is an illustrative quote typed in by hand, not a real bookmaker's.
illustrative prices [1.8, 2.1]: implied [0.5556, 0.4762], overround 3.17%, de-vigged [0.5385, 0.4615]
edge 5.0% at decimal 2.0: Kelly stake f* = 0.050 of bankroll; growth per bet 0.00125
half Kelly (f 0.025): median final 2.55x, P(50% drawdown) 37.10%, P(final < start) 9.95%
full Kelly (f 0.050): median final 3.49x, P(50% drawdown) 98.45%, P(final < start) 20.05%
double Kelly (f 0.100): median final 0.99x, P(50% drawdown) 100.00%, P(final < start) 51.60%
This reproduces Chapter 35 exactly. Even with a real 5% edge, full Kelly halves the bankroll from a peak at some point in 98.45% of paths, and one path in five ends below where it started after 1,000 bets. Half Kelly gives up some median growth and cuts the drawdown risk to 37.1%. Double Kelly has zero expected growth.
D.30 Choosing a method: a decision table
| Your question | Start with | Then check | Watch out for |
|---|---|---|---|
| Is this player's rate good? | Pooled ratio (D.1) with an interval (D.2, D.3) | Reliability at this sample (D.4) | Wrong denominator; not-outs |
| Who is better, with unequal samples? | Shrinkage (D.6, D.7) | Out-of-sample error against raw and against "ignore" | Shrinking toward the wrong group |
| Did his form really change? | Regression to the mean (D.5) | Projection residual (D.20) | Selecting on the extreme |
| How much is skill, how much luck? | Luck share (D.8) or ICC (D.28) | Schedule balance | Reading "luck" as "random" |
| Are two groups really different? | Test plus interval (D.10) | Power (D.11); multiple comparisons | Post-hoc splits |
| Did a rule or event change things? | Difference-in-differences (D.25) | Parallel pre-trends | No comparison group; non-random choices |
| What is P(win) now? | Logistic on state (D.12) or a state table (D.17) | Calibration (D.13), out of time (D.14) | Leakage by match; era drift (D.15) |
| Who will win before the toss? | Elo (D.19) | Luck ceiling (D.8); Brier against coin | Over-fitting XIs and form |
| Next season? | Marcel (D.20) | Translation (D.22); aging (D.21) | Untranslated pooled history |
| How long will he last? | Kaplan–Meier (D.16) | Log-rank / Cox | Ignoring censoring |
| Fair target after rain? | Resource function (D.18) | Era and format fit | Claiming the Professional Edition |
| What is he worth in ₹? | RAR → WAR → market rate (D.23) | Shrinkage; runs-per-win method | Mixing RAR scales |
| Who bowls which over? Which XI? | Integer programme (D.24) | Shrunk inputs; regret against actual | Optimising noise |
| What could happen from here? | Monte Carlo (D.27) | Simulated v real spread; backtest | Unchecked simulators |
| How much to stake? | Kelly fraction (D.29) | Out-of-time edge; drawdown simulation | Full Kelly on an estimated edge |
| What types exist? | Clustering (D.26) | Silhouette / BIC; stability | Clusters on a continuum |
Reproducing and extending
Every section of appendices/code/d_methods.py is a self-contained function (d01() to d29()), so you can copy one into your own notebook and swap the player, competition or years. Three habits keep the numbers honest:
- State the filter with the number. Many entries above differ from a chapter in the second decimal place because the filter differs: full members only, decided games, minimum balls. That is fine as long as the filter is written next to the number.
- Fix the seed and say so. Bootstrap intervals, split-half reliabilities and simulations change slightly with the random draw (D.4's 94 against Chapter 6's 98; D.25's +2.7 against +2.6). If a conclusion flips with the seed, it wasn't a conclusion.
- Fit on the past, test on the future. Every predictive entry (D.12–D.15, D.19–D.22) uses a time split. Keep it when you extend them.
For the metric definitions behind these methods see Appendix C. For the data and toolkit functions, see Appendix B. For the same calculations in R, see Appendix J.
Further reading. Bradley Efron and Carl Morris (1975) on Stein shrinkage; Andrew Gelman and colleagues, Bayesian Data Analysis (hierarchical models and empirical Bayes); Tom Tango, Mitchel Lichtman and Andrew Dolphin, The Book: Playing the Percentages in Baseball (run expectancy and the state-based view of an inning); Max Marchi, Jim Albert and Ben Baumer, Analyzing Baseball Data with R; Duckworth and Lewis (1998) and Stern (2016) in the Journal of the Operational Research Society (resource functions); Arpad Elo, The Rating of Chessplayers; J. L. Kelly (1956), "A New Interpretation of Information Rate"; Nate Silver, The Signal and the Noise, and Philip Tetlock and Dan Gardner, Superforecasting (calibration and forecasting habits).