Ahmed Beddi

Education

Soccer analytics: mathematics and statistics, a 24-session course

A comprehensive applied course teaching probability, regression, linear algebra, optimization, and statistical inference through real-world questions asked by fans and analysts, fitted on open match event data. Includes an interactive expected-goals (xG) explorer and a fully reproducible computational lab.

Teaching artifactCourseUpdated 2026-10-08

Public data: StatsBomb open data, 2018 FIFA World Cup (competition 43, season 3). Distance-band statistics and fitted coefficients are derived from the 1,556 open-play shots in wc2018_shots.csv, calculated in the accompanying notebook. Didactic baseline coefficients are illustrative and not empirically fitted.

Interactive

Context

Football is one of the rare domains where beginners already possess strong, well-formed intuitions about probability. Nearly every supporter holds an opinion on whether a missed chance "should have been converted", whether an in-form striker is genuinely clinical or merely on a lucky streak, or whether a league title was captured on merit. These intuitions represent a powerful pedagogical asset: each is a sophisticated statistical problem in disguise.

This course seizes that opportunity. It guides motivated learners—equipped only with high-school algebra and basic Python fluency (lists, loops, and functions)—from loading an initial shot log to delivering a complete capstone tactical dossier tailored for a coaching staff. No prior exposure to calculus or linear algebra is assumed; both mathematical tools are introduced visually and contextually at the exact moment a practical problem demands them.

The pedagogical problem

Traditional introductory statistics courses typically follow the linear sequence of standard textbooks: descriptive measures, followed by abstract probability distributions, formal regression, and finally statistical inference. Learners are introduced to technical machinery long before they encounter a compelling reason to use it, leaving formulas feeling largely decorative.

This curriculum deliberately reverses that dynamic. Every module begins with an authentic tactical or sporting puzzle, introducing only the mathematical concepts strictly necessary to resolve it.

Pedagogical approach and structure

24 sessions organized across seven modules. Each 90-minute session follows a structured four-part rhythm: a 10-minute hook drawn from an iconic match event; a 30-minute concept presentation delivered first as a visual intuition and subsequently formalized algebraically; 40 minutes of hands-on practice in a lab notebook or interactive dashboard; and a 10-minute exit ticket assessing the session’s single core objective. Four-session modules follow a consistent arc: Concept → Build → Lab → Apply.

Module Guiding Question Mathematical & Statistical Concepts
0. The pitch as a dataset Where do match event data come from and how are they structured? Spatial coordinates, Euclidean distance, mean, median, dispersion metrics, base rates
1. Building expected goals (xG) Why is a specific shooting chance evaluated at precisely 0.08 xG? Vector angles, conditional probability, logistic response curves, Brier score, probability calibration
2. The Poisson match model What is the exact probability of a 2–1 scoreline? Poisson counting processes, stochastic independence, outer products (scoreline matrices), Monte Carlo simulation
3. Passing networks & player profiles Who serves as the tactical hub, and which players share N'Golo Kanté's profile? Matrix algebra, eigenvector centrality (power iteration), standardized zz-scores, PCA, kk-means clustering
4. How models learn What actually occurs beneath the hood when an algorithm trains? Derivatives, gradient descent optimization, feature normalization, basic linear programming
5. Skill versus fortune Is this striker elite, or currently benefiting from positive variance? Sampling variance, regression to the mean, empirical Bayes shrinkage, multiple testing adjustments
6. Pitch control & capstone Which team controls the critical spaces across the pitch? Voronoi tessellations, spatial pitch control modeled as continuous probability fields

Core design principles. Questions precede the mathematics; visual intuition precedes symbolic notation. Every statistical model is estimated using open, verifiable event data, ensuring no formula remains abstract. The workflow centers on building a naïve model, identifying its failure points, and refining it. Formal proofs are avoided unless a concise algebraic derivation delivers immediate applied insight.

Tooling and data ecosystem. All assignments run entirely on open-source tools: Python in Jupyter or Google Colab using pandas, NumPy, Matplotlib, scikit-learn, and SciPy, alongside domain-specific libraries such as statsbombpy (event extraction) and mplsoccer (pitch visualizations). Empirical materials draw from StatsBomb's open repository (the 2018 FIFA World Cup; Leicester City's 2015/16 Premier League title run as the structural spine; and 2022 World Cup 360 freeze-frames) combined with Metrica Sports' open tracking sample.

Pacing and assessment architecture. The course accommodates either an intensive format (six weeks, four sessions per week) or a semester schedule (twelve weeks, two sessions per week). The suggested grading breakdown allocates: computational labs 40%, exit tickets 10%, intermediate mini-projects 20%, and the capstone project 30%. The capstone pairs an executed codebase with a one-page analytical memo written for a head coach. Evaluation weighs practical interpretation on par with algorithmic correctness: a mathematically complex model poorly communicated scores lower than an honest, simpler model whose assumptions and limitations are explicitly articulated.

Artifact demonstrations

The interactive expected-goals explorer

Sessions 3 through 5 center on a dedicated spatial simulator. By selecting a location on the pitch, the shot's distance to goal and visual angle subtended between the posts are mapped directly into an empirical scoring probability via the logistic function:

z=b0+b1 angle+b2 distance,xG=11+e−zz = b_0 + b_1\,\text{angle} + b_2\,\text{distance}, \qquad xG = \frac{1}{1 + e^{-z}}

The explorer incorporates two distinct parameter sets:

  • The didactic parameter set (b0=−0.6b_0 = -0.6, b1=2.2b_1 = 2.2, b2=−0.1b_2 = -0.1) is deployed in Session 3: it captures the intuitive topology of shot quality (shots closer to goal, more centrally located, and with wider angles yield higher conversion odds) without being fitted to empirical data.
  • The fitted parameter set represents the coefficients estimated in Lab 1 from 1,556 open-play shots during the 2018 World Cup (b0=−2.027b_0 = -2.027, b1=1.266b_1 = 1.266, b2=−0.069b_2 = -0.069).

Comparing these two models against the distance-band breakdown highlights a foundational data-science insight: the intuitive didactic model predicts roughly three times more goals than were actually scored in 2018, whereas the fitted logistic regression matches empirical conversion rates across distance bands with high fidelity.

The penalty-spot anomaly

The simulator also illustrates the boundaries of purely geometric modeling. In regular play at the 2018 World Cup, penalties were converted 22 times out of 29 attempts (76%). However, the fitted geometric model assigns an xG value of only ~0.12 to the penalty spot: while it correctly measures distance (12 yards) and angle, it fails to account for regulatory context—namely, an uncontested strike with no defenders obstructing the shooting lane. This diagnostic failure serves as an instructive motif throughout subsequent modules: construct a baseline model, fit it rigorously, and delineate precisely where its structural assumptions break down.

Key findings from the Lab 1 reproduction

The accompanying notebook replicates the primary analytical benchmarks of Lab 1 using the published match logs:

  • The Lab 0 data hygiene puzzle: The raw event table records 183 total goals, whereas official tournament standings reflect 169. This discrepancy arises because 26 successful shootout attempts are classified as shots in the event feed, while 12 own goals are excluded from attacking shot logs. Reconciling this (157 open-play and set-piece goals from shots + 12 own goals = 169 total match goals) grounds students in the critical importance of defensive data filtering.
  • Baseline conversion metrics: An overall in-game shooting conversion rate of 9.4%, a median shot distance of 18.4 yards (~16.8 m), and a median goal distance of 11.0 yards (~10.0 m).
  • Predictive accuracy: A Brier score of 0.069 for the student-fitted logistic model on open-play attempts, compared to 0.064 for StatsBomb’s proprietary multi-feature xG model.
  • Calibration versus discrimination: A predicted xG sum of 129.0 matching exactly 129 open-play goals scored. The session's exit ticket uses this finding to test understanding: does a model that perfectly matches aggregate totals prove predictive reliability? (It does not, as global calibration can coexist with poor individual event discrimination).

Curriculum build status

The complete syllabus outlines 15 core instructional artifacts. Three are fully developed and validated against open data: the interactive xG explorer, Lab 1 (fitting custom xG models), and the complete Module 0 suite (an orientation notebook, Lab 0, and an event-mapping script of the 2018 World Cup final). The remaining twelve components—ranging from the bivariate Poisson scoreline grid to the Voronoi pitch-control visualizer and capstone grading rubric—are fully drafted and scheduled for production.

Methodological limitations

  • In-sample evaluation bias: The performance metrics reported in Lab 1 are evaluated in-sample. Session 6 formally introduces out-of-sample validation by reserving the tournament knockout rounds as a test set; that partition is omitted in this introductory overview.
  • Sample size constraints: A dataset of 1,556 open-play shots and 129 goals is sufficient for pedagogical illustration, but remains too small to calibrate an enterprise-grade commercial xG model.
  • Omitted spatial variables: The baseline geometric model excludes defensive pressure, goalkeeper positioning, body part used, and pre-shot assist velocity. The penalty-spot gap highlights this omitted-variable bias.
  • Reproduction scope: The notebook provided here is an executive demonstration verifying the computational findings; it does not replace the complete student workbook and progressive exercises.
  • Formative evaluation stage: This curriculum represents an instructional framework paired with working demonstrators, rather than an empirically evaluated intervention with longitudinal student learning outcomes.

Operational deployment and transferability

The core instructional paradigm—leading with a domain-specific question, introducing only the mathematics required to solve it, and fitting models to open data—transfers readily to other applied quantitative disciplines where learners bring strong domain intuition but nascent formal mathematical skills.

In public-policy analysis, for instance, the guiding questions change (e.g., "Did an intervention move this social indicator?", "Does this regional discrepancy reflect structural disparity or small-sample noise?"), while the statistical toolkit remains consistent: Poisson distributions for incident monitoring, empirical Bayes shrinkage for small-area estimation, and regression to the mean for evaluating performance leaderboards. Evaluating such a curriculum relies on continuous formative assessment: rapid exit tickets to identify conceptual bottlenecks immediately, lab assignments evaluated on reproducible execution and clear one-sentence takeaways, and a capstone memo judged by a non-technical decision-maker on its strategic clarity.

Event data provided courtesy of StatsBomb via their Open Data repository.