Class: OpenSkill::Models::BradleyTerryPart::Rating
- Inherits:
-
Object
- Object
- OpenSkill::Models::BradleyTerryPart::Rating
- Defined in:
- lib/openskill/models/bradley_terry_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.
281 282 283 284 285 286 |
# File 'lib/openskill/models/bradley_terry_part.rb', line 281 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.
279 280 281 |
# File 'lib/openskill/models/bradley_terry_part.rb', line 279 def id @id end |
#mu ⇒ Object
Returns the value of attribute mu.
278 279 280 |
# File 'lib/openskill/models/bradley_terry_part.rb', line 278 def mu @mu end |
#name ⇒ Object
Returns the value of attribute name.
278 279 280 |
# File 'lib/openskill/models/bradley_terry_part.rb', line 278 def name @name end |
#sigma ⇒ Object
Returns the value of attribute sigma.
278 279 280 |
# File 'lib/openskill/models/bradley_terry_part.rb', line 278 def sigma @sigma end |
Instance Method Details
#<(other) ⇒ Object
304 305 306 307 308 |
# File 'lib/openskill/models/bradley_terry_part.rb', line 304 def <(other) raise ArgumentError, 'comparison with non-Rating' unless other.is_a?(Rating) ordinal < other.ordinal end |
#<=(other) ⇒ Object
316 317 318 319 320 |
# File 'lib/openskill/models/bradley_terry_part.rb', line 316 def <=(other) raise ArgumentError, 'comparison with non-Rating' unless other.is_a?(Rating) ordinal <= other.ordinal end |
#<=>(other) ⇒ Object
298 299 300 301 302 |
# File 'lib/openskill/models/bradley_terry_part.rb', line 298 def <=>(other) return nil unless other.is_a?(Rating) ordinal <=> other.ordinal end |
#==(other) ⇒ Object
328 329 330 331 332 |
# File 'lib/openskill/models/bradley_terry_part.rb', line 328 def ==(other) return false unless other.is_a?(Rating) @mu == other.mu && @sigma == other.sigma end |
#>(other) ⇒ Object
310 311 312 313 314 |
# File 'lib/openskill/models/bradley_terry_part.rb', line 310 def >(other) raise ArgumentError, 'comparison with non-Rating' unless other.is_a?(Rating) ordinal > other.ordinal end |
#>=(other) ⇒ Object
322 323 324 325 326 |
# File 'lib/openskill/models/bradley_terry_part.rb', line 322 def >=(other) raise ArgumentError, 'comparison with non-Rating' unless other.is_a?(Rating) ordinal >= other.ordinal end |
#eql?(other) ⇒ Boolean
338 339 340 |
# File 'lib/openskill/models/bradley_terry_part.rb', line 338 def eql?(other) self == other end |
#hash ⇒ Object
334 335 336 |
# File 'lib/openskill/models/bradley_terry_part.rb', line 334 def hash [@id, @mu, @sigma].hash end |
#inspect ⇒ Object
346 347 348 |
# File 'lib/openskill/models/bradley_terry_part.rb', line 346 def inspect to_s end |
#ordinal(z: 3.0, alpha: 1.0, target: 0.0) ⇒ Float
Calculate display rating (conservative estimate)
294 295 296 |
# File 'lib/openskill/models/bradley_terry_part.rb', line 294 def ordinal(z: 3.0, alpha: 1.0, target: 0.0) alpha * ((@mu - z * @sigma) + (target / alpha)) end |
#to_s ⇒ Object
342 343 344 |
# File 'lib/openskill/models/bradley_terry_part.rb', line 342 def to_s "Rating(mu=#{@mu}, sigma=#{@sigma}#{", name=#{@name}" if @name})" end |