summaryrefslogtreecommitdiff
path: root/boost/math/distributions/chi_squared.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/math/distributions/chi_squared.hpp')
-rw-r--r--boost/math/distributions/chi_squared.hpp43
1 files changed, 30 insertions, 13 deletions
diff --git a/boost/math/distributions/chi_squared.hpp b/boost/math/distributions/chi_squared.hpp
index 367a7154a3..071c7756f4 100644
--- a/boost/math/distributions/chi_squared.hpp
+++ b/boost/math/distributions/chi_squared.hpp
@@ -50,18 +50,34 @@ private:
//
// 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;
+#ifdef BOOST_MSVC
+#pragma warning(push)
+#pragma warning(disable:4127)
+#endif
+
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.
+ }
}
+#ifdef BOOST_MSVC
+#pragma warning(pop)
+#endif
+
template <class RealType, class Policy>
inline const std::pair<RealType, RealType> support(const chi_squared_distribution<RealType, Policy>& /*dist*/)
{ // Range of supported values for random variable x.
@@ -138,11 +154,12 @@ inline RealType quantile(const chi_squared_distribution<RealType, Policy>& dist,
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 +193,11 @@ inline RealType quantile(const complemented2_type<chi_squared_distribution<RealT
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());
}