From a920690a9f31b64e16fe1eb11caa2487f3ee4908 Mon Sep 17 00:00:00 2001 From: amyoshino Date: Mon, 14 Aug 2023 10:04:42 -0400 Subject: [PATCH 1/2] Fix docstrings reference for the betainc_grad function --- pytensor/scalar/math.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pytensor/scalar/math.py b/pytensor/scalar/math.py index 8dacc61f6f..dddfe9b9b4 100644 --- a/pytensor/scalar/math.py +++ b/pytensor/scalar/math.py @@ -1357,13 +1357,15 @@ def c_code(self, *args, **kwargs): def betainc_grad(p, q, x, wrtp: bool): - """Gradient of the regularized lower gamma function (P) wrt to the first - argument (k, a.k.a. alpha). + """Gradient of the regularized incomplete beta function (P) wrt to the + first and second arguments p (p, a.k.a. alpha) and q (q, a.k.a. beta). - Adapted from STAN `grad_reg_lower_inc_gamma.hpp` + Adapted from STAN `grad_reg_inc_beta.hpp` - Reference: Gautschi, W. (1979). A computational procedure for incomplete gamma functions. - ACM Transactions on Mathematical Software (TOMS), 5(4), 466-481. + Reference: [DLMF] NIST Digital Library of Mathematical Functions, Subsection 8.17(ii). + https://dlmf.nist.gov/8.17#ii, Release 1.1.10 of 2023-06-15. F. W. J. Olver, A. B. Olde Daalhuis, + D. W. Lozier, B. I. Schneider, R. F. Boisvert, C. W. Clark, B. R. Miller, B. V. Saunders, + H. S. Cohl, and M. A. McClain, eds. """ def _betainc_der(p, q, x, wrtp, skip_loop): From e9084976161f1a74889f514e47a8aabbcecd284d Mon Sep 17 00:00:00 2001 From: amyoshino Date: Mon, 14 Aug 2023 13:02:11 -0400 Subject: [PATCH 2/2] Fixing reference in suggested docstring --- pytensor/scalar/math.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/pytensor/scalar/math.py b/pytensor/scalar/math.py index dddfe9b9b4..22ec00defa 100644 --- a/pytensor/scalar/math.py +++ b/pytensor/scalar/math.py @@ -1357,15 +1357,13 @@ def c_code(self, *args, **kwargs): def betainc_grad(p, q, x, wrtp: bool): - """Gradient of the regularized incomplete beta function (P) wrt to the - first and second arguments p (p, a.k.a. alpha) and q (q, a.k.a. beta). - - Adapted from STAN `grad_reg_inc_beta.hpp` + """ + Gradient of the regularized incomplete beta function wrt to the first + argument `p` (aka alpha) or the second argument `q` (aka beta), + depending on whether `wrtp` is true. - Reference: [DLMF] NIST Digital Library of Mathematical Functions, Subsection 8.17(ii). - https://dlmf.nist.gov/8.17#ii, Release 1.1.10 of 2023-06-15. F. W. J. Olver, A. B. Olde Daalhuis, - D. W. Lozier, B. I. Schneider, R. F. Boisvert, C. W. Clark, B. R. Miller, B. V. Saunders, - H. S. Cohl, and M. A. McClain, eds. + Reference: Boik, R. J., & Robison-Cox, J. F. (1998). Derivatives of the incomplete beta function. + Journal of Statistical Software, 3(1), 1-20. """ def _betainc_der(p, q, x, wrtp, skip_loop):