-// Copyright Paul A. Bristow 2006.
+// Copyright Paul A. Bristow 2006, 2017.
// Copyright John Maddock 2006.
// Use, modification and distribution are subject to the
#include <boost/test/floating_point_comparison.hpp>
#include <boost/math/concepts/real_concept.hpp> // for real_concept
-#include <boost/math/distributions/students_t.hpp>
- using boost::math::students_t_distribution;
#include <boost/math/tools/test.hpp> // for real_concept
#include "test_out_of_range.hpp"
+#include <boost/math/distributions/students_t.hpp>
+ using boost::math::students_t_distribution;
#include <iostream>
using std::cout;
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.
+ 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.
+ 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.
+ 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.
- // Tests for df = infinity.
+ // Tests for df = infinity.
students_t_distribution<RealType> infdf(inf);
BOOST_CHECK_EQUAL(infdf.degrees_of_freedom(), inf);
BOOST_CHECK_EQUAL(mean(infdf), 0); // OK.
BOOST_MATH_CHECK_THROW(students_t_distribution<RealType> minfdf(nan), std::domain_error);
BOOST_MATH_CHECK_THROW(students_t_distribution<RealType> minfdf(-nan), std::domain_error);
#endif
+ BOOST_CHECK_EQUAL(pdf(infdf, -inf), 0);
+ BOOST_CHECK_EQUAL(pdf(infdf, +inf), 0);
+ BOOST_CHECK_EQUAL(cdf(infdf, -inf), 0);
+ BOOST_CHECK_EQUAL(cdf(infdf, +inf), 1);
// BOOST_CHECK_CLOSE_FRACTION(pdf(infdf, 0), static_cast<RealType>(0.3989422804014326779399460599343818684759L), tolerance);
BOOST_CHECK_CLOSE_FRACTION(pdf(infdf, 0),boost::math::constants::one_div_root_two_pi<RealType>() , tolerance);
BOOST_CHECK_EQUAL(mean(students_t_distribution<RealType>(2)), 0); // OK.
BOOST_CHECK_EQUAL(mean(students_t_distribution<RealType>(inf)), 0); // OK.
-
// Check on df for variance (moment 2)
BOOST_MATH_CHECK_THROW(variance(students_t_distribution<RealType>(nan)), std::domain_error);
// BOOST_MATH_CHECK_THROW(variance(students_t_distribution<RealType>(inf)), std::domain_error); // inf is now OK.
BOOST_CHECK(boost::math::isfinite(kurtosis(ignore_error_students_t(static_cast<RealType>(4.0001L)))));
// check_out_of_range<students_t_distribution<RealType> >(1);
- // Cannot be used because fails "exception std::domain_error is expected"
- // because df = +infinity is allowed.
+ // Cannot be used because fails "exception std::domain_error is expected but not raised"
+ // if df = +infinity is allowed, must use new version that allows skipping infinity tests.
+ // Infinite == true
- check_support<students_t_distribution<RealType> >(students_t_distribution<RealType>(1));
+ check_support<students_t_distribution<RealType> >(students_t_distribution<RealType>(1), true);
} // template <class RealType>void test_spots(RealType)