Skip to content

Commit ba137b3

Browse files
Improve code comments
1 parent 4d6d80b commit ba137b3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tensorflow_probability/python/math/special.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ def _betainc_der_power_series(a, b, x, dtype, use_power_series):
317317
"""Returns the partial derivatives of betainc with respect to a and b."""
318318
# This function evaluates betainc(a, b, x) by its series representation:
319319
# 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.
321321
# We apply this function when the input (a, b, x) satisfies at least one
322322
# of the following conditions:
323323
# 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):
333333
safe_b = tf.where(use_power_series, b, half)
334334
safe_x = tf.where(use_power_series, x, half)
335335

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
338338
# betainc(a, b, x) = 1 - betainc(b, a, 1 - x)
339339
use_symmetry_relation = (safe_x >= safe_a / (safe_a + safe_b))
340340
safe_a_orig = safe_a
@@ -427,13 +427,13 @@ def _betainc_partials(a, b, x):
427427
x = tf.broadcast_to(x, broadcast_shape)
428428

429429
# 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:
431431
# http://functions.wolfram.com/06.21.20.0001.01
432432
grad_x = tf.math.exp(
433433
tf.math.xlogy(a - one, x) + tf.math.xlog1py(b - one, -x) - lbeta(a, b))
434434

435435
# The partial derivatives of betainc with respect to a and b are computed
436-
# using forward mode.
436+
# by using forward mode.
437437
use_power_series = ((x < a / (a + b)) & (b * x <= 1.) & (x <= 0.95) |
438438
((x >= a / (a + b)) & (a * (1. - x) <= 1.) & (x >= 0.05)))
439439
ps_grad_a, ps_grad_b = _betainc_der_power_series(

0 commit comments

Comments
 (0)