Glicko2 (Rust Edition)
Glicko2 is an iterative algorithm for ranking opponents or teams in 1v1 games. This is a zero-dependency Rust library implementing this algorithm.
Installation
Add the following to your Cargo.toml:
[]
= "1.1.0"
Sample Usage
The most common usage is to update a series of matches for each team, but this library provides many other convenience methods.
To update a series of matchups
use ;
/// Tune the rating values, here we use the default
let tuning = default;
/// Create a Rating struct for each team
let mut team_to_update = new;
let mut opponent_1 = new;
let mut opponent_2 = new;
let mut opponent_3 = new;
let mut opponent_4 = new;
/// Rate our team against a vector of matchup results
rate;
/// Opponent 4 did not play, so their rating must be decayed
opponent_4.decay;
/// Print our updated rating
println!; // Rating(μ=1500.0, φ=255.40, σ=0.0059)0059 }
To get the odds one team will beat another
use ;
/// Tune the rating values, here we use the default
let tuning = default;
/// Create a Rating struct for each team
let mut rating_1 = new;
let mut rating_2 = new;
/// Get odds (percent chance team_1 beats team_2)
let odds = odds;
println!; // 0.5, perfect odds since both teams have the same rating
To determine the quality of a matchup
use ;
/// Tune the rating values, here we use the defaults
let tuning = default;
/// Create a Rating struct for each team
let mut rating_1 = new;
let mut rating_2 = new;
/// Get odds (the advantage team 1 has over team 2)
let quality = quality;
println!; // 1.0, perfect matchup since both teams have the same rating
To update both team's ratings for a single matchup
use ;
/// Tune the rating values, here we use the defaults
let tuning = default;
/// Create a Rating struct for each team
let mut rating_1 = new;
let mut rating_2 = new;
/// Update ratings for team_1 beating team_2
compete;
/// Print our updated ratings
println!; // Rating(μ=1646.47, φ=307.84, σ=0.0059)
println!; // Rating(μ=1383.42, φ=306.83, σ=0.0059)
Rating
Each side of a 1v1 competition is assigned a rating and a rating deviation. The rating represents the skill of a player or team, and the rating deviation measures confidence in the rating value.
Rating Deviation
A team or player's rating deviation decreases with results and increases during periods of inactivity. Rating deviation also depends on volatility, or how consistent a player or team's performance is.
Thus, a confidence interval represents a team's or player's skill: a player with a rating of 1300 and a rating deviation of 25 means the player's real strength lies between 1350 and 1250 with 95% confidence.
Match Timing Caveat
Since time is a factor in rating deviation, the algorithm assumes all matches within a rating period were played concurrently and use the same values for uncertainty.
Tuning Parameters
- Rating period length and quantity impact decay in rating deviation
- Should generally be
{10..15}matches per team per period
- Should generally be
- Initial mu and phi values affect how much teams or players can change
- Defaults are
1500and350respectively
- Defaults are
- Sigma is the base volatility
- Default to
0.06
- Default to
- Tau is the base change constraint; higher means increased weight given to upsets
- Should be
{0.3..1.2}
- Should be
Problems
- Difficult to determine the impact of an individual match
- No ratings available in the middle of a rating period
- Ratings are only valid at compute time
Paper
Mark Glickman developed the Glicko2 algorithm. His paper is available here.