#40653·jax

当 min(a, b)/max(a, b) 为次舍入数时, betaln(a, b) 会比 min(a, b) 大得多

作者: nstarman创建于 2026年9月14日更新于 2026年9月14日

jax/_src/third_party/scipy/betaln.py, in algdiv:

h = a / b
...
d = b + (a - 0.5)
...
u = d * lax.log1p(a / b)

XLA flushes subnormals to zero, so once a / b is subnormal the quotient becomes 0, log1p(0) is 0, and u is dropped entirely — where its true value is d * (a/b) ≈ b * (a/b) = a. Hence an error of exactly a, and since betaln sorts its arguments with a, b = minimum(a, b), maximum(a, b), exactly min(a, b) as seen by the caller.