diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 4adb29d160..9d7625786f 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -194,6 +194,7 @@ test-suite special_fun : [ run git_issue_1139.cpp ] [ run git_issue_1175.cpp ] [ run git_issue_1194.cpp ] + [ run git_issue_1203.cpp ] [ run special_functions_test.cpp /boost/test//boost_unit_test_framework ] [ run test_airy.cpp test_instances//test_instances pch_light /boost/test//boost_unit_test_framework ] [ run test_bessel_j.cpp test_instances//test_instances pch_light /boost/test//boost_unit_test_framework ] diff --git a/test/git_issue_1203.cpp b/test/git_issue_1203.cpp new file mode 100644 index 0000000000..76004294ef --- /dev/null +++ b/test/git_issue_1203.cpp @@ -0,0 +1,48 @@ +// (C) Copyright Matt Borland 2024. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// See: https://github.com/boostorg/math/issues/1203 + +#include "math_unit_test.hpp" +#include + +int main() +{ + constexpr auto mean = 2719.3; + + const auto dist = boost::math::poisson_distribution<>(mean); + + // Generated from: Quantile[PoissonDistribution[2719.13], p] + + // Passing before issue (p >= .50): + CHECK_ULP_CLOSE(boost::math::quantile(dist, 0.54), 2724.0, 10); + CHECK_ULP_CLOSE(boost::math::quantile(dist, 0.53), 2723.0, 10); + CHECK_ULP_CLOSE(boost::math::quantile(dist, 0.52), 2722.0, 10); + CHECK_ULP_CLOSE(boost::math::quantile(dist, 0.51), 2720.0, 10); + CHECK_ULP_CLOSE(boost::math::quantile(dist, 0.50), 2719.0, 10); + + // Failing before issue (p < .50): + CHECK_ULP_CLOSE(boost::math::quantile(dist, 0.49), 2718.0, 10); + CHECK_ULP_CLOSE(boost::math::quantile(dist, 0.48), 2716.0, 10); + CHECK_ULP_CLOSE(boost::math::quantile(dist, 0.47), 2715.0, 10); + + CHECK_ULP_CLOSE(boost::math::quantile(dist, 0.04), 2628.0, 10); + CHECK_ULP_CLOSE(boost::math::quantile(dist, 0.03), 2621.0, 10); + CHECK_ULP_CLOSE(boost::math::quantile(dist, 0.02), 2613.0, 10); + CHECK_ULP_CLOSE(boost::math::quantile(dist, 0.01), 2599.0, 10); + + // Check with smaller mean + constexpr auto mean_2 = 12.0; + const auto dist_2 = boost::math::poisson_distribution<>(mean_2); + + CHECK_ULP_CLOSE(boost::math::quantile(dist_2, 0.54), 12.0, 10); + CHECK_ULP_CLOSE(boost::math::quantile(dist_2, 0.53), 12.0, 10); + CHECK_ULP_CLOSE(boost::math::quantile(dist_2, 0.52), 12.0, 10); + CHECK_ULP_CLOSE(boost::math::quantile(dist_2, 0.40), 11.0, 10); + CHECK_ULP_CLOSE(boost::math::quantile(dist_2, 0.30), 10.0, 10); + CHECK_ULP_CLOSE(boost::math::quantile(dist_2, 0.20), 09.0, 10); + + return boost::math::test::report_errors(); +}