In one sentence
A Markov chain describes a system that hops between states, where the chance of the next hop depends only on where you are now, not how you got there.
How it works
An in-play football match is a chain of states: the score and the minute. From 1-0 in the 80th minute, the next minute ends 2-0, 1-1 or still 1-0. If you know how likely each of those is, you can work out the chance of every final result from any score and minute.
The "only where you are now" rule is called the Markov property. It means you do not need to remember the full history, just the current state. That keeps the maths small enough to compute every minute in-play.
Tennis is the textbook case, and the formulas below use it because it has only two outcomes per point. Chains also appear in cricket (runs and wickets per ball) and in modelling how a Betfair price moves between ticks.
The maths
- p: the chance the server wins any single point.
- q: the chance the returner wins a point, equal to 1 − p.
- s: the current score; s+ is the score after the server wins the point, s− after the server loses it.
- G(p): the chance the server holds the game from 0-0.
In plain English: your chance from here is a weighted mix of your chances from the two scores you might move to next.
Football works the same way with a third branch for "no goal this minute": the chance from here is (home goal chance × chance from the new score) + (away goal chance × chance from that score) + (no-goal chance × chance from the same score a minute later).
Worked betting example
The home side lead 1-0 with 10 minutes left, stoppage time included. Illustrative inputs: in any minute the home side score with chance 1.3% and the away side with 1.7% (the trailing side pushes). Working backwards minute by minute:
- Home win 85.9% (fair odds 1.16), draw 13.0% (fair odds 7.67), away win 1.1%.
- If the next minute passes without a goal: home win 87.1%, draw 12.1%.
- If the away side equalise next minute: home win 9.7%, draw 77.3%, away win 13.0%.
- If the home side score next minute (2-0): home win 99.1%.
Check with the one-step rule: 0.013 × 99.1% + 0.017 × 9.7% + 0.970 × 87.1% = 85.9%.
Suppose the Match Odds market shows the draw at 9.0 to back. The chain says fair is 7.67. Backing £20 at 9.0 has an expected value of 0.1303 × £160 × 0.98 − 0.8697 × £20 ≈ £3.04 after 2% commission, but only if those goal rates are right for these two teams, today, at this score. Get them slightly wrong and the edge vanishes.
Where it's good
- In-play football: pricing Match Odds, Correct Score and Over/Under goals from any score and minute.
- Checking whether in-play prices overreact to a single goal or a quiet spell.
- In-play tennis: pricing games, sets and matches point by point.
- Modelling transitions between ladder prices for short-term trading simulations.
Limitations and pitfalls
- Fixed goal rates are the big assumption; real teams tire, sit back when ahead and chase when behind.
- Real sport often breaks the Markov property: momentum or pressure may make history matter.
- The output is only as good as the input rates, and small errors cause big errors late in a match.
- In-play markets react faster than most people can compute and bet, especially with Betfair's in-play delay.
- Many other traders run the same chain, so obvious mispricings are rare in the big leagues.
How to build it
- A recursive Python function with caching (functools.lru_cache) computes result chances from every score and minute in milliseconds.
- For goal rates, use minute-by-minute goal data, adjusted for team strength and the current score, shrunk towards league averages.
- Tip: build the chain in one-minute steps, then check its pre-match output against the Match Odds and Correct Score prices before trusting it in-play.
Related methods
- Hidden Markov models add states you cannot see directly, such as "in form".
- Dynamic programming is the working-backwards technique used above.
- Birth-death processes are a special chain where you only move up or down one step.
- Monte Carlo simulation handles chains too big to solve exactly.