G10Tips
Live· 0 matches
Goals

The Mathematics of xG: The Formulas Behind Predictions

The mathematics behind Expected Goals — from shot geometry to Bayesian models and xG+, and how these formulas power predictions and betting.

6 min read#xg#expected goals#mathematics#logistic regression#bayesian#value bet

Introduction

In recent years football has undergone a genuine statistical revolution. What used to be judged by eye and intuition is now dissected by mathematical models that try to capture the essence of the game in numbers. At the centre of this shift is xG (Expected Goals), a metric now omnipresent in broadcasts, stats sites and betting platforms.

xG is not a magic number: it is the output of probabilistic models that answer one fundamental question — how likely is a given shot to become a goal? By assigning a value between 0 and 1 to each attempt, xG translates the quality of a chance into a conversion probability. This article explores the formulas and models behind xG, with attention to their critical use in the betting ecosystem.

1. The geometry of the goal: model fundamentals

At the heart of any xG model is the premise that shot location is the single most important factor for conversion. A base model uses two geometric parameters: distance to goal and shot angle.

1.1 The physics of the shot angle

The shot angle is the angle formed between the ball’s position and the two posts. The more central the position relative to the goal, the wider the angle and the more room to finish — increasing the chance of scoring.

Modelling with Cartesian coordinates: on a 50 m wide pitch with a 7 m goal, with the origin at the corner (0,0), the posts sit at C(21.5, 0) and B(28.5, 0). For a shot from position A(x, y), the angle θ follows from the law of cosines:

θ=arccos ⁣[2y2+(xxB)2+(xxC)2(xBxC)22((xxB)2+y2)((xxC)2+y2)]\theta = \arccos\!\left[\frac{2y^{2}+(x-x_B)^{2}+(x-x_C)^{2}-(x_B-x_C)^{2}}{2\sqrt{\left((x-x_B)^{2}+y^{2}\right)\cdot\left((x-x_C)^{2}+y^{2}\right)}}\right]

The formula shows that the more central the position (x near 25 m), the wider the angle θ and the higher the expected xG. It is, however, a simplification: other factors — such as the presence of defenders — affect the real chance.

1.2 Beyond basic geometry

Modern models integrate several variables (features) that contextualise the shot. A Serie A study of 7,801 attempts showed that, beyond distance and angle, other variables are equally influential:

  • Shot type: header or foot.
  • Assist type: cross, long ball or through pass.
  • Game situation: set piece, counter-attack or established possession.
  • Defensive pressure: presence and proximity of defenders between the attacker and the goal.

Many early models worked as logistic regressions, estimating the probability of a binary outcome (goal or no goal):

P(Y=1)=11+e(β0+β1x1+β2x2++βkxk)P(Y=1) = \frac{1}{1 + e^{-\left(\beta_0 + \beta_1 x_1 + \beta_2 x_2 + \cdots + \beta_k x_k\right)}}

Here, Y indicates whether the shot was a goal (1) or not (0), β₀ is the intercept and β₁…βₖ are the coefficients that quantify the impact of each variable x₁…xₖ. Positive coefficients raise the probability; negative ones lower it.

2. Statistical evolution: logistic regression and machine learning

xG models have evolved considerably since the first experiments. Logistic regression remains a solid base, but the state of the art incorporates machine learning to handle the complexity and volume of data.

2.1 The power of simplicity: logistic regression

Despite more complex techniques, logistic regression remains powerful, especially when interpretability is a priority. A comparative study of eight models found that a logistic regression with a cloglog (complementary log-log) link even outperformed XGBoost in accuracy. cloglog suits rare events such as goals:

log ⁣(log(1P))=β0+β1x1++βkxk\log\!\big(-\log(1 - P)\big) = \beta_0 + \beta_1 x_1 + \cdots + \beta_k x_k

2.2 The power of complexity: XGBoost and neural networks

At the other end, models like XGBoost (gradient boosting) and neural networks excel at finding non-linear patterns and complex interactions that linear models might miss.

Trained on spatio-temporal tracking data of players and the ball, XGBoost improves accuracy by considering not only the shot’s position but the movement that led to it — building decision trees where each new tree corrects the errors of the previous one.

3. Hierarchical and player-correction models

A common criticism of traditional models is assuming that every player is an “average finisher”: the same shot would have the same xG regardless of who takes it. Bayesian models address this gap.

3.1 Hierarchical Bayesian modelling

The hierarchical approach learns global parameters (distance, angle, etc.) and, at a lower level, per-player parameters indicating how much better or worse than average a player is at finishing. For a shot by player j:

logit ⁣(P(Goalij=1))=αj+β1xij1+β2xij2+\operatorname{logit}\!\big(P(\text{Goal}_{ij}=1)\big) = \alpha_j + \beta_1 x_{ij1} + \beta_2 x_{ij2} + \cdots

αⱼ is the player’s random effect (positive = above average; negative = below). The αⱼ are assumed to follow a normal distribution around zero, and the model “shrinks” estimates for players with few attempts toward the mean — avoiding overblown conclusions from small samples.

Premier League studies confirm significant per-player effects: forwards and attacking midfielders with positive effects, defenders with negative effects, and some athletes consistently outperforming their expected xG.

4. Betting applications: xG, EV and the prediction market

For platforms, xG underpins algorithms that look for value bets: they estimate an event’s true probability and compare it with the probability implied by the odds.

4.1 From probability to Expected Value (EV)

If a model estimates a 60% chance of “Over 2.5 goals”, but the odds imply only 50%, the bet has positive EV. The expected value of a bet is:

EV=(True Probability×Odds)1EV = \big(\text{True Probability} \times \text{Odds}\big) - 1

If the result is greater than zero, the bet is, in theory, profitable in the long run — which does not remove risk or guarantee any individual outcome.

4.2 Markets derived from xG

  • Both teams to score (BTTS): the sum of both teams’ xG vs. xGA (Expected Goals Against).
  • Over/Under goals: total expectancy = the sum of both teams’ xG.
  • Correct score: detailed probabilities for specific scorelines.

4.3 The new frontier: from xG to xG+

Traditional xG only counts shots that actually occur — ignoring dangerous sequences without a shot — and merely sums probabilities, which can inflate the value of a possession with several shots above 1. xG+ models the probability of a shot occurring at each instant (xS) multiplied by the probability of a goal given the shot:

xGt+=Pt(Shot)×Pt(GoalShot)xG^{+}_{t} = P_t(\text{Shot}) \times P_t(\text{Goal} \mid \text{Shot})

For the whole possession, it combines the probability of no goal at each instant:

xGpossession+=1t=1n(1xGt+)xG^{+}_{\text{possession}} = 1 - \prod_{t=1}^{n}\left(1 - xG^{+}_{t}\right)

This way, the total probability never exceeds 1 (100%), correcting xG inflation and evaluating danger even when the team does not shoot.

Conclusion

xG is a sophisticated application of mathematics and statistics to football — from the trigonometry of pitch geometry to machine-learning algorithms and Bayesian models that capture individual skill. Its evolution is a story of the pursuit of precision.

In the betting ecosystem, xG grounds decisions in probability and EV, not guesswork. Even so, no formula removes uncertainty: models describe probabilities, not certainties. Analyse to understand the game, always within responsible limits.

References

  • Maddmaths! (2024). Angolo di tiro ed expected goals.
  • Scholtes, A., & Karakuş, O. (2023). Bayes-xG: Player and Position Correction on Expected Goals using Bayesian Hierarchical Approach. arXiv.
  • Pipping, J., Feng, T., & Sabin, P. (2025). Beyond Expected Goals: A Probabilistic Framework for Shot Occurrences in Soccer. arXiv.
  • Severin, S. (2024). Expected Points, Expected Goals Difference. Thesis, Università degli Studi di Padova.
  • Mahmudlu, M., Karakuş, O., & Arkadaş, H. (2025). What If They Took the Shot? A Hierarchical Bayesian Framework for Counterfactual Expected Goals. arXiv.
  • Cefis, M., & Carpita, M. (2024). Accuracy and explainability of statistical and machine learning xG models in football. Taylor & Francis Online.
  • Wyscout (2025). Pre-shot and post-shot xG. Wyscout Glossary.
  • BBC Sport (2017). Premier League: “Expected goals” tells us whether a player really should have scored.

References gathered as editorial background only; the text above is original to G10Tips.

Related articles