$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
From: pbristow_at_[hidden]
Date: 2008-02-16 05:36:02
Author: pbristow
Date: 2008-02-16 05:36:02 EST (Sat, 16 Feb 2008)
New Revision: 43275
URL: http://svn.boost.org/trac/boost/changeset/43275
Log:
Corrected range to permit df == 2 
and Added comment(-ed code) about mode with df < 2.
No reply to question about this on Wikipedia 16 Feb 08. 
Text files modified: 
   sandbox/math_toolkit/boost/math/distributions/chi_squared.hpp |    18 +++++++++++++++---                      
   1 files changed, 15 insertions(+), 3 deletions(-)
Modified: sandbox/math_toolkit/boost/math/distributions/chi_squared.hpp
==============================================================================
--- sandbox/math_toolkit/boost/math/distributions/chi_squared.hpp	(original)
+++ sandbox/math_toolkit/boost/math/distributions/chi_squared.hpp	2008-02-16 05:36:02 EST (Sat, 16 Feb 2008)
@@ -1,5 +1,5 @@
 // Copyright John Maddock 2006, 2007.
-// Copyright Paul A. Bristow 2007.
+// Copyright Paul A. Bristow 2008.
 
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0.
@@ -202,10 +202,22 @@
 {
    RealType df = dist.degrees_of_freedom();
    static const char* function = "boost::math::mode(const chi_squared_distribution<%1%>&)";
-   if(df <= 2)
+   // Most sources only define mode for df >= 2,
+   // but for 0 <= df <= 2, the pdf maximum actually occurs at random variate = 0;
+   // So one could extend the definition of mode thus:
+   //if(df < 0)
+   //{
+   //   return policies::raise_domain_error<RealType>(
+   //      function,
+   //      "Chi-Squared distribution only has a mode for degrees of freedom >= 0, but got degrees of freedom = %1%.",
+   //      df, Policy());
+   //}
+   //return (df <= 2) ? 0 : df - 2;
+
+   if(df < 2)
       return policies::raise_domain_error<RealType>(
          function,
-         "The Chi-Squared distribution only has a mode for degrees of freedom >= 2, but got degrees of freedom = %1%.",
+         "Chi-Squared distribution only has a mode for degrees of freedom >= 2, but got degrees of freedom = %1%.",
          df, Policy());
    return df - 2;
 }