Class: OpenSkill::Models::ThurstoneMostellerPart::Rating
- Inherits:
-
Object
- Object
- OpenSkill::Models::ThurstoneMostellerPart::Rating
- Defined in:
- lib/openskill/models/thurstone_mosteller_part.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.
284 285 286 287 288 289 |
# File 'lib/openskill/models/thurstone_mosteller_part.rb', line 284 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.
282 283 284 |
# File 'lib/openskill/models/thurstone_mosteller_part.rb', line 282 def id @id end |
#mu ⇒ Object
Returns the value of attribute mu.
281 282 283 |
# File 'lib/openskill/models/thurstone_mosteller_part.rb', line 281 def mu @mu end |
#name ⇒ Object
Returns the value of attribute name.
281 282 283 |
# File 'lib/openskill/models/thurstone_mosteller_part.rb', line 281 def name @name end |
#sigma ⇒ Object
Returns the value of attribute sigma.
281 282 283 |
# File 'lib/openskill/models/thurstone_mosteller_part.rb', line 281 def sigma @sigma end |
Instance Method Details
#<(other) ⇒ Object
307 308 309 310 311 |
# File 'lib/openskill/models/thurstone_mosteller_part.rb', line 307 def <(other) raise ArgumentError, 'comparison with non-Rating' unless other.is_a?(Rating) ordinal < other.ordinal end |
#<=(other) ⇒ Object
319 320 321 322 323 |
# File 'lib/openskill/models/thurstone_mosteller_part.rb', line 319 def <=(other) raise ArgumentError, 'comparison with non-Rating' unless other.is_a?(Rating) ordinal <= other.ordinal end |
#<=>(other) ⇒ Object
301 302 303 304 305 |
# File 'lib/openskill/models/thurstone_mosteller_part.rb', line 301 def <=>(other) return nil unless other.is_a?(Rating) ordinal <=> other.ordinal end |
#==(other) ⇒ Object
331 332 333 334 335 |
# File 'lib/openskill/models/thurstone_mosteller_part.rb', line 331 def ==(other) return false unless other.is_a?(Rating) @mu == other.mu && @sigma == other.sigma end |
#>(other) ⇒ Object
313 314 315 316 317 |
# File 'lib/openskill/models/thurstone_mosteller_part.rb', line 313 def >(other) raise ArgumentError, 'comparison with non-Rating' unless other.is_a?(Rating) ordinal > other.ordinal end |
#>=(other) ⇒ Object
325 326 327 328 329 |
# File 'lib/openskill/models/thurstone_mosteller_part.rb', line 325 def >=(other) raise ArgumentError, 'comparison with non-Rating' unless other.is_a?(Rating) ordinal >= other.ordinal end |
#eql?(other) ⇒ Boolean
341 342 343 |
# File 'lib/openskill/models/thurstone_mosteller_part.rb', line 341 def eql?(other) self == other end |
#hash ⇒ Object
337 338 339 |
# File 'lib/openskill/models/thurstone_mosteller_part.rb', line 337 def hash [@id, @mu, @sigma].hash end |
#inspect ⇒ Object
349 350 351 |
# File 'lib/openskill/models/thurstone_mosteller_part.rb', line 349 def inspect to_s end |
#ordinal(z: 3.0, alpha: 1.0, target: 0.0) ⇒ Float
Calculate display rating (conservative estimate)
297 298 299 |
# File 'lib/openskill/models/thurstone_mosteller_part.rb', line 297 def ordinal(z: 3.0, alpha: 1.0, target: 0.0) alpha * ((@mu - z * @sigma) + (target / alpha)) end |
#to_s ⇒ Object
345 346 347 |
# File 'lib/openskill/models/thurstone_mosteller_part.rb', line 345 def to_s "Rating(mu=#{@mu}, sigma=#{@sigma}#{", name=#{@name}" if @name})" end |