[Boost-bugs] [Boost C++ Libraries] #7177: Students t returns rubbihs values for undefined input instead of throw

Subject: [Boost-bugs] [Boost C++ Libraries] #7177: Students t returns rubbihs values for undefined input instead of throw
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-07-26 08:14:41


#7177: Students t returns rubbihs values for undefined input instead of throw
-----------------------------+----------------------------------------------
 Reporter: pbristow | Owner: pbristow
     Type: Bugs | Status: new
Milestone: Boost 1.52.0 | Component: math
  Version: Boost 1.50.0 | Severity: Problem
 Keywords: math students t |
-----------------------------+----------------------------------------------
 Reported by Thomas Mang

 According to the documentation, in boost 1-50 non-member functions of
 moments (e.g. mean, variance) which are not defined for a given
 distribution shall issue compile-time errors, or throw a domain_error at
 runtime otherwise. For the Cauchy Distribution, that's what it does. For
 the t-distribution, that's not what it does - the non-member functions
 happily return some complete rubbish values for mean and variance (and
 hence I'd also suppose standard deviation). For kurtosis and skewness it
 seems to work correctly but are subject to mathematical definitions. I
 have not tested other non-member functions.

 typedef boost::math::students_t_distribution<double> t_distr;

 // this is ok
 std::cout << "mean(t(2)): " << boost::math::mean( t_distr(2) ) <<
 std::endl;

 // this is NOT ok - first moment not defined for given distribution
 std::cout << "mean(t(1)): " << boost::math::mean( t_distr(1) ) <<
 std::endl;


 // this is ok
 std::cout << "var(t(3)): " << boost::math::variance( t_distr(3) ) <<
 std::endl;

 // this might be ok or not
 // depending on point of view, either Inf or undefined std::cout <<
 "var(t(2)): " << boost::math::variance( t_distr(2) ) << std::endl;

 // this is NOT ok - second moment not defined for the given distribution
 std::cout << "var(t(1)): " << boost::math::variance( t_distr(1) ) <<
 std::endl;

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/7177>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:10 UTC