Glicko.Player (glicko v0.8.1)

Provides convenience functions that handle conversions between Glicko versions one and two.

Usage

Create a v1 player with the default values for an unrated player.

iex> Player.new_v1
%Player.V1{rating: 1.5e3, rating_deviation: 350.0}

Create a v2 player with the default values for an unrated player.

iex> Player.new_v2
%Player.V2{rating: 0.0, rating_deviation: 2.014761872416068, volatility: 0.06}

Create a player with custom values.

iex> Player.new_v2(rating: 3.0, rating_deviation: 2.0, volatility: 0.05)
%Player.V2{rating: 3.0, rating_deviation: 2.0, volatility: 0.05}

Convert a v2 player to a v1. Note this drops the volatility.

iex> Player.new_v2 |> Player.to_v1
%Player.V1{rating: 1.5e3, rating_deviation: 350.0}

Convert a v1 player to a v2.

iex> Player.new_v1 |> Player.to_v2(0.06)
%Player.V2{rating: 0.0, rating_deviation: 2.014761872416068, volatility: 0.06}

Note calling to_v1 with a v1 player or likewise with to_v2 and a v2 player will pass-through unchanged. The volatility arg in this case is ignored.

iex> player_v2 = Player.new_v2
iex> player_v2 == Player.to_v2(player_v2)
true

Summary

Functions

The recommended initial volatility value for a new player.

Creates a new v1 player.

Creates a new v2 player.

A version agnostic method for getting a player's rating.

A version agnostic method for getting a player's rating deviation.

A convenience function for summarizing a player's strength as a 95% confidence interval.

Scales a player's rating deviation.

Scales a player's rating.

Converts a v2 player to a v1.

A version agnostic method for getting a player's volatility.

Types

@type rating() :: float()
Link to this type

rating_deviation()

@type rating_deviation() :: float()
@type t() :: v1() | v2()
@type v1() :: Glicko.Player.V1.t()
@type v2() :: Glicko.Player.V2.t()
@type version() :: :v1 | :v2
Link to this type

volatility()

@type volatility() :: float()

Functions

Link to this function

initial_volatility()

@spec initial_volatility() :: volatility()

The recommended initial volatility value for a new player.

Link to this function

new_v1(opts \\ [])

@spec new_v1(rating: rating(), rating_deviation: rating_deviation()) :: v1()

Creates a new v1 player.

If not overriden, will use the default values for an unrated player.

Link to this function

new_v2(opts \\ [])

@spec new_v2(
  rating: rating(),
  rating_deviation: rating_deviation(),
  volatility: volatility()
) :: v2()

Creates a new v2 player.

If not overriden, will use default values for an unrated player.

Link to this function

rating(player, as_version \\ nil)

@spec rating(player :: t(), as_version :: version() | nil) :: rating()

A version agnostic method for getting a player's rating.

Link to this function

rating_deviation(player, as_version \\ nil)

@spec rating_deviation(player :: t(), as_version :: version() | nil) ::
  rating_deviation()

A version agnostic method for getting a player's rating deviation.

Link to this function

rating_interval(player, as_version \\ nil)

@spec rating_interval(player :: t(), as_version :: version() | nil) ::
  {rating_low :: float(), rating_high :: float()}

A convenience function for summarizing a player's strength as a 95% confidence interval.

The lowest value in the interval is the player's rating minus twice the RD, and the highest value is the player's rating plus twice the RD. The volatility measure does not appear in the calculation of this interval.

An example would be if a player's rating is 1850 and the RD is 50, the interval would range from 1750 to 1950. We would then say that we're 95% confident that the player's actual strength is between 1750 and 1950.

When a player has a low RD, the interval would be narrow, so that we would be 95% confident about a player’s strength being in a small interval of values.

Link to this function

scale_rating_deviation_to(rating_deviation, version)

@spec scale_rating_deviation_to(
  rating_deviation :: rating_deviation(),
  to_version :: version()
) ::
  rating_deviation()

Scales a player's rating deviation.

Link to this function

scale_rating_to(rating, version)

@spec scale_rating_to(rating :: rating(), to_version :: version()) :: rating()

Scales a player's rating.

@spec to_v1(player :: t()) :: v1()

Converts a v2 player to a v1.

A v1 player will pass-through unchanged.

Note the volatility field used in a v2 player will be lost in the conversion.

Link to this function

to_v2(player, volatility \\ initial_volatility())

@spec to_v2(player :: t(), volatility :: volatility()) :: v2()

Converts a v1 player to a v2.

A v2 player will pass-through unchanged with the volatility arg ignored.

Link to this function

volatility(player, default_volatility \\ initial_volatility())

@spec volatility(player :: t(), default_volatility :: volatility()) :: volatility()

A version agnostic method for getting a player's volatility.