Documentation ¶
Index ¶
- func Ordinal(rating Rating, options *Options) float64
- func PredictDraw(teams []Team, options *Options) float64
- func PredictRank(teams []Team, options *Options) (predictions [][]float64)
- func PredictWin(teams []Team, options *Options) []float64
- func RankDataMin(data []float64) []float64
- type Gamma
- type Model
- type NewRatingParams
- type Options
- type Rating
- type Team
- func BradleyTerryFull(game []Team, options *Options) []Team
- func BradleyTerryPart(game []Team, options *Options) []Team
- func NewTeam(teams ...*Rating) Team
- func PlackettLuce(game []Team, options *Options) []Team
- func Rate(teams []Team, options Options) []Team
- func ThurstoneMostellerFull(game []Team, options *Options) []Team
- func ThurstoneMostellerPart(game []Team, options *Options) []Team
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Ordinal ¶
Ordinal takes a Rating and returns a value that has 99.7% of representing the player true skill rating
func PredictDraw ¶ added in v0.4.0
PredictDraw returns the probability that a set of teams will tie based on their rating. If there is only one team, the function will return 1, and if there is no teams, it will return -1
func PredictRank ¶ added in v0.5.0
PredictRank calculates and predicts the ranks of teams based on pairwise probabilities.
Parameters:
teams: A slice of Team structs representing the teams. options: A pointer to an Options struct that holds the configuration options.
Returns:
predictions: A 2D slice of float64 containing the predicted ranks and corresponding probabilities. Each inner slice has two elements: rank and probability. The outer slice represents the predictions for each team. The length of predictions slice is equal to the number of teams.
func PredictWin ¶ added in v0.4.0
PredictWin returns the probability of each team has to win ordered by the order of the teams. If there is only one team, the function will return nil.
func RankDataMin ¶ added in v0.5.0
RankDataMin calculates the ranks for a given slice of float64 values. It assigns ranks based on the values in ascending order, where the lowest value gets rank 1. If there are ties (equal values), the tied elements receive the same rank, with the next rank skipped.
Parameters:
data: A slice of float64 values for which ranks need to be calculated.
Returns:
A new slice of float64 values representing the ranks corresponding to the input data.
Types ¶
type Gamma ¶
type Gamma func(adjustedTeamUncertainty float64, amountOfTeams int64, averageTeamSkill float64, teamUncertaintySquared float64, team *Team, teamRanking int64) float64
Gamma represents a function to help to reduce the variance of how much the skill uncertainty degree can change. It is defined by user and helps to correct cases in which the player skill can assume huge negative or positive values with an uncertainty value near zero. Said function returns a number to adjust the skill uncertainty.
type NewRatingParams ¶
NewRatingParams represents the values that help initilize a rating.
type Options ¶
type Options struct { // StandardizedPlayerSkill is a constant that is set in way that, the following assertion // is always true: // // StandardizedPlayerSkill == (Ordinal(Rating) - Rating.AveragePlayerSkill) / Rating.SkillUncertaintyDegree // // The bigger this constant is, the smaller the degree of uncertainty relative to average skill. // When not set,it defaults to 3. StandardizedPlayerSkill *float64 // AveragePlayerSkill represents the default value of a player average skill level. // When not set, it defaults to 25. AveragePlayerSkill *float64 // SkillUncertaintyDegree represents the default value of uncertainty for a player skill. // When not set, it defaults to Options.AveragePlayerSkill / Options.NormalizedPlayerSkill SkillUncertaintyDegree *float64 // SmallPositive is a value to use when a ranking model tries to update a player uncertainty // with a negative value. It is rarely needed to do such substitutions. // When not set, it defaults to 0.001 SmallPositive *float64 // GammaFunction is a pointer to a function that is used to adjust // how much SkillUncertaintyDegree can vary. When not set, it defaults // to an internal implementation that mirrors the one found on item 6.1 of the // Weng-Lin paper for the Packett-Luce model. GammaFunction *Gamma // VarianceForTeamPerformance represents a constant to adjust the value of a team // performance. When not set, it defaults to (Options.SkillUncertaintyDegree / 2) ^ 2. // The default value for this constant takes into consideration if Options.SkillUncertaintyDegree is set or if // either Options.AveragePlayerSkill or Options.NormalizedPlayerSkill are set. VarianceForTeamPerformance *float64 // Model represents the current model of ranking used. When not set, it defaults to Plackett-Luce. Model *Model // Rankings is a optional slice of rankings that is used when provided order of the teams for the // Rate function differs from the actual order of rankings. Other use for this field is to indicate // when ties happened after a competition. Rankings []int64 // Scores is slice of the scores of the teams after competing. In this implementation // is a slice of integer values because otherwise, a lot of the internal operations // would use maps. This field doesn't need to be initialized with values. Scores []int64 // Tau is a value that prevents the uncertainty to drop to a value that is too low. // Setting this constant, allows the rating to stay pliable even after many games. // A suggested value for this constant is Options.AveragePlayerSkill / 300. Tau *float64 // PreventUncertaintyIncrease is an optional boolean value that, if it is set, and if Options.Tau is set, // prevents the uncertainty value to increase, thus stopping the fringe case when the Ordinal of player // rating decrease after a victory, which can feel unfair. PreventUncertaintyIncrease *bool // contains filtered or unexported fields }
Options contains the values provided of the constants used by the rating system, plus optional rankings and scores of the teams to be rated, plus a optional paramenter that stops a player true skill rating from going after a victory, which can feel unfair.
type Rating ¶
type Rating struct { // AveragePlayerSkill represents the average // value for a player skill. It normally is // the value in the middle of normal or // logistic distribution. AveragePlayerSkill float64 // SkillUncertaintyDegree represents the amount // of uncertainty of the skill of a player. // This value is used to set the bounds of the // probalistic distribution. SkillUncertaintyDegree float64 }
Rating represents a player's skill in the particular set rankings
func NewRating ¶
func NewRating(init *NewRatingParams, options *Options) *Rating
NewRating creates a new Rating, with optional initializing rating values and a optional set of default constants. Useful when not creating ratings in a vacuum.
type Team ¶
type Team []*Rating
Team is nothing more than a collection of Ratings
func BradleyTerryFull ¶
BradleyTerryFull is a implementation of the Bradley-Terry ranking model that uses full pairing. The Bradley-Terry model uses logistic distribution to properly rank the teams. It accepts the a slice with the team that are competing, plus an options parameter, with things such as scores and previous rankings. The function return a slice of teams that are properly ranked.
func BradleyTerryPart ¶ added in v0.2.0
BradleyTerryPart is a implementation of the Bradley-Terry ranking model that uses partial pairing. The Bradley-Terry model uses logistic distribution to properly rank the teams. Partial pairing is less accurate than a full pairing, but works better in situations with a high number of teams. This function accepts the a slice with the team that are competing, plus an options parameter, with things such as scores and previous rankings. The function return a slice of teams that are properly ranked.
func NewTeam ¶ added in v0.2.0
NewTeam is a small utility function to create a Team from many players.
func PlackettLuce ¶
PlackettLuce represents the Plackett-Luce ranking model, which is the generalized version of the Bradley-Terry model
func ThurstoneMostellerFull ¶ added in v0.3.0
ThurstoneMostellerFull is a implementation of the Thurstone-Mosteller ranking model that uses full pairing. The Thurstone-Mosteller model uses gaussian distribution to properly rank the teams. It accepts the a slice with the team that are competing, plus an options parameter, with things such as scores and previous rankings. The function return a slice of teams that are properly ranked.
func ThurstoneMostellerPart ¶ added in v0.3.0
ThurstoneMostellerPart is a implementation of the Thurstone-Mosteller ranking model that uses partial pairing. The Thurstone-Mosteller model uses gaussian distribution to properly rank the teams. Partial pairing is less accurate than a full pairing, but works better in situations with a high number of teams. This function accepts the a slice with the team that are competing, plus an options parameter, with things such as scores and previous rankings. The function return a slice of teams that are properly ranked.