Source code for openskill.statistics

import sys

import scipy.stats

normal = scipy.stats.norm(0, 1)


[docs]def phi_major(x): return normal.cdf(x)
[docs]def phi_minor(x): return normal.pdf(x)
[docs]def v(x, t): xt = x - t denom = phi_major(xt) return -xt if (denom < sys.float_info.epsilon) else phi_minor(xt) / denom
[docs]def w(x, t): xt = x - t denom = phi_major(xt) if denom < sys.float_info.epsilon: return 1 if (x < 0) else 0 return v(x, t) * (v(x, t) + xt)
[docs]def vt(x, t): xx = abs(x) b = phi_major(t - xx) - phi_major(-t - xx) if b < 1e-5: if x < 0: return -x - t return -x + t a = phi_minor(-t - xx) - phi_minor(t - xx) return (-a if x < 0 else a) / b
[docs]def wt(x, t): xx = abs(x) b = phi_major(t - xx) - phi_major(-t - xx) if b < sys.float_info.epsilon: return 1.0 return ((t - xx) * phi_minor(t - xx) + (t + xx) * phi_minor(-t - xx)) / b + vt( x, t ) * vt(x, t)