Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r79891 - trunk/libs/math/test
From: pbristow_at_[hidden]
Date: 2012-08-06 12:29:39


Author: pbristow
Date: 2012-08-06 12:29:38 EDT (Mon, 06 Aug 2012)
New Revision: 79891
URL: http://svn.boost.org/trac/boost/changeset/79891

Log:
Test of using the 1/eps to switch to normal distribution.
Text files modified:
   trunk/libs/math/test/test_students_t.cpp | 23 +++++++++++++++++++++++
   1 files changed, 23 insertions(+), 0 deletions(-)

Modified: trunk/libs/math/test/test_students_t.cpp
==============================================================================
--- trunk/libs/math/test/test_students_t.cpp (original)
+++ trunk/libs/math/test/test_students_t.cpp 2012-08-06 12:29:38 EDT (Mon, 06 Aug 2012)
@@ -471,6 +471,29 @@
          static_cast<RealType>(1.0))),
          9);
 
+ // Test for large degrees of freedom when should be same as normal.
+
+ std::string type = typeid(RealType).name();
+ if (type != "class boost::math::concepts::real_concept")
+ {
+ RealType limit = 1/ boost::math::tools::epsilon<RealType>();
+ // Default policy to get full accuracy.
+ // std::cout << "Switch over to normal if df > " << limit << std::endl;
+ // float Switch over to normal if df > 8.38861e+006
+ // double Switch over to normal if df > 4.5036e+015
+ // Can't test real_concept - doesn't converge.
+
+ boost::math::normal_distribution<RealType> n(0, 1); //
+ students_t_distribution<RealType> st(boost::math::tools::max_value<RealType>()); // Well over the switchover point,
+ // PDF
+ BOOST_CHECK_EQUAL(pdf(st, 0), pdf(n, 0.)); // should be exactly equal.
+ students_t_distribution<RealType> st2(limit /5 ); // Just below the switchover point,
+ BOOST_CHECK_CLOSE_FRACTION(pdf(st2, 0), pdf(n, 0.), tolerance); // should be very close to normal.
+ // CDF
+ BOOST_CHECK_EQUAL(cdf(st, 0), cdf(n, 0.)); // should be exactly equal.
+ BOOST_CHECK_CLOSE_FRACTION(cdf(st2, 0), cdf(n, 0.), tolerance); // should be very close to normal.
+ }
+
 
     // Checks added for Trac #7717 report by Thomas Mang.
     RealType inf = std::numeric_limits<RealType>::infinity();


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk