Class: OpenSkill::Models::PlackettLuce::Rating
- Inherits:
-
Object
- Object
- OpenSkill::Models::PlackettLuce::Rating
- Defined in:
- lib/openskill/models/plackett_luce.rb
Overview
Rating class for individual players
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#mu ⇒ Object
Returns the value of attribute mu.
-
#name ⇒ Object
Returns the value of attribute name.
-
#sigma ⇒ Object
Returns the value of attribute sigma.
Instance Method Summary collapse
- #<(other) ⇒ Object
- #<=(other) ⇒ Object
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #>(other) ⇒ Object
- #>=(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(mu:, sigma:, name: nil) ⇒ Rating
constructor
A new instance of Rating.
- #inspect ⇒ Object
-
#ordinal(z: 3.0, alpha: 1.0, target: 0.0) ⇒ Float
Calculate display rating (conservative estimate).
- #to_s ⇒ Object
Constructor Details
#initialize(mu:, sigma:, name: nil) ⇒ Rating
Returns a new instance of Rating.
279 280 281 282 283 284 |
# File 'lib/openskill/models/plackett_luce.rb', line 279 def initialize(mu:, sigma:, name: nil) @id = SecureRandom.hex @mu = mu.to_f @sigma = sigma.to_f @name = name end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
277 278 279 |
# File 'lib/openskill/models/plackett_luce.rb', line 277 def id @id end |
#mu ⇒ Object
Returns the value of attribute mu.
276 277 278 |
# File 'lib/openskill/models/plackett_luce.rb', line 276 def mu @mu end |
#name ⇒ Object
Returns the value of attribute name.
276 277 278 |
# File 'lib/openskill/models/plackett_luce.rb', line 276 def name @name end |
#sigma ⇒ Object
Returns the value of attribute sigma.
276 277 278 |
# File 'lib/openskill/models/plackett_luce.rb', line 276 def sigma @sigma end |
Instance Method Details
#<(other) ⇒ Object
302 303 304 305 306 |
# File 'lib/openskill/models/plackett_luce.rb', line 302 def <(other) raise ArgumentError, 'comparison with non-Rating' unless other.is_a?(Rating) ordinal < other.ordinal end |
#<=(other) ⇒ Object
314 315 316 317 318 |
# File 'lib/openskill/models/plackett_luce.rb', line 314 def <=(other) raise ArgumentError, 'comparison with non-Rating' unless other.is_a?(Rating) ordinal <= other.ordinal end |
#<=>(other) ⇒ Object
296 297 298 299 300 |
# File 'lib/openskill/models/plackett_luce.rb', line 296 def <=>(other) return nil unless other.is_a?(Rating) ordinal <=> other.ordinal end |
#==(other) ⇒ Object
326 327 328 329 330 |
# File 'lib/openskill/models/plackett_luce.rb', line 326 def ==(other) return false unless other.is_a?(Rating) @mu == other.mu && @sigma == other.sigma end |
#>(other) ⇒ Object
308 309 310 311 312 |
# File 'lib/openskill/models/plackett_luce.rb', line 308 def >(other) raise ArgumentError, 'comparison with non-Rating' unless other.is_a?(Rating) ordinal > other.ordinal end |
#>=(other) ⇒ Object
320 321 322 323 324 |
# File 'lib/openskill/models/plackett_luce.rb', line 320 def >=(other) raise ArgumentError, 'comparison with non-Rating' unless other.is_a?(Rating) ordinal >= other.ordinal end |
#eql?(other) ⇒ Boolean
336 337 338 |
# File 'lib/openskill/models/plackett_luce.rb', line 336 def eql?(other) self == other end |
#hash ⇒ Object
332 333 334 |
# File 'lib/openskill/models/plackett_luce.rb', line 332 def hash [@id, @mu, @sigma].hash end |
#inspect ⇒ Object
344 345 346 |
# File 'lib/openskill/models/plackett_luce.rb', line 344 def inspect to_s end |
#ordinal(z: 3.0, alpha: 1.0, target: 0.0) ⇒ Float
Calculate display rating (conservative estimate)
292 293 294 |
# File 'lib/openskill/models/plackett_luce.rb', line 292 def ordinal(z: 3.0, alpha: 1.0, target: 0.0) alpha * ((@mu - z * @sigma) + (target / alpha)) end |
#to_s ⇒ Object
340 341 342 |
# File 'lib/openskill/models/plackett_luce.rb', line 340 def to_s "Rating(mu=#{@mu}, sigma=#{@sigma}#{", name=#{@name}" if @name})" end |