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

📄 test_cauchy.cpp

📁 Boost provides free peer-reviewed portable C++ source libraries. We emphasize libraries that work
💻 CPP
📖 第 1 页 / 共 3 页
字号:
         tolerance); // %   BOOST_CHECK_CLOSE(      ::boost::math::cdf(         cauchy_distribution<RealType>(0, 1),         static_cast<RealType>(-100)),              // x         static_cast<RealType>(3.18299276490824E-3),  // probability.         tolerance); // %   BOOST_CHECK_CLOSE(      ::boost::math::cdf(         cauchy_distribution<RealType>(1, 5),         static_cast<RealType>(1.25)),              // x         static_cast<RealType>(0.515902251256176),  // probability.         tolerance); // %   BOOST_CHECK_CLOSE(      ::boost::math::cdf(         cauchy_distribution<RealType>(2, 2),         static_cast<RealType>(1.25)),              // x         static_cast<RealType>(0.385799748780092),  // probability.         tolerance); // %   BOOST_CHECK_CLOSE(      ::boost::math::cdf(         cauchy_distribution<RealType>(4, 0.125),         static_cast<RealType>(3)),              // x         static_cast<RealType>(0.039583424160566),  // probability.         tolerance); // %    BOOST_CHECK_CLOSE(       ::boost::math::cdf(         cauchy_distribution<RealType>(-2, static_cast<RealType>(0.0001)),         static_cast<RealType>(-3)),              // x         static_cast<RealType>(3.1830988512275777e-5),  // probability.         tolerance); // %   BOOST_CHECK_CLOSE(      ::boost::math::cdf(         cauchy_distribution<RealType>(4, 50),         static_cast<RealType>(-3)),              // x         static_cast<RealType>(0.455724386698215),  // probability.         tolerance); // %   BOOST_CHECK_CLOSE(      ::boost::math::cdf(         cauchy_distribution<RealType>(-4, 50),         static_cast<RealType>(-3)),              // x         static_cast<RealType>(0.506365349100973),  // probability.         tolerance); // %   BOOST_CHECK_CLOSE(      ::boost::math::cdf(         complement(cauchy_distribution<RealType>(1, 5),         static_cast<RealType>(1.25))),              // x         static_cast<RealType>(1-0.515902251256176),  // probability.         tolerance); // %   BOOST_CHECK_CLOSE(      ::boost::math::cdf(         complement(cauchy_distribution<RealType>(2, 2),         static_cast<RealType>(1.25))),              // x         static_cast<RealType>(1-0.385799748780092),  // probability.         tolerance); // %   BOOST_CHECK_CLOSE(      ::boost::math::cdf(         complement(cauchy_distribution<RealType>(4, 0.125),         static_cast<RealType>(3))),              // x         static_cast<RealType>(1-0.039583424160566),  // probability.         tolerance); // %   BOOST_CHECK_CLOSE(      ::boost::math::cdf(         cauchy_distribution<RealType>(-2, static_cast<RealType>(0.001)),         static_cast<RealType>(-3)),              // x         static_cast<RealType>(0.000318309780080539),  // probability.         tolerance); // %   BOOST_CHECK_CLOSE(      ::boost::math::cdf(         complement(cauchy_distribution<RealType>(4, 50),         static_cast<RealType>(-3))),              // x         static_cast<RealType>(1-0.455724386698215),  // probability.         tolerance); // %   BOOST_CHECK_CLOSE(      ::boost::math::cdf(         complement(cauchy_distribution<RealType>(-4, 50),         static_cast<RealType>(-3))),              // x         static_cast<RealType>(1-0.506365349100973),  // probability.         tolerance); // %   BOOST_CHECK_CLOSE(      ::boost::math::quantile(         cauchy_distribution<RealType>(1, 5),         static_cast<RealType>(0.515902251256176)),              // x         static_cast<RealType>(1.25),  // probability.         tolerance); // %   BOOST_CHECK_CLOSE(      ::boost::math::quantile(         cauchy_distribution<RealType>(2, 2),         static_cast<RealType>(0.385799748780092)),              // x         static_cast<RealType>(1.25),  // probability.         tolerance); // %   BOOST_CHECK_CLOSE(      ::boost::math::quantile(         cauchy_distribution<RealType>(4, 0.125),         static_cast<RealType>(0.039583424160566)),              // x         static_cast<RealType>(3),  // probability.         tolerance); // %   /*   BOOST_CHECK_CLOSE(      ::boost::math::quantile(         cauchy_distribution<RealType>(-2, 0.0001),         static_cast<RealType>(-3)),              // x         static_cast<RealType>(0.000015915494296),  // probability.         tolerance); // %         */   BOOST_CHECK_CLOSE(      ::boost::math::quantile(         cauchy_distribution<RealType>(4, 50),         static_cast<RealType>(0.455724386698215)),              // x         static_cast<RealType>(-3),  // probability.         tolerance); // %   BOOST_CHECK_CLOSE(      ::boost::math::quantile(         cauchy_distribution<RealType>(-4, 50),         static_cast<RealType>(0.506365349100973)),              // x         static_cast<RealType>(-3),  // probability.         tolerance); // %   BOOST_CHECK_CLOSE(      ::boost::math::quantile(         complement(cauchy_distribution<RealType>(1, 5),         static_cast<RealType>(1-0.515902251256176))),              // x         static_cast<RealType>(1.25),  // probability.         tolerance); // %   BOOST_CHECK_CLOSE(      ::boost::math::quantile(         complement(cauchy_distribution<RealType>(2, 2),         static_cast<RealType>(1-0.385799748780092))),              // x         static_cast<RealType>(1.25),  // probability.         tolerance); // %   BOOST_CHECK_CLOSE(      ::boost::math::quantile(         complement(cauchy_distribution<RealType>(4, 0.125),         static_cast<RealType>(1-0.039583424160566))),              // x         static_cast<RealType>(3),  // probability.         tolerance); // %   /*   BOOST_CHECK_CLOSE(      ::boost::math::quantile(         cauchy_distribution<RealType>(-2, 0.0001),         static_cast<RealType>(-3)),              // x         static_cast<RealType>(0.000015915494296),  // probability.         tolerance); // %         */   BOOST_CHECK_CLOSE(      ::boost::math::quantile(         complement(cauchy_distribution<RealType>(4, 50),         static_cast<RealType>(1-0.455724386698215))),              // x         static_cast<RealType>(-3),  // probability.         tolerance); // %   BOOST_CHECK_CLOSE(      ::boost::math::quantile(         complement(cauchy_distribution<RealType>(-4, 50),         static_cast<RealType>(1-0.506365349100973))),              // x         static_cast<RealType>(-3),  // probability.         tolerance); // %   cauchy_distribution<RealType> dist; // default (0, 1)   BOOST_CHECK_EQUAL(       mode(dist),       static_cast<RealType>(0));   BOOST_CHECK_EQUAL(       median(dist),       static_cast<RealType>(0));   //   // Things that now don't compile (BOOST-STATIC_ASSERT_FAILURE) by default.   // #define BOOST_MATH_ASSERT_UNDEFINED_POLICY false    // To compile even if Cauchy mean is used.   // See policy reference, mathematically undefined function policies   //   //BOOST_CHECK_THROW(   //    mean(dist),   //    std::domain_error);   //BOOST_CHECK_THROW(   //    variance(dist),   //    std::domain_error);   //BOOST_CHECK_THROW(   //    standard_deviation(dist),   //    std::domain_error);   //BOOST_CHECK_THROW(   //    kurtosis(dist),   //    std::domain_error);   //BOOST_CHECK_THROW(   //    kurtosis_excess(dist),   //    std::domain_error);   //BOOST_CHECK_THROW(   //    skewness(dist),   //    std::domain_error);   BOOST_CHECK_THROW(       quantile(dist, RealType(0.0)),       std::overflow_error);   BOOST_CHECK_THROW(       quantile(dist, RealType(1.0)),       std::overflow_error);   BOOST_CHECK_THROW(       quantile(complement(dist, RealType(0.0))),       std::overflow_error);   BOOST_CHECK_THROW(       quantile(complement(dist, RealType(1.0))),       std::overflow_error);} // template <class RealType>void test_spots(RealType)int test_main(int, char* []){    BOOST_MATH_CONTROL_FP;   // Check that can generate cauchy distribution using the two convenience methods:   boost::math::cauchy mycd1(1.); // Using typedef   cauchy_distribution<> mycd2(1.); // Using default RealType double.   cauchy_distribution<> C01; // Using default RealType double for Standard Cauchy.  BOOST_CHECK_EQUAL(C01.location(), 0); // Check standard values.  BOOST_CHECK_EQUAL(C01.scale(), 1);    // 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* [])/*Output:Running 1 test case...Tolerance for type float is 0.000596046 %Tolerance for type double is 1.11022e-012 %Tolerance for type long double is 1.11022e-012 %Tolerance for type class boost::math::concepts::real_concept is 1.11022e-012 %*** No errors detected*/

⌨️ 快捷键说明

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