Class: Olympic::Rating::Glicko::Formula
- Inherits:
-
Object
- Object
- Olympic::Rating::Glicko::Formula
- Extended by:
- Memoist
- Defined in:
- lib/olympic/rating/glicko/formula.rb
Constant Summary collapse
- DEFAULT_RATING =
The default rating. Glicko states to use 1500 as the default.
1500
- DEFAULT_RATING_DERIVATION =
The default RD. Glicko states to use 350 as the default.
350
- CERTAINTY_DECAY =
This is the “certainty decay,” or the constant value that is used in Step 1 of the Glicko rating system. It denotes the decay of certainty of a player’s rating over a given time (see Olympic::Rating::Glicko for a definition of time). The default chosen here expects a typical RD of 50, with 10 time units before a decay to 350. The formula would be (in LaTeX):
c = \sqrt{\frac{350^2-50^2}{10}}
However, in order to optimize operations, this is c^2. So the actual value of this would be:
c = \frac{350^2-50^2}{10}
12_000
- Q =
Math.log2(10).fdiv(400)
- Q2 =
Q ** 2
Instance Method Summary collapse
- #call ⇒ Object
-
#derivation ⇒ Numeric
This returns the current rating derivation of the unit.
-
#initialize(unit, matches) ⇒ Formula
constructor
A new instance of Formula.
Constructor Details
#initialize(unit, matches) ⇒ Formula
Returns a new instance of Formula.
35 36 37 38 |
# File 'lib/olympic/rating/glicko/formula.rb', line 35 def initialize(unit, matches) @unit = unit @matches = matches end |
Instance Method Details
#call ⇒ Object
40 41 42 43 44 |
# File 'lib/olympic/rating/glicko/formula.rb', line 40 def call flush_cache @unit. = @unit.derivation = new_derivation end |
#derivation ⇒ Numeric
This returns the current rating derivation of the unit. It clamps the rating derivation to between 30 and 350. The Glicko system states that it must be less than or equal to 350, but later recommends not letting the rating derivation drop below 30.
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/olympic/rating/glicko/formula.rb', line 53 def derivation if @unit.unrated? 350 elsif @unit.time_passed == 0 @unit.derivation else a = [ 30, Math.sqrt((@unit.derivation) ** 2 + CERTAINTY_DECAY * @unit.time_passed), 350 ].sort[1] end end |