⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test_fisher_f.cpp

📁 Boost provides free peer-reviewed portable C++ source libraries. We emphasize libraries that work
💻 CPP
📖 第 1 页 / 共 2 页
字号:
         static_cast<RealType>(2.)),  // df2         static_cast<RealType>(3.))),  // F      static_cast<RealType>(0.25L), // probability.      tolerance);   BOOST_CHECK_CLOSE(      cdf(complement(fisher_f_distribution<RealType>(         static_cast<RealType>(2.),  // df1         static_cast<RealType>(2.)),  // df2         static_cast<RealType>(7.))),  // F      static_cast<RealType>(0.125L), // probability.      tolerance);   BOOST_CHECK_CLOSE(      cdf(complement(fisher_f_distribution<RealType>(         static_cast<RealType>(2.),  // df1         static_cast<RealType>(2.)),  // df2         static_cast<RealType>(9.))),  // F      static_cast<RealType>(0.1L), // probability.      tolerance);   BOOST_CHECK_CLOSE(      cdf(complement(fisher_f_distribution<RealType>(         static_cast<RealType>(2.),  // df1         static_cast<RealType>(2.)),  // df2         static_cast<RealType>(19.))),  // F      static_cast<RealType>(0.05L), // probability.      tolerance);   BOOST_CHECK_CLOSE(      cdf(complement(fisher_f_distribution<RealType>(         static_cast<RealType>(2.),  // df1         static_cast<RealType>(2.)),  // df2         static_cast<RealType>(29.))),  // F      static_cast<RealType>(0.03333333333333333333333333333333333333333L), // probability.      tolerance);   BOOST_CHECK_CLOSE(      cdf(complement(fisher_f_distribution<RealType>(         static_cast<RealType>(2.),  // df1         static_cast<RealType>(2.)),  // df2         static_cast<RealType>(99.))),  // F      static_cast<RealType>(0.01L), // probability.       tolerance);   BOOST_CHECK_CLOSE(      cdf(complement(fisher_f_distribution<RealType>(         static_cast<RealType>(4.),  // df1         static_cast<RealType>(4.)),  // df2         static_cast<RealType>(9.))),  // F      static_cast<RealType>(0.028L), // probability.       tolerance*10);   // not quite exact???   BOOST_CHECK_CLOSE(      cdf(complement(fisher_f_distribution<RealType>(         static_cast<RealType>(8.),  // df1         static_cast<RealType>(8.)),  // df2         static_cast<RealType>(1.))),  // F      static_cast<RealType>(0.5L), // probability.       tolerance);// Inverse tests      BOOST_CHECK_CLOSE(      quantile(complement(fisher_f_distribution<RealType>(         static_cast<RealType>(2.),  // df1         static_cast<RealType>(2.)),  // df2         static_cast<RealType>(0.03333333333333333333333333333333333333333L))),  // probability      static_cast<RealType>(29.), // F expected.      tolerance*10);      BOOST_CHECK_CLOSE(      quantile(fisher_f_distribution<RealType>(         static_cast<RealType>(2.),  // df1         static_cast<RealType>(2.)),  // df2         static_cast<RealType>(1.0L - 0.03333333333333333333333333333333333333333L)),  // probability      static_cast<RealType>(29.), // F expected.      tolerance*10);// Also note limit cases for F(1, infinity) == normal distribution// F(1, n2) == Student's t distribution// F(n1, infinity) == Chisq distribution// These might allow some further cross checks?    RealType tol2 = boost::math::tools::epsilon<RealType>() * 5 * 100;  // 5 eps as a percent    cout << "Tolerance = " << tol2 << "%." << endl;    fisher_f_distribution<RealType> dist(static_cast<RealType>(8), static_cast<RealType>(6));    RealType x = 7;    using namespace std; // ADL of std names.    // mean:    BOOST_CHECK_CLOSE(       mean(dist)       , static_cast<RealType>(6)/static_cast<RealType>(4), tol2);    // variance:    BOOST_CHECK_CLOSE(       variance(dist)       , static_cast<RealType>(2 * 6 * 6 * (8 + 6 - 2)) / static_cast<RealType>(8 * 16 * 2), tol2);    // std deviation:    BOOST_CHECK_CLOSE(       standard_deviation(dist)       , sqrt(static_cast<RealType>(2 * 6 * 6 * (8 + 6 - 2)) / static_cast<RealType>(8 * 16 * 2)), tol2);    // hazard:    BOOST_CHECK_CLOSE(       hazard(dist, x)       , pdf(dist, x) / cdf(complement(dist, x)), tol2);    // cumulative hazard:    BOOST_CHECK_CLOSE(       chf(dist, x)       , -log(cdf(complement(dist, x))), tol2);    // coefficient_of_variation:    BOOST_CHECK_CLOSE(       coefficient_of_variation(dist)       , standard_deviation(dist) / mean(dist), tol2);    BOOST_CHECK_CLOSE(       mode(dist)       , static_cast<RealType>(6*6)/static_cast<RealType>(8*8), tol2);    fisher_f_distribution<RealType> dist2(static_cast<RealType>(8), static_cast<RealType>(12));    BOOST_CHECK_CLOSE(       skewness(dist2)       , static_cast<RealType>(26 * sqrt(64.0L)) / (12*6), tol2);    BOOST_CHECK_CLOSE(       kurtosis_excess(dist2)       , static_cast<RealType>(6272) * 12 / 3456, tol2);    BOOST_CHECK_CLOSE(       kurtosis(dist2)       , static_cast<RealType>(6272) * 12 / 3456 + 3, tol2);    // special cases:    BOOST_CHECK_THROW(       pdf(          fisher_f_distribution<RealType>(static_cast<RealType>(1), static_cast<RealType>(1)),          static_cast<RealType>(0)), std::overflow_error       );    BOOST_CHECK_EQUAL(       pdf(fisher_f_distribution<RealType>(2, 2), static_cast<RealType>(0))       , static_cast<RealType>(1.0f));    BOOST_CHECK_EQUAL(       pdf(fisher_f_distribution<RealType>(3, 3), static_cast<RealType>(0))       , static_cast<RealType>(0.0f));    BOOST_CHECK_EQUAL(       cdf(fisher_f_distribution<RealType>(1, 1), static_cast<RealType>(0))       , static_cast<RealType>(0.0f));    BOOST_CHECK_EQUAL(       cdf(fisher_f_distribution<RealType>(2, 2), static_cast<RealType>(0))       , static_cast<RealType>(0.0f));    BOOST_CHECK_EQUAL(       cdf(fisher_f_distribution<RealType>(3, 3), static_cast<RealType>(0))       , static_cast<RealType>(0.0f));    BOOST_CHECK_EQUAL(       cdf(complement(fisher_f_distribution<RealType>(1, 1), static_cast<RealType>(0)))       , static_cast<RealType>(1));    BOOST_CHECK_EQUAL(       cdf(complement(fisher_f_distribution<RealType>(2, 2), static_cast<RealType>(0)))       , static_cast<RealType>(1));    BOOST_CHECK_EQUAL(       cdf(complement(fisher_f_distribution<RealType>(3, 3), static_cast<RealType>(0)))       , static_cast<RealType>(1));    BOOST_CHECK_THROW(       pdf(          fisher_f_distribution<RealType>(-1, 2),          static_cast<RealType>(1)), std::domain_error       );    BOOST_CHECK_THROW(       pdf(          fisher_f_distribution<RealType>(1, -1),          static_cast<RealType>(1)), std::domain_error       );    BOOST_CHECK_THROW(       pdf(          fisher_f_distribution<RealType>(8, 2),          static_cast<RealType>(-1)), std::domain_error       );    BOOST_CHECK_THROW(       cdf(          fisher_f_distribution<RealType>(-1, 1),          static_cast<RealType>(1)), std::domain_error       );    BOOST_CHECK_THROW(       cdf(          fisher_f_distribution<RealType>(8, 4),          static_cast<RealType>(-1)), std::domain_error       );    BOOST_CHECK_THROW(       cdf(complement(          fisher_f_distribution<RealType>(-1, 2),          static_cast<RealType>(1))), std::domain_error       );    BOOST_CHECK_THROW(       cdf(complement(          fisher_f_distribution<RealType>(8, 4),          static_cast<RealType>(-1))), std::domain_error       );    BOOST_CHECK_THROW(       quantile(          fisher_f_distribution<RealType>(-1, 2),          static_cast<RealType>(0.5)), std::domain_error       );    BOOST_CHECK_THROW(       quantile(          fisher_f_distribution<RealType>(8, 8),          static_cast<RealType>(-1)), std::domain_error       );    BOOST_CHECK_THROW(       quantile(          fisher_f_distribution<RealType>(8, 8),          static_cast<RealType>(1.1)), std::domain_error       );    BOOST_CHECK_THROW(       quantile(complement(          fisher_f_distribution<RealType>(2, -1),          static_cast<RealType>(0.5))), std::domain_error       );    BOOST_CHECK_THROW(       quantile(complement(          fisher_f_distribution<RealType>(8, 8),          static_cast<RealType>(-1))), std::domain_error       );    BOOST_CHECK_THROW(       quantile(complement(          fisher_f_distribution<RealType>(8, 8),          static_cast<RealType>(1.1))), std::domain_error       );} // template <class RealType>void test_spots(RealType)int test_main(int, char* []){  // Check that can generate fisher distribution using the two convenience methods:   boost::math::fisher_f myf1(1., 2); // Using typedef   fisher_f_distribution<> myf2(1., 2); // Using default RealType double.  // Basic sanity-check spot values.  // (Parameter value, arbitrarily zero, only communicates the floating point type).  test_spots(0.0F); // Test float.  test_spots(0.0); // Test double.#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS  test_spots(0.0L); // Test long double.#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))  test_spots(boost::math::concepts::real_concept(0.)); // Test real concept.#endif#endif  return 0;} // int test_main(int, char* [])/*Output is:Autorun "i:\boost-06-05-03-1300\libs\math\test\Math_test\debug\test_fisher.exe"Running 1 test case...Tolerance = 0.2%.Tolerance = 5.96046e-005%.Tolerance = 5.96046e-005%.Tolerance = 0.2%.Tolerance = 1.11022e-013%.Tolerance = 1.11022e-013%.Tolerance = 0.2%.Tolerance = 1.11022e-013%.Tolerance = 1.11022e-013%.Tolerance = 0.2%.Tolerance = 1.11022e-013%.Tolerance = 1.11022e-013%.*** No errors detected*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -