Bayesian modelling · All chapters
Bayesian modellingChapter 03 of 06

Goals per game

A newly promoted side wins its first match 5–0. Is it suddenly the best attack in the league? Time to learn how to count properly.

AuthorJack Maughan
ModelGamma-Poisson
Figures3, interactive
Reading time8 minutes
PreviouslyIn Chapter 2, a striker's three from three became a curve of beliefs about his penalty rate: a prior, some evidence, and a posterior that is always a range, never a single number.

Opening day. Riverside, just promoted, beat a solid mid-table side 5–0. By Monday the fans are booking the open-top bus and the pundits are calling it a fluke. Both camps are reacting to the same one match.

Penalties were yes-or-no: goal or miss. Goals in a match are a count: 0, 1, 2, 3… That needs a slightly different model, but the recipe from the last two chapters doesn't change at all. Start with a belief, add the evidence, and see where you end up.

Riverside and its results are made up, so you can play with them freely.

§ 01 — How goals behave

One number describes a whole season

Goals are rare and fairly random. Statisticians describe them with the Poisson distribution, named after the French mathematician Siméon Denis Poisson. You give it one number, a team's average goals per game (its scoring rate), and it tells you how often that team should score 0, 1, 2 or more. Models built on it are the workhorse of football prediction.

Move the slider and watch what a single rate implies. Then play a few seasons and see how lumpy real results look, even when nothing about the team changes.

Fig. 4 — What a scoring rate looks likeOne team, one rate, many outcomes
In a typical match this team

Each square below will be one match.

Chance of scoring exactly this manyBlank (no goals)

Two things jump out. First, even a decent attack draws a blank surprisingly often: a team averaging 1.4 goals fails to score in about a quarter of its matches. Second, the occasional thrashing is part of normal randomness. A team that averages 1.2 a game will still score five roughly once every 130 matches, and a 20-team league has 760 team-performances a season. Somebody ordinary is going to hit five.

So Riverside's 5–0 is exciting, but it's one draw from a very wide range. The question is how far it should move us.

§ 02 — Updating the rate

One 5–0 isn't five goals a game

Before a ball is kicked, what would you guess for a newly promoted side? Let's say about 1.2 goals a game, held about as firmly as if you'd already watched them for 10 games. That's our prior. It's a judgement call, and you can change it below.

For counts, the prior is a Gamma distribution, the counting cousin of the Beta curve from Chapter 2. And the update is beautifully simple: add the goals to the top and the games to the bottom. The prior counts as 12 goals in 10 games; the opener adds 5 goals in 1 game. Best guess: 17 ÷ 11 ≈ 1.55 goals a game.

Fig. 5 — Updating a scoring rate1 match
01  Prior
02  Results
Add a match where they scored
Prior (before) Results alone Posterior (after)
PriorWho's winning the argument?Results
Record5 in 1goals in games
Raw rate5.00results alone
Best guess1.55goals per game
90% range–credible interval

The dashed blue curve is what the results say on their own. After a single match it's enormous and flat, because one game can't pin down a rate. The prior is narrow, so it wins the argument, and the posterior lands just above it.

Now press Play 5 more a few times. The computer is quietly simulating Riverside's real season from a hidden rate. Each batch of results drags the posterior towards the truth, and the tug-of-war bar swings from the prior to the results. By the end of a season the starting guess barely matters. Try a sceptical prior (0.8) and an optimistic one (2.0) and you'll see them meet in the middle.

§ 03 — What happens next

Predicting the next match

The posterior isn't the end of the story; you can ask it about the future. For every rate it thinks is possible, the Poisson says what next week might look like. Average all of those, weighted by how believable each rate is, and you get the predictive distribution.

The lazy alternative is to take the raw scoring rate and plug it straight into a Poisson. Below are both, using whatever results you've built up in Fig. 5.

Fig. 6 — Next match, two waysBased on 1 match
Plugging in the raw rate Bayesian prediction

After one 5–0, plugging in the raw rate says Riverside will almost certainly score three or more next week and has about a 1% chance of a blank. The Bayesian prediction is far humbler, and it's what you'd want to bet with. Notice it is also wider than a single Poisson would be: it carries our uncertainty about the rate into the forecast instead of pretending we know it.

Real football models go further. They give every team an attack rate and a defence rate, add home advantage, and let the rates drift through a season. The best-known version was published by Mark Dixon and Stuart Coles in 1997. But under the hood it's this chapter, many times over.

Key findings

  1. Counts (goals, cards, complaints, claims) get a Poisson model: one rate describes the whole spread of outcomes.
  2. With a Gamma prior, updating is just arithmetic: add the goals to the top, the games to the bottom.
  3. Thrashings and blanks are part of normal randomness. One match moves the estimate a little; a season moves it a lot.
  4. The posterior predicts the future too, and its predictions are honest about uncertainty, so they're wider than plugging in a single rate.
Appendix — the maths

A prior guess m goals per game, held with the strength of s games, becomes a Gamma distribution on the rate λ:

λ ~ Gamma(α = m·s, β = s)

Each match's goals are Poisson. After G goals in n games the posterior is again a Gamma:

λ | data ~ Gamma(α + G, β + n)    best guess = (α + G) ÷ (β + n)

With the default prior and the 5–0: (12 + 5) ÷ (10 + 1) ≈ 1.55. As in Chapter 2, that's a weighted average of the prior guess and the raw rate, with the results' weight n ÷ (n + s).

The predictive distribution for next match's goals k is a negative binomial:

P(k) = Γ(k + α′) ÷ (Γ(α′) · k!) · (β′ ÷ (β′ + 1))^α′ · (1 ÷ (β′ + 1))^k

where α′ and β′ are the posterior parameters. It has the same mean as the Poisson but a larger variance, which is the uncertainty about λ showing up in the forecast.

Next · Chapter 04

Five stars from three reviews

Where should a prior come from? A film with a perfect score from three people shows how a group can set the prior for each of its members.

→