diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index a42dbee2a..3c283a201 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -979,10 +979,10 @@ test-suite misc : [ run signal_statistics_test.cpp : : : [ requires cxx17_if_constexpr cxx17_std_apply ] ] [ run anderson_darling_test.cpp : : : [ requires cxx17_if_constexpr cxx17_std_apply ] ] [ run ljung_box_test.cpp : : : [ requires cxx17_if_constexpr cxx17_std_apply ] ] - [ run test_t_test.cpp : : : [ requires cxx17_if_constexpr cxx17_std_apply ] ] - [ run test_z_test.cpp : : : [ requires cxx17_if_constexpr cxx17_std_apply ] ] - [ run bivariate_statistics_test.cpp : : : [ requires cxx11_hdr_forward_list cxx11_hdr_tuple cxx11_sfinae_expr ] ] - [ run linear_regression_test.cpp : : : [ requires cxx17_if_constexpr cxx17_std_apply ] ] + [ run test_t_test.cpp : : : [ requires cxx11_hdr_forward_list cxx11_hdr_atomic cxx11_hdr_thread cxx11_hdr_tuple cxx11_hdr_future cxx11_sfinae_expr ] ] + [ run test_z_test.cpp : : : [ requires cxx11_hdr_forward_list cxx11_hdr_atomic cxx11_hdr_thread cxx11_hdr_tuple cxx11_hdr_future cxx11_sfinae_expr ] ] + [ run bivariate_statistics_test.cpp : : : [ requires cxx11_hdr_forward_list cxx11_hdr_atomic cxx11_hdr_thread cxx11_hdr_tuple cxx11_hdr_future cxx11_sfinae_expr ] ] + [ run linear_regression_test.cpp : : : [ requires cxx11_hdr_forward_list cxx11_hdr_atomic cxx11_hdr_thread cxx11_hdr_tuple cxx11_hdr_future cxx11_sfinae_expr ] ] [ run test_runs_test.cpp : : : [ requires cxx17_if_constexpr cxx17_std_apply ] ] [ run lanczos_smoothing_test.cpp ../../test/build//boost_unit_test_framework : : : [ requires cxx17_if_constexpr cxx17_std_apply ] ] [ run condition_number_test.cpp ../../test/build//boost_unit_test_framework : : : [ requires cxx17_if_constexpr cxx17_std_apply ] ] diff --git a/test/bivariate_statistics_test.cpp b/test/bivariate_statistics_test.cpp index d28ccf923..19acb937e 100644 --- a/test/bivariate_statistics_test.cpp +++ b/test/bivariate_statistics_test.cpp @@ -21,11 +21,7 @@ #include #include #include - -#if __cplusplus > 201700L || _MSVC_LANG > 201700L #include -#define CPP17TESTS -#endif using boost::multiprecision::cpp_bin_float_50; using boost::multiprecision::cpp_complex_50; @@ -110,7 +106,6 @@ void test_covariance() v[i] = (Real) dis(gen); } - #ifdef CPP17TESTS Real mu_u = boost::math::statistics::mean(u); Real mu_v = boost::math::statistics::mean(v); Real sigma_u_sq = boost::math::statistics::variance(u); @@ -131,7 +126,6 @@ void test_covariance() BOOST_TEST(abs(cov_uu - sigma_u_sq) < tol); Real cov_vv = covariance(v, v); BOOST_TEST(abs(cov_vv - sigma_v_sq) < tol); - #endif } template @@ -202,7 +196,6 @@ void test_integer_covariance() v[i] = (Z) dis(gen); } - #ifdef CPP17TESTS double mu_u = boost::math::statistics::mean(u); double mu_v = boost::math::statistics::mean(v); double sigma_u_sq = boost::math::statistics::variance(u); @@ -223,7 +216,6 @@ void test_integer_covariance() BOOST_TEST(abs(cov_uu - sigma_u_sq) < tol); double cov_vv = covariance(v, v); BOOST_TEST(abs(cov_vv - sigma_v_sq) < tol); - #endif } template diff --git a/test/test_t_test.cpp b/test/test_t_test.cpp index 2e1b9c89f..e121cf01d 100644 --- a/test/test_t_test.cpp +++ b/test/test_t_test.cpp @@ -9,6 +9,7 @@ #include "math_unit_test.hpp" #include #include +#include #include #include #include @@ -31,7 +32,9 @@ void test_exact_mean() Real mu = boost::math::statistics::mean(v); - auto [computed_statistic, computed_pvalue] = boost::math::statistics::one_sample_t_test(v, mu); + std::pair temp = boost::math::statistics::one_sample_t_test(v, mu); + Real computed_statistic = std::get<0>(temp); + Real computed_pvalue = std::get<1>(temp); CHECK_MOLLIFIED_CLOSE(Real(0), computed_statistic, 10*std::numeric_limits::epsilon()); CHECK_ULP_CLOSE(Real(1), computed_pvalue, 9); @@ -49,7 +52,9 @@ void test_multiprecision_exact_mean() Real mu = boost::math::statistics::mean(v); - auto [computed_statistic, computed_pvalue] = boost::math::statistics::one_sample_t_test(v, mu); + std::pair temp = boost::math::statistics::one_sample_t_test(v, mu); + Real computed_statistic = std::get<0>(temp); + Real computed_pvalue = std::get<1>(temp); CHECK_MOLLIFIED_CLOSE(Real(0), computed_statistic, 15*std::numeric_limits::epsilon()); CHECK_ULP_CLOSE(Real(1), computed_pvalue, 25); @@ -59,7 +64,9 @@ template void test_integer() { // https://www.wolframalpha.com/input/?i=t+test - auto [computed_statistic, computed_pvalue] = boost::math::statistics::one_sample_t_test(Z(12), Z(5*5), Z(25), Z(10)); + std::pair temp = boost::math::statistics::one_sample_t_test(Z(12), Z(5*5), Z(25), Z(10)); + double computed_statistic = std::get<0>(temp); + double computed_pvalue = std::get<1>(temp); CHECK_MOLLIFIED_CLOSE(2.0, computed_statistic, 10*std::numeric_limits::epsilon()); CHECK_MOLLIFIED_CLOSE(0.02847*2, computed_pvalue, 0.00001); } @@ -98,7 +105,9 @@ void test_agreement_with_mathematica() double expected_statistic = 0.4587075249160456; double expected_pvalue = 0.6472282548266728; - auto [computed_statistic, computed_pvalue] = boost::math::statistics::one_sample_t_test(v, 0.0); + std::pair temp = boost::math::statistics::one_sample_t_test(v, 0.0); + double computed_statistic = std::get<0>(temp); + double computed_pvalue = std::get<1>(temp); CHECK_ULP_CLOSE(expected_statistic, computed_statistic, 8); CHECK_ULP_CLOSE(expected_pvalue, computed_pvalue, 90); @@ -110,7 +119,9 @@ void test_agreement_with_mathematica() expected_statistic = 2.103013485037935; expected_pvalue = 0.1701790440880712; - auto [computed_statistic, computed_pvalue] = boost::math::statistics::one_sample_t_test(v, 0.0); + std::pair temp = boost::math::statistics::one_sample_t_test(v, 0.0); + double computed_statistic = std::get<0>(temp); + double computed_pvalue = std::get<1>(temp); CHECK_ULP_CLOSE(expected_statistic, computed_statistic, 2); CHECK_ULP_CLOSE(expected_pvalue, computed_pvalue, 7); } @@ -119,15 +130,18 @@ void test_agreement_with_mathematica() template void test_two_sample_t() { - auto [computed_statistic, computed_pvalue] = + std::pair temp = boost::math::statistics::detail::two_sample_t_test_impl>(Real(10.0), Real(1.0), Real(20), Real(5.0), Real(0.25), Real(20)); - + Real computed_statistic = std::get<0>(temp); + Real computed_pvalue = std::get<1>(temp); CHECK_ULP_CLOSE(Real(20), computed_statistic, 5); CHECK_MOLLIFIED_CLOSE(Real(0), computed_pvalue, 1e-21); std::vector set_1 {301, 298, 295, 297, 304, 305, 309, 298, 291, 299, 293, 304}; - auto [computed_statistic_2, computed_pvalue_2] = boost::math::statistics::two_sample_t_test(set_1, set_1); + temp = boost::math::statistics::two_sample_t_test(set_1, set_1); + Real computed_statistic_2 = std::get<0>(temp); + Real computed_pvalue_2 = std::get<1>(temp); CHECK_ULP_CLOSE(Real(0), computed_statistic_2, 5); CHECK_ULP_CLOSE(Real(1), computed_pvalue_2, 5); } @@ -135,14 +149,16 @@ void test_two_sample_t() template void test_integer_two_sample_t() { - auto [computed_statistic, computed_pvalue] = + std::pair temp = boost::math::statistics::detail::two_sample_t_test_impl>(Z(10), Z(4), Z(20), Z(5), Z(1), Z(20)); - + double computed_statistic = std::get<0>(temp); CHECK_ULP_CLOSE(10.0, computed_statistic, 5); std::vector set_1 {301, 298, 295, 297, 304, 305, 309, 298, 291, 299, 293, 304}; - auto [computed_statistic_2, computed_pvalue_2] = boost::math::statistics::two_sample_t_test(set_1, set_1); + temp = boost::math::statistics::two_sample_t_test(set_1, set_1); + double computed_statistic_2 = std::get<0>(temp); + double computed_pvalue_2 = std::get<1>(temp); CHECK_ULP_CLOSE(0.0, computed_statistic_2, 5); CHECK_ULP_CLOSE(1.0, computed_pvalue_2, 5); } @@ -152,15 +168,16 @@ void test_welch() { using std::sqrt; - auto [computed_statistic, computed_pvalue] = + std::pair temp = boost::math::statistics::detail::welchs_t_test_impl>(Real(10.0), Real(1.0), Real(20), Real(5.0), Real(0.25), Real(20)); - + Real computed_statistic = std::get<0>(temp); + Real computed_pvalue = std::get<1>(temp); CHECK_ULP_CLOSE(Real(20), computed_statistic, 5); CHECK_MOLLIFIED_CLOSE(Real(0), computed_pvalue, 5e-18); - auto [computed_statistic_2, computed_pvalue_2] = - boost::math::statistics::detail::welchs_t_test_impl>(Real(10.0), Real(0.5), Real(20), Real(10.0), Real(0.5), Real(20)); - + temp = boost::math::statistics::detail::welchs_t_test_impl>(Real(10.0), Real(0.5), Real(20), Real(10.0), Real(0.5), Real(20)); + Real computed_statistic_2 = std::get<0>(temp); + Real computed_pvalue_2 = std::get<1>(temp); CHECK_ULP_CLOSE(Real(0), computed_statistic_2, 5); CHECK_ULP_CLOSE(Real(1), computed_pvalue_2, 5); } @@ -168,13 +185,14 @@ void test_welch() template void test_integer_welch() { - auto [computed_statistic, computed_pvalue] = + std::pair temp = boost::math::statistics::detail::welchs_t_test_impl>(10.0, 4.0, 20.0, 5.0, 1.0, 20.0); - + double computed_statistic = std::get<0>(temp); CHECK_ULP_CLOSE(10.0, computed_statistic, 5); - auto [computed_statistic_2, computed_pvalue_2] = - boost::math::statistics::detail::welchs_t_test_impl>(10.0, 0.5, 20.0, 10.0, 0.5, 20.0); + temp = boost::math::statistics::detail::welchs_t_test_impl>(10.0, 0.5, 20.0, 10.0, 0.5, 20.0); + double computed_statistic_2 = std::get<0>(temp); + double computed_pvalue_2 = std::get<1>(temp); CHECK_ULP_CLOSE(0.0, computed_statistic_2, 5); CHECK_ULP_CLOSE(1.0, computed_pvalue_2, 5); } @@ -185,8 +203,8 @@ void test_paired_samples() std::vector set_1 {2,4}; std::vector set_2 {1,2}; - auto [computed_statistic, computed_pvalue] = boost::math::statistics::paired_samples_t_test(set_1, set_2); - + std::pair temp = boost::math::statistics::paired_samples_t_test(set_1, set_2); + Real computed_statistic = std::get<0>(temp); CHECK_ULP_CLOSE(Real(3), computed_statistic, 5); } @@ -196,8 +214,8 @@ void test_integer_paired_samples() std::vector set_1 {2,4}; std::vector set_2 {1,2}; - auto [computed_statistic, computed_pvalue] = boost::math::statistics::paired_samples_t_test(set_1, set_2); - + std::pair temp = boost::math::statistics::paired_samples_t_test(set_1, set_2); + double computed_statistic = std::get<0>(temp); CHECK_ULP_CLOSE(3.0, computed_statistic, 5); } diff --git a/test/test_z_test.cpp b/test/test_z_test.cpp index 479a0cc67..1acbde8a0 100644 --- a/test/test_z_test.cpp +++ b/test/test_z_test.cpp @@ -10,31 +10,39 @@ #include #include #include +#include using quad = boost::multiprecision::cpp_bin_float_quad; template void test_one_sample_z() { - auto [computed_statistic, computed_pvalue] = boost::math::statistics::one_sample_z_test(Real(10), Real(2), Real(100), Real(10)); + std::pair temp = boost::math::statistics::one_sample_z_test(Real(10), Real(2), Real(100), Real(10)); + Real computed_statistic = std::get<0>(temp); + Real computed_pvalue = std::get<1>(temp); CHECK_ULP_CLOSE(Real(0), computed_statistic, 5); CHECK_MOLLIFIED_CLOSE(Real(0), computed_pvalue, 5*std::numeric_limits::epsilon()); - auto [computed_statistic_2, computed_pvalue_2] = boost::math::statistics::one_sample_z_test(Real(10), Real(2), Real(100), Real(5)); + temp = boost::math::statistics::one_sample_z_test(Real(10), Real(2), Real(100), Real(5)); + Real computed_statistic_2 = std::get<0>(temp); CHECK_ULP_CLOSE(Real(25), computed_statistic_2, 5); - auto [computed_statistic_3, computed_pvalue_3] = boost::math::statistics::one_sample_z_test(Real(1)/2, Real(10), Real(100), Real(1)/3); + temp = boost::math::statistics::one_sample_z_test(Real(1)/2, Real(10), Real(100), Real(1)/3); + Real computed_statistic_3 = std::get<0>(temp); CHECK_ULP_CLOSE(Real(1)/6, computed_statistic_3, 5); } template void test_integer_one_sample_z() { - auto [computed_statistic, computed_pvalue] = boost::math::statistics::one_sample_z_test(Z(10), Z(2), Z(100), Z(10)); + std::pair temp = boost::math::statistics::one_sample_z_test(Z(10), Z(2), Z(100), Z(10)); + double computed_statistic = std::get<0>(temp); + double computed_pvalue = std::get<1>(temp); CHECK_ULP_CLOSE(0.0, computed_statistic, 5); CHECK_MOLLIFIED_CLOSE(0.0, computed_pvalue, 5*std::numeric_limits::epsilon()); - auto [computed_statistic_2, computed_pvalue_2] = boost::math::statistics::one_sample_z_test(Z(10), Z(2), Z(100), Z(5)); + temp = boost::math::statistics::one_sample_z_test(Z(10), Z(2), Z(100), Z(5)); + double computed_statistic_2 = std::get<0>(temp); CHECK_ULP_CLOSE(25.0, computed_statistic_2, 5); } @@ -44,7 +52,9 @@ void test_two_sample_z() std::vector set_1 {1,2,3,4,5}; std::vector set_2 {2,3,4,5,6}; - auto [computed_statistic, computed_pvalue] = boost::math::statistics::two_sample_z_test(set_2, set_1); + std::pair temp = boost::math::statistics::two_sample_z_test(set_2, set_1); + Real computed_statistic = std::get<0>(temp); + Real computed_pvalue = std::get<1>(temp); CHECK_ULP_CLOSE(Real(1), computed_statistic, 5); CHECK_MOLLIFIED_CLOSE(Real(0), computed_pvalue, 5*std::numeric_limits::epsilon()); } @@ -55,7 +65,9 @@ void test_integer_two_sample_z() std::vector set_1 {1,2,3,4,5}; std::vector set_2 {2,3,4,5,6}; - auto [computed_statistic, computed_pvalue] = boost::math::statistics::two_sample_z_test(set_2, set_1); + std::pair temp = boost::math::statistics::two_sample_z_test(set_2, set_1); + double computed_statistic = std::get<0>(temp); + double computed_pvalue = std::get<1>(temp); CHECK_ULP_CLOSE(1.0, computed_statistic, 5); CHECK_MOLLIFIED_CLOSE(0.0, computed_pvalue, 5*std::numeric_limits::epsilon()); }