Glicko (glicko v0.8.0)
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])
%Player.V1{rating: 1464.0506705393013, rating_deviation: 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])
%Player.V1{rating: 1.5e3, rating_deviation: 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
Calculate the probability of a player drawing against an opponent.
iex> player = Player.new_v1
iex> opponent = Player.new_v1
iex> Glicko.draw_probability(player, opponent)
1.0
Link to this section Summary
Functions
Calculates the probability of a player drawing against an opponent.
Calculates the probability of a player drawing against an opponent from a player rating, opponent rating and opponent rating deviation.
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.
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
new_rating_opts()
Specs
Link to this section Functions
draw_probability(player, opponent)
Specs
draw_probability(player :: Glicko.Player.t(), opponent :: Glicko.Player.t()) :: float()
Calculates the probability of a player drawing against an opponent.
Returns a value between 0.0
and 1.0
.
draw_probability(player_rating, opponent_rating, opponent_rating_deviation)
Specs
draw_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 drawing 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
.
new_rating(player, results, opts \\ [])
Specs
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.
win_probability(player, opponent)
Specs
win_probability(player :: Glicko.Player.t(), opponent :: Glicko.Player.t()) :: float()
Calculates the probability of a player winning against an opponent.
Returns a value between 0.0
and 1.0
.
win_probability(player_rating, opponent_rating, opponent_rating_deviation)
Specs
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
.