|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r78776 - trunk/boost/math/distributions
From: pbristow_at_[hidden]
Date: 2012-05-31 05:35:52
Author: pbristow
Date: 2012-05-31 05:35:52 EDT (Thu, 31 May 2012)
New Revision: 78776
URL: http://svn.boost.org/trac/boost/changeset/78776
Log:
Corrected failure to check for NaN in quantiles. UNsure if df should include zero.
Text files modified:
trunk/boost/math/distributions/chi_squared.hpp | 34 +++++++++++++++++++++-------------
1 files changed, 21 insertions(+), 13 deletions(-)
Modified: trunk/boost/math/distributions/chi_squared.hpp
==============================================================================
--- trunk/boost/math/distributions/chi_squared.hpp (original)
+++ trunk/boost/math/distributions/chi_squared.hpp 2012-05-31 05:35:52 EDT (Thu, 31 May 2012)
@@ -50,7 +50,7 @@
//
// Data member:
//
- RealType m_df; // degrees of freedom are a real number.
+ RealType m_df; // degrees of freedom is a positive real number.
}; // class chi_squared_distribution
typedef chi_squared_distribution<double> chi_squared;
@@ -58,8 +58,15 @@
template <class RealType, class Policy>
inline const std::pair<RealType, RealType> range(const chi_squared_distribution<RealType, Policy>& /*dist*/)
{ // Range of permissible values for random variable x.
- using boost::math::tools::max_value;
- return std::pair<RealType, RealType>(static_cast<RealType>(0), max_value<RealType>()); // 0 to + infinity.
+ if (std::numeric_limits<RealType>::has_infinity)
+ {
+ return std::pair<RealType, RealType>(static_cast<RealType>(0), std::numeric_limits<RealType>::infinity()); // 0 to + infinity.
+ }
+ else
+ {
+ using boost::math::tools::max_value;
+ return std::pair<RealType, RealType>(static_cast<RealType>(0), max_value<RealType>()); // 0 to + max.
+ }
}
template <class RealType, class Policy>
@@ -138,11 +145,12 @@
static const char* function = "boost::math::quantile(const chi_squared_distribution<%1%>&, %1%)";
// Error check:
RealType error_result;
- if(false == detail::check_df(
- function, degrees_of_freedom, &error_result, Policy())
- && detail::check_probability(
- function, p, &error_result, Policy()))
- return error_result;
+ if(false ==
+ (
+ detail::check_df(function, degrees_of_freedom, &error_result, Policy())
+ && detail::check_probability(function, p, &error_result, Policy()))
+ )
+ return error_result;
return 2 * boost::math::gamma_p_inv(degrees_of_freedom / 2, p, Policy());
} // quantile
@@ -176,11 +184,11 @@
static const char* function = "boost::math::quantile(const chi_squared_distribution<%1%>&, %1%)";
// Error check:
RealType error_result;
- if(false == detail::check_df(
- function, degrees_of_freedom, &error_result, Policy())
- && detail::check_probability(
- function, q, &error_result, Policy()))
- return error_result;
+ if(false == (
+ detail::check_df(function, degrees_of_freedom, &error_result, Policy())
+ && detail::check_probability(function, q, &error_result, Policy()))
+ )
+ return error_result;
return 2 * boost::math::gamma_q_inv(degrees_of_freedom / 2, q, Policy());
}
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