Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion include/boost/math/distributions/non_central_beta.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<RealType, Policy>(a, b), x);
{
if(x < y)
{
return invert
? cdf(complement(boost::math::beta_distribution<RealType, Policy>(a, b), x))
: cdf(boost::math::beta_distribution<RealType, Policy>(a, b), x);
}
return invert
? cdf(boost::math::beta_distribution<RealType, Policy>(b, a), y)
: cdf(complement(boost::math::beta_distribution<RealType, Policy>(b, a), y));
}
else if(x > cross)
{
// Complement is the smaller of the two:
Expand Down
3 changes: 3 additions & 0 deletions test/test_nc_f.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading