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

📄 test_students_t.cpp

📁 Boost provides free peer-reviewed portable C++ source libraries. We emphasize libraries that work
💻 CPP
📖 第 1 页 / 共 2 页
字号:
      ::boost::math::quantile(         complement(            students_t_distribution<RealType>(5.),  // degrees_of_freedom            static_cast<RealType>(0.7))),  // probability.         static_cast<RealType>(-0.559429644), // t         tolerance);   BOOST_CHECK_CLOSE( // Tests of p high.      ::boost::math::cdf(         students_t_distribution<RealType>(5.),  // degrees_of_freedom         static_cast<RealType>(1.475884049)),  // t         static_cast<RealType>(0.9), // probability.         tolerance);   BOOST_CHECK_CLOSE(      ::boost::math::quantile(         students_t_distribution<RealType>(5.),  // degrees_of_freedom         static_cast<RealType>(0.9)),  // probability.         static_cast<RealType>(1.475884049), // t         tolerance);   BOOST_CHECK_CLOSE( // Tests of p low.      ::boost::math::cdf(         students_t_distribution<RealType>(5.),  // degrees_of_freedom         static_cast<RealType>(-1.475884049)),  // t         static_cast<RealType>(0.1), // probability.         tolerance);   BOOST_CHECK_CLOSE(      ::boost::math::quantile(         students_t_distribution<RealType>(5.),  // degrees_of_freedom         static_cast<RealType>(0.1)),  // probability.         static_cast<RealType>(-1.475884049), // t         tolerance);   BOOST_CHECK_CLOSE(      ::boost::math::cdf(         students_t_distribution<RealType>(2.),  // degrees_of_freedom         static_cast<RealType>(-6.96455673428326)),  // t         static_cast<RealType>(0.01), // probability.         tolerance);   BOOST_CHECK_CLOSE(      ::boost::math::quantile(         students_t_distribution<RealType>(2.),  // degrees_of_freedom         static_cast<RealType>(0.01)),  // probability.         static_cast<RealType>(-6.96455673428326), // t         tolerance);  // Student's t pdf tests.  // for PDF checks, use 100 eps tolerance expressed as a percent:   tolerance = boost::math::tools::epsilon<RealType>() * 10000;   for(unsigned i = 1; i < 20; i += 3)   {      for(RealType r = -10; r < 10; r += 0.125)      {         //std::cout << "df=" << i << " t=" << r << std::endl;         BOOST_CHECK_CLOSE(            boost::math::pdf(               students_t_distribution<RealType>(static_cast<RealType>(i)),               r),            naive_pdf<RealType>(static_cast<RealType>(i), r),            tolerance);      }   }    RealType tol2 = boost::math::tools::epsilon<RealType>() * 5;    students_t_distribution<RealType> dist(8);    RealType x = static_cast<RealType>(0.125);    using namespace std; // ADL of std names.    // mean:    BOOST_CHECK_CLOSE(       mean(dist)       , static_cast<RealType>(0), tol2);    // variance:    BOOST_CHECK_CLOSE(       variance(dist)       , static_cast<RealType>(8.0L / 6.0L), tol2);    // std deviation:    BOOST_CHECK_CLOSE(       standard_deviation(dist)       , static_cast<RealType>(sqrt(8.0L / 6.0L)), 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_THROW(       coefficient_of_variation(dist),       std::overflow_error);    // mode:    BOOST_CHECK_CLOSE(       mean(dist)       , static_cast<RealType>(0), tol2);    // median:    BOOST_CHECK_CLOSE(       median(dist)       , static_cast<RealType>(0), tol2);    // skewness:    BOOST_CHECK_CLOSE(       skewness(dist)       , static_cast<RealType>(0), tol2);    // kurtosis:    BOOST_CHECK_CLOSE(       kurtosis(dist)       , static_cast<RealType>(4.5), tol2);    // kurtosis excess:    BOOST_CHECK_CLOSE(       kurtosis_excess(dist)       , static_cast<RealType>(1.5), tol2);    // Parameter estimation. These results are close to but    // not identical to those reported on the NIST website at    // http://www.itl.nist.gov/div898/handbook/prc/section2/prc222.htm    // the NIST results appear to be calculated using a normal    // approximation, which slightly under-estimates the degrees of    // freedom required, particularly when the result is small.    //    BOOST_CHECK_EQUAL(       ceil(students_t_distribution<RealType>::find_degrees_of_freedom(         static_cast<RealType>(0.5),         static_cast<RealType>(0.005),         static_cast<RealType>(0.01),         static_cast<RealType>(1.0))),         99);    BOOST_CHECK_EQUAL(       ceil(students_t_distribution<RealType>::find_degrees_of_freedom(         static_cast<RealType>(1.5),         static_cast<RealType>(0.005),         static_cast<RealType>(0.01),         static_cast<RealType>(1.0))),         14);    BOOST_CHECK_EQUAL(       ceil(students_t_distribution<RealType>::find_degrees_of_freedom(         static_cast<RealType>(0.5),         static_cast<RealType>(0.025),         static_cast<RealType>(0.01),         static_cast<RealType>(1.0))),         76);    BOOST_CHECK_EQUAL(       ceil(students_t_distribution<RealType>::find_degrees_of_freedom(         static_cast<RealType>(1.5),         static_cast<RealType>(0.025),         static_cast<RealType>(0.01),         static_cast<RealType>(1.0))),         11);    BOOST_CHECK_EQUAL(       ceil(students_t_distribution<RealType>::find_degrees_of_freedom(         static_cast<RealType>(0.5),         static_cast<RealType>(0.05),         static_cast<RealType>(0.01),         static_cast<RealType>(1.0))),         65);    BOOST_CHECK_EQUAL(       ceil(students_t_distribution<RealType>::find_degrees_of_freedom(         static_cast<RealType>(1.5),         static_cast<RealType>(0.05),         static_cast<RealType>(0.01),         static_cast<RealType>(1.0))),         9);} // template <class RealType>void test_spots(RealType)int test_main(int, char* []){  // Check that can construct students_t distribution using the two convenience methods:  using namespace boost::math;  students_t myst1(2); // Using typedef   students_t_distribution<> myst2(2); // Using default RealType double.   //students_t_distribution<double> myst3(2); // Using explicit RealType double.    // Basic sanity-check spot values.   // (Parameter value, arbitrarily zero, only communicates the floating point type).  test_spots(0.0F); // Test float. OK at decdigits = 0 tolerance = 0.0001 %  test_spots(0.0); // Test double. OK at decdigits 7, tolerance = 1e07 %#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#else   std::cout << "<note>The long double tests have been disabled on this platform "      "either because the long double overloads of the usual math functions are "      "not available at all, or because they are too inaccurate for these tests "      "to pass.</note>" << std::cout;#endif   return 0;} // int test_main(int, char* [])/*Autorun "i:\boost-06-05-03-1300\libs\math\test\Math_test\debug\test_students_t.exe"Running 1 test case...Tolerance for type float is 0.0001 %Tolerance for type double is 0.0001 %Tolerance for type long double is 0.0001 %Tolerance for type class boost::math::concepts::real_concept is 0.0001 %*** No errors detected*/

⌨️ 快捷键说明

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