glandfried / TrueSkillThroughTime.py

The TrueSkill Through Time Python Package
https://trueskillthroughtime.readthedocs.io/en/latest/
Other
30 stars 7 forks source link

Handling ZeroDivisionError in the v_w Function #9

Open apiss2 opened 1 month ago

apiss2 commented 1 month ago

Handling ZeroDivisionError in the v_w Function

It is possible that cdf(-_alpha, 0, 1) or (cdf(_beta, 0, 1) - cdf(_alpha, 0, 1)) could become zero. What values of v or w are expected when a division by zero occurs?

Additionally, due to floating-point calculation errors, w might exceed 1. In such cases, the math.sqrt(1-w) within the trunc function might throw an error. Is it necessary to implement special handling for cases where w exceeds 1?

glandfried commented 1 month ago

The method v_w it is used to computes the mean and variance of a truncated Gaussian. This is a well known problem so maybe we can use a tested solution of another package, to ensure no error. Did you encounter a specific ZeroDivisionError in the v_w function? If so, do you can replicate the bug?

It is a good point to avoid possible floting-point caclutations errors that may occur for example in math.sqrt(1-w).