Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ BOOST_MATH_GPU_ENABLED T ibeta_inv_imp(T a, T b, T p, T q, const Policy& pol, T*
{
if(b == 1)
{
if(py) *py = 1 - p;
if(py) *py = q;
return p;
}
// Change things around so we can handle as b == 1 special case below:
Expand Down
26 changes: 26 additions & 0 deletions test/test_fisher_f.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,32 @@ BOOST_AUTO_TEST_CASE( test_main )

} // BOOST_AUTO_TEST_CASE( test_main )

BOOST_AUTO_TEST_CASE( test_complement_quantile_df2_2 )
{
using namespace boost::math;
using no_promotion = policies::policy<
policies::promote_float<false>,
policies::promote_double<false>>;
const fisher_f_distribution<double, no_promotion> dist(2.0, 2.0);
const double tol = std::numeric_limits<double>::epsilon() * 16;

// For df1 = 2, df2 = 2, SF(x) = 1 / (1 + x), so quantile(complement(dist, q)) = 1 / q - 1.
for (double q : {1e-7, 1e-10, 1e-15, 3.85e-16, 1e-20, 1e-100, 1e-300})
{
const double expected = (1.0 - q) / q;
BOOST_CHECK_CLOSE_FRACTION(quantile(complement(dist, q)), expected, tol);
}

// Direct check on ibetac_inv(1, 1, q, &y) complement output y == q.
for (double q : {1e-7, 1e-15, 3.85e-16, 1e-20, 1e-300})
{
double y = 0.0;
const double x = ibetac_inv(1.0, 1.0, q, &y, no_promotion());
BOOST_CHECK_EQUAL(x, 1.0 - q);
BOOST_CHECK_EQUAL(y, q);
}
}

/*

Output is:
Expand Down