@@ -317,7 +317,7 @@ def _betainc_der_power_series(a, b, x, dtype, use_power_series):
317
317
"""Returns the partial derivatives of betainc with respect to a and b."""
318
318
# This function evaluates betainc(a, b, x) by its series representation:
319
319
# x ** a * 2F1(a, 1 - b; a + 1; x) / (a * B(a, b)) ,
320
- # where 2F1 is the Gauss series as defined here: http://dlmf.nist.gov/15.2.i
320
+ # where 2F1 is the Gaussian hypergeometric function.
321
321
# We apply this function when the input (a, b, x) satisfies at least one
322
322
# of the following conditions:
323
323
# C1: (x < a / (a + b)) & (b * x <= 1) & (x <= 0.95)
@@ -333,8 +333,8 @@ def _betainc_der_power_series(a, b, x, dtype, use_power_series):
333
333
safe_b = tf .where (use_power_series , b , half )
334
334
safe_x = tf .where (use_power_series , x , half )
335
335
336
- # When the condition C1 is false , we apply the symmetry relation given
337
- # here: https://dlmf.nist.gov/8.17.E4
336
+ # When x >= a / (a + b) , we must apply the symmetry relation given here:
337
+ # https://dlmf.nist.gov/8.17.E4
338
338
# betainc(a, b, x) = 1 - betainc(b, a, 1 - x)
339
339
use_symmetry_relation = (safe_x >= safe_a / (safe_a + safe_b ))
340
340
safe_a_orig = safe_a
@@ -427,13 +427,13 @@ def _betainc_partials(a, b, x):
427
427
x = tf .broadcast_to (x , broadcast_shape )
428
428
429
429
# The partial derivative of betainc with respect to x can be obtained
430
- # directly using the expression given here:
430
+ # directly by using the expression given here:
431
431
# http://functions.wolfram.com/06.21.20.0001.01
432
432
grad_x = tf .math .exp (
433
433
tf .math .xlogy (a - one , x ) + tf .math .xlog1py (b - one , - x ) - lbeta (a , b ))
434
434
435
435
# The partial derivatives of betainc with respect to a and b are computed
436
- # using forward mode.
436
+ # by using forward mode.
437
437
use_power_series = ((x < a / (a + b )) & (b * x <= 1. ) & (x <= 0.95 ) |
438
438
((x >= a / (a + b )) & (a * (1. - x ) <= 1. ) & (x >= 0.05 )))
439
439
ps_grad_a , ps_grad_b = _betainc_der_power_series (
0 commit comments