A knockout bracket is the cruellest sampling device in sport. Thirty-two teams enter the 2026 World Cup's round of 32; one survives five wins to lift the trophy, and a single bad ninety minutes ends everyone else's tournament. No team's title chance can be read off a bracket by eye: the path matters as much as the rating. The honest way to estimate it is to simulate: play the whole bracket round by round, do it ten thousand times, and count how often each team is the last one standing. This tutorial builds exactly that in Python.
From ratings to a match probability
Everything starts with one function: given two teams' ratings, what is the probability the first beats the second in a single match? The workhorse model is a logistic one, the same shape used by Elo. The larger the rating gap, the more lopsided the win probability, following an S-curve that never quite reaches 0 or 1, because in football, anyone can beat anyone on the day. If ratings are on an Elo-style scale, the formula is a tidy one-liner.
The 400 is the Elo scale constant: a 400-point edge makes a team roughly a 10-to-1 favourite. Where the logic of these ratings comes from, and why Elo and SPI disagree on purpose, is the subject of soccer power ratings: Elo, SPI, and why they disagree. For the simulator we just need the function.
import numpy as np
rng = np.random.default_rng(7)
def match_prob(rating_a, rating_b):
"""Probability team A beats team B in one match (Elo logistic)."""
return 1.0 / (1.0 + 10 ** (-(rating_a - rating_b) / 400.0))
def play_match(team_a, team_b, ratings, seed_rng):
"""Return the winner of a single knockout match."""
p_a = match_prob(ratings[team_a], ratings[team_b])
return team_a if seed_rng.random() < p_a else team_b
There is no draw here, and that is deliberate: a knockout match cannot end level. The logistic gives the probability of A advancing: whether that comes via 90 minutes, extra time, or penalties is all folded into the single number. Modelling the penalty lottery separately is possible, but it adds noise more than insight at this level.
A toy field of 32 teams
We need thirty-two teams with ratings. Here is the essential honesty point of this whole piece: the field below is invented. It is not the real 2026 World Cup field, not based on any draw, qualification, or seeding, and not a prediction. This tutorial was first written before the 2026 tournament kicked off on June 11, 2026, when there were no real bracket results to use. The tournament has since been played (Spain beat Argentina 1–0 in the final on July 19), but the toy field stays: the point here is the machinery, and invented ratings keep the code short and the numbers easy to check. The toy ratings exist only to make the code runnable. Replace the names and numbers with your own and the simulator works unchanged.
# --- TOY FIELD (invented, NOT the real 2026 bracket) --------------
# 32 fake teams with made-up Elo-style ratings. Replace with your own.
team_names = [f"Team {i:02d}" for i in range(1, 33)]
base_ratings = np.linspace(1900, 1500, 32) # spread strong to weak
jitter = rng.normal(0, 30, size=32) # a little randomness
ratings = {name: float(r + j)
for name, r, j in zip(team_names, base_ratings, jitter)}
# Bracket seeding: the order teams are paired in round 1.
# In a real run this comes from the group-stage results. Here it is
# just the list order, so adjacent pairs (0v1, 2v3, ...) meet first.
bracket = list(team_names)
The structure of a real bracket (which group winner meets which runner-up) is fixed in advance by the tournament's bracket diagram. To keep this tutorial focused on the simulation engine, we treat the bracket list order as the seeding: team 0 plays team 1, team 2 plays team 3, and so on. When you plug in real results from simulating the groups, you arrange the thirty-two survivors into this list in the official bracket order, and everything downstream is identical.
Playing one bracket, round by round
A single-elimination bracket has a beautifully simple recursive shape: pair up the teams, play each match, collect the winners into a new (half-as-long) list, and repeat until one team remains. With thirty-two teams that is five rounds (round of 32, round of 16, quarter-final, semi-final, final) and the list halves each time: 32, 16, 8, 4, 2, 1.
def play_bracket(seeding, ratings, seed_rng):
"""Play a single-elimination bracket once. Return the champion."""
survivors = list(seeding)
while len(survivors) > 1:
next_round = []
# Pair adjacent teams: (0,1), (2,3), (4,5), ...
for i in range(0, len(survivors), 2):
winner = play_match(survivors[i], survivors[i + 1],
ratings, seed_rng)
next_round.append(winner)
survivors = next_round
return survivors[0]
That loop is the entire knockout. It works for any power-of-two field (32, 16, 8) without modification, because halving a power of two always lands cleanly on another. (The 2026 round of 32 is itself the product of a 48-team group stage; the unusual arithmetic that gets us there is unpacked in why 104 matches and a 48-team format.)
Monte Carlo: ten thousand tournaments
One bracket is one story. To estimate title odds we replay the bracket many times, each run using fresh random numbers, and tally how often each team wins. The fraction of tournaments a team wins is its estimated title probability: the core idea behind every published World Cup forecast, explained without code in how a World Cup simulation works.
from collections import Counter
def simulate(seeding, ratings, n_sims=10_000, seed=7):
seed_rng = np.random.default_rng(seed)
champions = Counter()
for _ in range(n_sims):
champ = play_bracket(seeding, ratings, seed_rng)
champions[champ] += 1
print(f"Title odds over {n_sims:,} simulated tournaments:\n")
for team, wins in champions.most_common(10):
print(f" {team:9s} {wins / n_sims:6.1%}")
simulate(bracket, ratings)
The output is a leaderboard of title probabilities. With the toy ratings spread evenly from strong to weak, the top-seeded teams will lead, but notice two things the simulation reveals that no eyeball estimate could. First, even the strongest team's title chance is far below 50%: winning five straight knockout matches is hard, and small per-match edges compound into long-shot odds. Second, two teams with nearly identical ratings can have meaningfully different title chances purely because of where the bracket places them: an easier half is worth real probability.
How a World Cup simulation works
This section condenses a separate article first published on 15 June 2026.
The code above is the skeleton of every published World Cup forecast. This section sets out, without code, why the method is needed, why it keeps embarrassing the favourite, and why two careful forecasters running it can still disagree.
The arithmetic of compounding
Suppose a genuinely excellent team wins 70% of its matches against the kind of opponent it will face in a deep bracket. How often does it win five straight to take the trophy? Not 70%: it has to win the first match and the second and the third and the fourth and the fifth. That product is 0.705 ≈ 0.168, about one tournament in six. Drop the per-match win rate to a still-excellent 60% and the title probability collapses to 0.605 ≈ 0.078, fewer than one run in twelve.
70% per match over 5 rounds → 0.705 ≈ 16.8%.
60% per match over 5 rounds → 0.605 ≈ 7.8%.
The favourite's edge survives one match; it does not survive five.
Flip it around and you see why upsets feel so common: in the 70%-per-match case, somebody other than the best team wins better than 83% of the time. Single elimination hands the field, collectively, more chances than it hands the single strongest entrant, which is the structural reason the favourite wins less often than its quality suggests.
Why you cannot just calculate it
It is tempting to multiply the probability of winning the group by the probability of winning each knockout round. But those probabilities are not independent or fixed: who a team meets in the round of 16 depends on which teams top their groups, which depends on results that have not happened. The bracket is a tree of contingencies, and the clean way to handle one is to sample it: play it out, let the contingencies resolve themselves, and repeat until the averages stabilise.
A full simulation needs two ingredients: a rating for every team (a single Elo figure or a paired attack-and-defence number in the SPI tradition) and a match model that turns two ratings into a result. Instead of the logistic used above, many forecasters use a Poisson model: convert the rating gap (plus any venue adjustment) into an expected number of goals for each side and draw each team's goals from a Poisson distribution, which yields a probability for every scoreline. A knockout tie the model lands on as a draw goes to extra time and, if needed, a shoot-out, which most simulations treat as close to 50/50. Run the whole tournament 50,000 times and a team that won 6,000 of those runs gets a 12% title probability; every other question (reach the semis, top the group, suffer a group-stage exit) is answered the same way.
Why two forecasts disagree
The engine is mechanical; the disagreement comes from the inputs, and a handful of choices dominate. The ratings are the biggest lever: a results-only Elo and a chance-quality-aware hybrid can rate the same team meaningfully differently, and because the match model is non-linear, a modest rating gap can swing a title share by several points. The home and venue edge (how much advantage to give host or near-host teams, and how to handle travel, altitude and heat across a continent-spanning tournament) is a real and unsettled choice. The shoot-out assumption, pure coin flip versus a small edge for the stronger or better-prepared side, nudges the deep-run odds of every contender. And variance settings control how often upsets happen: a higher-variance model produces flatter odds, a lower-variance one concentrates probability on the favourites. When two forecasts agree, that is relative confidence; when they diverge, one of them has made a different, examinable assumption.
Run the 48-team version
The simulator below plays the real 48-team, 12-group World Cup 2026 format (twelve groups of four, top two plus the eight best third-placed teams into a 32-team knockout) over as many Monte Carlo tournaments as you like. It ships with generic placeholder teams and ratings that you overwrite; it knows nothing about the actual 2026 results. Leave the shipped placeholder spread alone, where the ratings step down gently from 90 to 38, and even the top-rated team takes fewer than one title in twenty. Nudge that rating up five points and re-run: the share barely twitches. Push every rating to the extremes the inputs allow, 100 down to nearly zero, and it still only reaches about 7%, roughly one tournament in fourteen.
This simulator needs JavaScript. The method: simulate each group as a round robin with Poisson goals (scoring rate set by the rating gap), rank by points then goal difference, advance the top two of each group plus the eight best third-placed teams into a 32-team knockout decided by the same goal model, and repeat thousands of times to estimate each team's advance and title odds. It uses placeholder teams you edit: no real 2026 results are encoded.
Open the full simulator on its own page →
What a simulation does not tell you
It is only as good as the ratings you feed it, and the crisp percentages tempt you to forget they rest on a number you essentially guessed. It assumes a stable model of a match, with no idea about a key suspension, a tactical mismatch, fatigue from a brutal travel schedule, or the fact that knockout football is often cagier and lower-scoring than the group stage. Independence between rounds is an approximation: a team that grinds through extra time twice may be more vulnerable in the next round. And it is not a forecast of the real tournament but a property of your assumptions and the format's structure. Read the title-odds column as a distribution, not a verdict, run it with deliberately different ratings to see which conclusions survive, and watch how the per-stage odds decay round by round, because that decay is the compounding. The deeper warning against reading too much into any single bracket is laid out in what the June previews told readers to watch for.
Sharpening the simulator
A few upgrades make this genuinely useful. Track every round, not just the title, by recording how far each team gets: that yields "reach the quarter-final" and "reach the final" probabilities, which are often more robust than the noisy title number. Feed in real ratings rather than the toy linspace: convert a power-rating table using the approach in soccer power ratings: Elo, SPI, and why they disagree. And chain it to the group stage so the whole pipeline runs end to end: simulate a World Cup group in Python produces the thirty-two survivors this bracket consumes, and the wider numbers behind the tournament live in World Cup 2026 by the numbers.
The honest framing never changes, though. A simulator is a machine for turning assumptions into probabilities; it cannot turn guesses into facts. Garbage ratings in, garbage odds out. The value is in being explicit about your inputs and letting ten thousand random tournaments tell you what those inputs imply, not in pretending the bracket has already been played.
Sources & further reading
- SciPy documentation: NumPy's random number generation, used to drive the match and bracket draws.
- StatsBomb: background on rating teams and modelling match outcomes.
- StatsBomb open data: results data for building and validating your own team ratings.
- FBref: international match histories useful for calibrating an Elo-style rating.
Published by SoccerAnalytics from public data and the sources named in this piece. How this site is made.