From d18964d5aa968cea0742c4bb0dad99a3f2e37f3f Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Thu, 16 Nov 2023 09:38:11 +0100 Subject: [PATCH] Check update of xterm for denom of 0 --- include/boost/math/distributions/non_central_beta.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/boost/math/distributions/non_central_beta.hpp b/include/boost/math/distributions/non_central_beta.hpp index 9266c9e57..944f1dc24 100644 --- a/include/boost/math/distributions/non_central_beta.hpp +++ b/include/boost/math/distributions/non_central_beta.hpp @@ -212,7 +212,10 @@ namespace boost } pois *= i / l2; beta -= xterm; - xterm *= (a + i - 1) / (x * (a + b + i - 2)); + if (a + b + i - 2 != 0) + { + xterm *= (a + i - 1) / (x * (a + b + i - 2)); + } } return sum; }