$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r79759 - trunk/boost/math/distributions
From: pbristow_at_[hidden]
Date: 2012-07-26 14:03:32
Author: pbristow
Date: 2012-07-26 14:03:32 EDT (Thu, 26 Jul 2012)
New Revision: 79759
URL: http://svn.boost.org/trac/boost/changeset/79759
Log:
Revised for Trac #7717
Text files modified: 
   trunk/boost/math/distributions/students_t.hpp |    34 ++++++++++++++++++++++++++--------      
   1 files changed, 26 insertions(+), 8 deletions(-)
Modified: trunk/boost/math/distributions/students_t.hpp
==============================================================================
--- trunk/boost/math/distributions/students_t.hpp	(original)
+++ trunk/boost/math/distributions/students_t.hpp	2012-07-26 14:03:32 EDT (Thu, 26 Jul 2012)
@@ -293,19 +293,37 @@
 }
 
 template <class RealType, class Policy>
-inline RealType mean(const students_t_distribution<RealType, Policy>& )
-{
+inline RealType mean(const students_t_distribution<RealType, Policy>& dist)
+{  // Revised for https://svn.boost.org/trac/boost/ticket/7177
+  RealType df = dist.degrees_of_freedom();
+   if(df <= 1)
+   {
+      policies::raise_domain_error<RealType>(
+      "boost::math::mean(students_t_distribution<%1%> const&, %1%)",
+      "Mean is undefined for degrees of freedom < 1 but got %1%.", df, Policy());
+      return std::numeric_limits<RealType>::quiet_NaN();
+   }
    return 0;
 }
 
 template <class RealType, class Policy>
 inline RealType variance(const students_t_distribution<RealType, Policy>& dist)
-{
-   // Error check:
-   RealType error_result;
-   if(false == detail::check_df(
-      "boost::math::variance(students_t_distribution<%1%> const&, %1%)", dist.degrees_of_freedom(), &error_result, Policy()))
-      return error_result;
+{ // http://en.wikipedia.org/wiki/Student%27s_t-distribution
+
+  // Revised for https://svn.boost.org/trac/boost/ticket/7177
+
+   RealType df = dist.degrees_of_freedom();
+   if((df <= 2) || !(boost::math::isfinite)(df))
+   {
+      if (df > 1)
+      {
+        return std::numeric_limits<RealType>::infinity();
+      }
+      policies::raise_domain_error<RealType>(
+         "boost::math::variance(students_t_distribution<%1%> const&, %1%)",
+         "Degrees of freedom is undefined for <= 2 but got %1%.", df, Policy());
+      return std::numeric_limits<RealType>::quiet_NaN();
+   }
 
    RealType v = dist.degrees_of_freedom();
    return v / (v - 2);