From 9b914aeed32aecac173b85635bc37142388c108d Mon Sep 17 00:00:00 2001 From: Nick Thompson Date: Tue, 15 Sep 2026 19:37:05 -0700 Subject: [PATCH 1/2] Submit failing unit test for Issue 1463. --- test/test_nc_f.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/test_nc_f.cpp b/test/test_nc_f.cpp index 7ad45c1ba3..7ed04ba883 100644 --- a/test/test_nc_f.cpp +++ b/test/test_nc_f.cpp @@ -336,6 +336,9 @@ void test_spots(RealType, const char* name = nullptr) for (RealType x : x_vals) { RealType P = cdf(dist_no_centrality, x); + RealType Q = cdf(complement(dist_no_centrality, x)); + // Regression test for #1463: CDF and CCDF must remain complementary for nc=0. + BOOST_CHECK_CLOSE(P + Q, RealType(1), tolerance); BOOST_CHECK_LE(dist.find_non_centrality(x, a, b, P), tolerance); } // Case when P=1 or P=0 From 4d6672161d655135cf2ac163b00a030c48bf4ce6 Mon Sep 17 00:00:00 2001 From: Nick Thompson Date: Tue, 15 Sep 2026 19:43:26 -0700 Subject: [PATCH 2/2] cdf(x) + complement(cdf(x)) == 1 --- .../boost/math/distributions/non_central_beta.hpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/include/boost/math/distributions/non_central_beta.hpp b/include/boost/math/distributions/non_central_beta.hpp index 00938ab9e4..b78da0521d 100644 --- a/include/boost/math/distributions/non_central_beta.hpp +++ b/include/boost/math/distributions/non_central_beta.hpp @@ -257,7 +257,17 @@ namespace boost value_type c = a + b + l / 2; value_type cross = 1 - (b / c) * (1 + l / (2 * c * c)); if(l == 0) - result = cdf(boost::math::beta_distribution(a, b), x); + { + if(x < y) + { + return invert + ? cdf(complement(boost::math::beta_distribution(a, b), x)) + : cdf(boost::math::beta_distribution(a, b), x); + } + return invert + ? cdf(boost::math::beta_distribution(b, a), y) + : cdf(complement(boost::math::beta_distribution(b, a), y)); + } else if(x > cross) { // Complement is the smaller of the two: