#197Elo Rating UpdateEasy

Elo Rating Update

Background

The Elo system updates two players' ratings after a match. The chess-rating heritage carried over directly to LLM-arena leaderboards: each side-by-side vote is a "match", winning model gains rating points, losing model drops. Anchor it to a starting rating (typically 1500) and you have ranked LMArena outputs.

Problem statement

Implement elo_update(rating_a, rating_b, score_a, K=32):

EA=11+10(rBrA)/400,rA=rA+K(sAEA),rB=rB+K((1sA)(1EA))E_A = \frac{1}{1 + 10^{(r_B - r_A)/400}},\qquad r_A' = r_A + K(s_A - E_A),\qquad r_B' = r_B + K\bigl((1 - s_A) - (1 - E_A)\bigr)

score_a is 11 if A won, 00 if B won, 0.50.5 for a draw. Return (new_a, new_b).

Input

  • rating_a, rating_bfloat, current ratings.
  • score_afloat in {0,0.5,1}\{0, 0.5, 1\}.
  • Kfloat, the K-factor (default 32 for new ratings; 16 for stable).

Output

Returns a tuple (new_a: float, new_b: float).

Examples

Example 1 — equal ratings, A wins → A gains K/2

Input:  rating_a=1500, rating_b=1500, score_a=1.0, K=32
Output: (1516.0, 1484.0)

Example 2 — equal ratings, draw → no change

Input:  rating_a=1500, rating_b=1500, score_a=0.5
Output: (1500.0, 1500.0)

Example 3 — total rating is conserved

Input:  any single update
Output: (new_a + new_b) == (rating_a + rating_b)

Example 4 — upset → large swing

Input:  rating_a=1800, rating_b=1400, score_a=0.0, K=32
Output: a drops, b rises by ~30 points

Constraints

  • score_a in {0,0.5,1}\{0, 0.5, 1\} (binary or draw).
  • K > 0.
  • Returns Python floats.

Notes

  • K-factor. Higher K = faster adjustment. FIDE uses 40 for new players, 20 for established, 10 for masters. LMArena tunes K based on number of votes received.
  • Bradley-Terry equivalence. Elo ratings are a logarithmic re-scaling of Bradley-Terry strengths: Eloi=400log10(ri)\text{Elo}_i = 400 \log_{10}(r_i).
Python
Loading...

▶ 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.

  • Reference example — equal ratings A wins
  • Sample — equal ratings draw, no change
  • Reference — upset, favorite loses