提交 2f96f2bb authored 作者: Ricardo's avatar Ricardo 提交者: Thomas Wiecki

Tweak betainc_der impl

上级 99fbef6e
...@@ -1083,7 +1083,7 @@ betainc = BetaInc(upgrade_to_float_no_complex, name="betainc") ...@@ -1083,7 +1083,7 @@ betainc = BetaInc(upgrade_to_float_no_complex, name="betainc")
class BetaIncDer(ScalarOp): class BetaIncDer(ScalarOp):
""" """
Gradient of the regularized incomplete beta function wrt to the first Gradient of the regularized incomplete beta function wrt to the first
argument (alpha) or the second argument (bbeta), depending on whether the argument (alpha) or the second argument (beta), depending on whether the
fourth argument to betainc_der is `True` or `False`, respectively. fourth argument to betainc_der is `True` or `False`, respectively.
Reference: Boik, R. J., & Robison-Cox, J. F. (1998). Derivatives of the incomplete beta function. Reference: Boik, R. J., & Robison-Cox, J. F. (1998). Derivatives of the incomplete beta function.
...@@ -1253,16 +1253,13 @@ class BetaIncDer(ScalarOp): ...@@ -1253,16 +1253,13 @@ class BetaIncDer(ScalarOp):
derivative_old = derivative derivative_old = derivative
if d_errapx <= err_threshold: if d_errapx <= err_threshold:
break return derivative
if n >= max_iters: warnings.warn(
warnings.warn( f"betainc_der did not converge after {n} iterations",
f"_betainc_derivative did not converge after {n} iterations", RuntimeWarning,
RuntimeWarning, )
) return np.nan
return np.nan
return derivative
betainc_der = BetaIncDer(upgrade_to_float_no_complex, name="betainc_der") betainc_der = BetaIncDer(upgrade_to_float_no_complex, name="betainc_der")
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论