Bradley-Terry Strength MLE
Background
Bradley-Terry estimates per-player strength parameters from head-to-head win records. The probability that player beats player is . LMArena uses this to convert tens of millions of side-by-side LLM votes into the Elo-style numbers on the leaderboard.
Problem statement
Implement bradley_terry(wins, max_iter=200, tol=1e-6) via the standard MM (minorisation-maximisation) iteration:
where = times beat and . After each step, normalise so the geometric mean of r equals .
Input
wins—np.ndarrayshape of integers.wins[i, j]= times beat .max_iter—int, iteration cap (default200).tol—float, convergence tolerance on max relative change (default1e-6).
Output
Returns np.ndarray of length — the strength parameters, normalised so .
Examples
Example 1 — strict dominance hierarchy
Input: wins = [[0, 10, 10], [0, 0, 10], [0, 0, 0]]
Output: r[0] > r[1] > r[2]
Example 2 — symmetric records → equal strengths
Input: every pair has 5-5 wins
Output: all r equal (and equal to 1 after normalisation)
Example 3 — geometric-mean normalisation
Input: any non-degenerate matrix
Output: prod(r)**(1/N) ≈ 1.0
Constraints
- Diagonal of
winsis ignored (players don't play themselves). - Players with zero total wins get a tiny strength (floor at
1e-12) to keep the geometric mean non-zero. - Returns
np.ndarrayoffloat.
Notes
- Convergence. MM iterations are monotone in the log-likelihood; convergence is guaranteed but can be slow. Production use Newton-Raphson for fewer iterations.
- Mapping to Elo. for some scale (LMSYS uses ). The shapes are the same; only the units differ.
▶ Run executes the 3 visible sample tests below in your browser. Submit runs the full suite — including hidden tests — on the server for an official verdict.
- •Dominance hierarchy orders strengths (example)
- •Symmetric records give equal strengths (reference)
- •Geometric-mean normalisation equals 1 (sample)