add decay when results are empty and retab file
This commit is contained in:
1 parent
5b64f13b89
commit
cbe79afd1f
2 files changed
+10
-8
No files matched your search
+7
-5
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby -w
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -136,9 +136,6 @@ class Glicko2
|
|||||||
add_result(opponent,Glicko2::DRAW)
|
add_result(opponent,Glicko2::DRAW)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Update rating based on current results list, and clear results.
|
|
||||||
def update
|
|
||||||
|
|
||||||
# util func
|
# util func
|
||||||
def Glicko2.g(deviation)
|
def Glicko2.g(deviation)
|
||||||
1.0 / (Math.sqrt(1.0 + 3.0 * deviation ** 2.0 / (Math::PI ** 2.0)))
|
1.0 / (Math.sqrt(1.0 + 3.0 * deviation ** 2.0 / (Math::PI ** 2.0)))
|
||||||
@@ -149,9 +146,14 @@ class Glicko2
|
|||||||
1.0 / (1.0 + Math.exp(-Glicko2.g(deviation_opponent)*(rating - rating_opponent)));
|
1.0 / (1.0 + Math.exp(-Glicko2.g(deviation_opponent)*(rating - rating_opponent)));
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Update rating based on current results list, and clear results.
|
||||||
|
def update
|
||||||
|
# util func
|
||||||
|
|
||||||
# bail if no opponents set
|
# bail if no opponents set
|
||||||
if @results.empty?
|
if @results.empty?
|
||||||
return nil
|
@g2deviation = Math.sqrt(@g2deviation**2.0 + @g2volatility**2.0)
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
# compute variance
|
# compute variance
|
||||||
|
|||||||
Regular → Executable
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby -w
|
||||||
|
|
||||||
require 'glicko2'
|
require_relative 'glicko2'
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
|
|
||||||
class TestGlicko2 < Test::Unit::TestCase
|
class TestGlicko2 < Test::Unit::TestCase
|
||||||
@@ -26,7 +26,7 @@ class TestGlicko2 < Test::Unit::TestCase
|
|||||||
a.update()
|
a.update()
|
||||||
|
|
||||||
assert_in_delta(1464.05,a.rating,0.01)
|
assert_in_delta(1464.05,a.rating,0.01)
|
||||||
assert_in_delta(151.516,a.deviation,0.01)
|
assert_in_delta(151.875,a.deviation,0.01)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user