Class: OpenSkill::Models::BradleyTerryFull::Rating
- Inherits:
-
Object
- Object
- OpenSkill::Models::BradleyTerryFull::Rating
- Defined in:
- lib/openskill/models/bradley_terry_full.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.
278 279 280 281 282 283 |
# File 'lib/openskill/models/bradley_terry_full.rb', line 278 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.
276 277 278 |
# File 'lib/openskill/models/bradley_terry_full.rb', line 276 def id @id end |
#mu ⇒ Object
Returns the value of attribute mu.
275 276 277 |
# File 'lib/openskill/models/bradley_terry_full.rb', line 275 def mu @mu end |
#name ⇒ Object
Returns the value of attribute name.
275 276 277 |
# File 'lib/openskill/models/bradley_terry_full.rb', line 275 def name @name end |
#sigma ⇒ Object
Returns the value of attribute sigma.
275 276 277 |
# File 'lib/openskill/models/bradley_terry_full.rb', line 275 def sigma @sigma end |
Instance Method Details
#<(other) ⇒ Object
301 302 303 304 305 |
# File 'lib/openskill/models/bradley_terry_full.rb', line 301 def <(other) raise ArgumentError, "comparison with non-Rating" unless other.is_a?(Rating) ordinal < other.ordinal end |
#<=(other) ⇒ Object
313 314 315 316 317 |
# File 'lib/openskill/models/bradley_terry_full.rb', line 313 def <=(other) raise ArgumentError, "comparison with non-Rating" unless other.is_a?(Rating) ordinal <= other.ordinal end |
#<=>(other) ⇒ Object
295 296 297 298 299 |
# File 'lib/openskill/models/bradley_terry_full.rb', line 295 def <=>(other) return nil unless other.is_a?(Rating) ordinal <=> other.ordinal end |
#==(other) ⇒ Object
325 326 327 328 329 |
# File 'lib/openskill/models/bradley_terry_full.rb', line 325 def ==(other) return false unless other.is_a?(Rating) @mu == other.mu && @sigma == other.sigma end |
#>(other) ⇒ Object
307 308 309 310 311 |
# File 'lib/openskill/models/bradley_terry_full.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/bradley_terry_full.rb', line 319 def >=(other) raise ArgumentError, "comparison with non-Rating" unless other.is_a?(Rating) ordinal >= other.ordinal end |
#eql?(other) ⇒ Boolean
335 336 337 |
# File 'lib/openskill/models/bradley_terry_full.rb', line 335 def eql?(other) self == other end |
#hash ⇒ Object
331 332 333 |
# File 'lib/openskill/models/bradley_terry_full.rb', line 331 def hash [@id, @mu, @sigma].hash end |
#inspect ⇒ Object
343 344 345 |
# File 'lib/openskill/models/bradley_terry_full.rb', line 343 def inspect to_s end |
#ordinal(z: 3.0, alpha: 1.0, target: 0.0) ⇒ Float
Calculate display rating (conservative estimate)
291 292 293 |
# File 'lib/openskill/models/bradley_terry_full.rb', line 291 def ordinal(z: 3.0, alpha: 1.0, target: 0.0) alpha * ((@mu - z * @sigma) + (target / alpha)) end |
#to_s ⇒ Object
339 340 341 |
# File 'lib/openskill/models/bradley_terry_full.rb', line 339 def to_s "Rating(mu=#{@mu}, sigma=#{@sigma}#{", name=#{@name}" if @name})" end |