Exglicko2 (exglicko2 v0.1.0)

Tools for working with Glicko-2 ratings.

Ratings are represented by a tuple of the rating, the rating deviation, and the rating volatility. You can get a new, default tuple with the new/0 function.

iex> Exglicko2.new()
{0.0, 2.0, 0.06}

Once your players have ratings, the games can begin! Game results are represented by a number ranging from zero to one, with a one representing a win, and a zero representing a loss.

Ratings are updated with a list of game results passed to the update_rating/3 function. Game results are batched into a list of tuples, with the first element being the opponent's rating tuple, and the second being the resulting score. This function also requires a system constant, which governs how much ratings are allowed to change. This value must be between 0.4 and 1.2

iex> player = {0.0, 1.2, 0.06}
iex> system_constant = 0.5
iex> results = [
...>   {{-0.6, 0.2, 0}, 1},
...>   {{0.3, 0.6, 0}, 0},
...>   {{1.2, 1.7, 0}, 0}
...> ]
iex> Exglicko2.update_rating(player, results, system_constant)
{-0.21522518921916625, 0.8943062104659615, 0.059995829968027437}

Here is some guidance on the optimal number of games to pass into the update_rating/3 function, directly from the original paper:

The Glicko-2 system works best when the number of games in a rating period is moderate to large, say an average of at least 10-15 games per player in a rating period. The length of time for a rating period is at the discretion of the administrator.

Some convenience functions are also present in this module. The functions rating/1, deviation/1, and volatility/1 access the corresponding value of a rating tuple, so you don't have to keep accessing a "magic tuple position" in your code.

If you use the older Glicko rating system, use the Exglicko2.Conversion module to convert between the old and new systems.

iex> Exglicko2.Conversion.glicko_to_glicko2({1500.0, 350, 0.06})
{0.0, 2.014761872416068, 0.06}

Link to this section Summary

Functions

Returns the deviation value of a rating tuple.

Returns a new {rating, deviation, volatility} tuple, suited to new players.

Returns the rating value of a rating tuple.

Update a player's rating based on game results.

Returns the volatility value of a rating tuple.

Link to this section Functions

Returns the deviation value of a rating tuple.

Examples

iex> Exglicko2.deviation({0.0, 2.0, 0.06})
2.0

Returns a new {rating, deviation, volatility} tuple, suited to new players.

Returns the rating value of a rating tuple.

Examples

iex> Exglicko2.rating({0.0, 2.0, 0.06})
0.0
Link to this function

update_rating(player, results, system_constant)

Update a player's rating based on game results.

Each player is represented by a tuple of the player's rating, their rating deviation, and their rating volatility. Game results are batched into a list of tuples, with the first element being the opponent's values, and the second being the resulting score between zero and one.

Also requires a system constant, which governs how much ratings are allowed to change. This value must be between 0.4 and 1.2

Example

A player with a rating of 0.0, a deviation of 1.2, and a volatility of 0.06 plays three games.

  • Against the first opponent, they win. Thus the score is 1.
  • Against the second opponent, they lose. Thus the score is 0.
  • Against the third opponent, they lose again. Thus the score is 0.

The result is that the player's score drops to -0.2, their deviation drops to 0.9, and their volatility drops slightly.

iex> player = {0.0, 1.2, 0.06}
iex> system_constant = 0.5
iex> results = [
...>   {{-0.6, 0.2, 0}, 1},
...>   {{0.3, 0.6, 0}, 0},
...>   {{1.2, 1.7, 0}, 0}
...> ]
iex> Exglicko2.update_rating(player, results, system_constant)
{-0.21522518921916625, 0.8943062104659615, 0.059995829968027437}
Link to this function

volatility(arg)

Returns the volatility value of a rating tuple.

Examples

iex> Exglicko2.volatility({0.0, 2.0, 0.06})
0.06