From 11418786f58b8f2696cbc5268a2403ebbab6a565 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Thu, 11 Jan 2024 12:55:54 -0800 Subject: [PATCH] Use base-e (not 10) in expected_win_probability Change `expected_win_probability` to use base-e (instead of base-10), to match Glicko-2. `v5_glicko2_update` was already (correctly) using base-e. This follow-up to 87c3fa8fb4129bd6d70d2c2e635f6237b1f3f227 gets handles the math domain error from tallying results on large small board handicaps. The base-10 bug made the expected win rate 1.0 (100%). Of course, it's still possible to skip large handicap games when tallying results... but no longer necessary. --- goratings/math/glicko2.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/goratings/math/glicko2.py b/goratings/math/glicko2.py index ecbd3e3..a8da7b5 100644 --- a/goratings/math/glicko2.py +++ b/goratings/math/glicko2.py @@ -72,15 +72,9 @@ def g(rd: float) -> float: return 1 / sqrt(1 + 3 * q ** 2 * (self.deviation ** 2) / pi ** 2) E = 1 / ( - 1 - + ( - 10 - ** ( - -g(sqrt(self.deviation ** 2 + white.deviation ** 2)) + 1 + exp(-g(sqrt(self.deviation ** 2 + white.deviation ** 2)) * (self.rating + handicap_adjustment - white.rating) - / 400 - ) - ) + / 400) ) return E