glicko v0.5.0 Glicko

Provides the implementation of the Glicko rating system.

See the specification for implementation details.

Usage

Get a player’s new rating after a series of matches in a rating period.

iex> results = [Result.new(Player.new_v1([rating: 1400, rating_deviation: 30]), :win),
...> Result.new(Player.new_v1([rating: 1550, rating_deviation: 100]), :loss),
...> Result.new(Player.new_v1([rating: 1700, rating_deviation: 300]), :loss)]
iex> player = Player.new_v1([rating: 1500, rating_deviation: 200])
iex> Glicko.new_rating(player, results, [system_constant: 0.5])
{1464.0506705393013, 151.51652412385727}

Get a player’s new rating when they haven’t played within a rating period.

iex> player = Player.new_v1([rating: 1500, rating_deviation: 200])
iex> Glicko.new_rating(player, [], [system_constant: 0.5])
{1.5e3, 200.27141669877065}

Calculate the probability of a player winning against an opponent.

iex> player = Player.new_v1
iex> opponent = Player.new_v1
iex> Glicko.win_probability(player, opponent)
0.5

Link to this section Summary

Functions

Generate a new rating from an existing rating and a series (or lack) of results

Calculates the probability of a player winning against an opponent from a player and an opponent

Calculates the probability of a player winning against an opponent from a player rating, opponent rating and opponent rating deviation

Link to this section Types

Link to this type new_rating_opts()
new_rating_opts() :: [system_constant: float(), convergence_tolerance: float()]

Link to this section Functions

Link to this function new_rating(player, results, opts \\ [])
new_rating(player :: Glicko.Player.t(), results :: [Glicko.Result.t()], opts :: new_rating_opts()) :: Glicko.Player.t()

Generate a new rating from an existing rating and a series (or lack) of results.

Returns the updated player with the same version given to the function.

Link to this function win_probability(player, opponent)
win_probability(player :: Glicko.Player.t(), opponent :: Glicko.Player.t()) :: float()

Calculates the probability of a player winning against an opponent from a player and an opponent.

Returns a value between 0.0 and 1.0.

Link to this function win_probability(player_rating, opponent_rating, opponent_rating_deviation)
win_probability(player_rating :: Glicko.Player.rating(), opponent_rating :: Glicko.Player.rating(), opponent_rating_deviation :: Glicko.Player.rating_deviation()) :: float()

Calculates the probability of a player winning against an opponent from a player rating, opponent rating and opponent rating deviation.

Values provided for the player rating, opponent rating and opponent rating deviation must be v2 based.

Returns a value between 0.0 and 1.0.