Documentation
¶
Overview ¶
This code names variables and functions according to the conventions used in Professor Mark E. Glickman's paper:
- mu: the player's strength estimate (rating converted to the Glicko-2 scale).
- phi: the rating deviation converted to the Glicko-2 scale. Phi defines the bounds of the 95% confidence interval, where the lower bound is mu-2*phi, and the upper bound is mu+2*phi.
- sigma: the degree of expected fluctuation in a player's rating. This value is high when a player has erratic performances, and low when the player performs at a consistent level.
- tau: the volatility change constraint.
- g: a weighting function that reduces the influence of enemies with high phi values.
- e: the expected score against an enemy with the specified mu and phi.
- v: the updated player's mu based only on expected game outcomes.
- delta: the estimated value of the updated player's mu based on actual game outcomes.
Index ¶
Constants ¶
const ( DefaultRating = 1500 // This value can also be an upper bound, since the system cannot be less // uncertain about a player's rating than it is for an unrated player. DefaultDeviation = 350 DefaultVolatility = 0.06 DefaultTau = 0.5 DefaultFactor = 173.7178 DefaultEpsilon = 0.000001 // Default rating period duration in seconds. DefaultDuration = 60 * 60 * 24 * 7 )
Recommended values based on the original Glicko-2 paper.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Converter ¶
type Converter struct {
// Default rating of the unrated player. Use [DefaultRating] constant for
// the recommended value.
Rating float64
// Default deviation of the unrated player. Use [DefaultDeviation] constant
// for the recommended value.
Deviation float64
// Scaling factor. Use [DefaultFactor] constant for the recommended value.
Factor float64
}
Converter performs conversions between the Glicko-2 and traditional "Elo-style" rating scales. Internally all calculations to estimate the player's Strength are performed using the Glicko-2 scaled values.
func (Converter) Deviation2Phi ¶
Deviation2Phi converts deviation to the Glicko-2 scale.
func (Converter) Phi2Deviation ¶
Phi2Deviation converts phi to the "Elo-style" rating deviation scale.
type Estimator ¶
type Estimator struct {
// Rating period duration in seconds. Use [DefaultDuration] constant for
// the recommended value.
Duration uint64
// Lower bound of the possible mu value.
MinPhi float64
// Upper bound of the possible mu value.
MaxPhi float64
// Lower bound of the possible phi value.
MinMu float64
// Upper bound of the possible phi value.
MaxMu float64
// Lower bound of the possible sigma value.
MinSigma float64
// Upper bound of the possible sigma value.
MaxSigma float64
// System variable. Use [DefaultTau] constant for the recommended value.
Tau float64
// System variable. Use [DefaultEpsilon] constant for the recommended value.
Epsilon float64
}
Estimator performs calculations of the player's strength.
func (Estimator) Estimate ¶
Estimate updates the player's Strength by analyzing:
- s: player's Strength at the onset of the rating period.
- o: Outcome of a single match withing a single rating period.
- periodFraction: fraction of a rating period that has elapsed since the last rating update.
The result of this function is validated.
type Outcome ¶
type Outcome struct {
// Enemy's mu.
Mu float64
// Enemy's phi.
Phi float64
// Set score to 0 if the player lost the match, 0.5 for a draw, and 1 if
// the player won.
Score float64
}
Outcome represents a game information used to calculate the new player's rating. It stores only Glicko-2 scaled values which are used for internal calculations, hence all fields are unexported.