X-Git-Url: https://git.donarmstrong.com/?p=rsem.git;a=blobdiff_plain;f=boost%2Fmath%2Fdistributions%2Fnormal.hpp;h=73039679f19d5859f511378e01f02b2792ca896d;hp=69da2dc3885967c45358d82e8748df350b3b4240;hb=2d71eb92104693ca9baa5a2e1c23eeca776d8fd3;hpb=da57529b92adbb7ae74a89861cb39fb35ac7c62d diff --git a/boost/math/distributions/normal.hpp b/boost/math/distributions/normal.hpp index 69da2dc..7303967 100644 --- a/boost/math/distributions/normal.hpp +++ b/boost/math/distributions/normal.hpp @@ -31,14 +31,14 @@ public: typedef RealType value_type; typedef Policy policy_type; - normal_distribution(RealType mean = 0, RealType sd = 1) - : m_mean(mean), m_sd(sd) + normal_distribution(RealType l_mean = 0, RealType sd = 1) + : m_mean(l_mean), m_sd(sd) { // Default is a 'standard' normal distribution N01. static const char* function = "boost::math::normal_distribution<%1%>::normal_distribution"; RealType result; detail::check_scale(function, sd, &result, Policy()); - detail::check_location(function, mean, &result, Policy()); + detail::check_location(function, l_mean, &result, Policy()); } RealType mean()const @@ -74,17 +74,30 @@ typedef normal_distribution normal; template inline const std::pair range(const normal_distribution& /*dist*/) { // Range of permissible values for random variable x. - using boost::math::tools::max_value; - return std::pair(-max_value(), max_value()); // - to + max value. + if (std::numeric_limits::has_infinity) + { + return std::pair(-std::numeric_limits::infinity(), std::numeric_limits::infinity()); // - to + infinity. + } + else + { // Can only use max_value. + using boost::math::tools::max_value; + return std::pair(-max_value(), max_value()); // - to + max value. + } } template inline const std::pair support(const normal_distribution& /*dist*/) { // Range of supported values for random variable x. // This is range where cdf rises from 0 to 1, and outside it, the pdf is zero. - + if (std::numeric_limits::has_infinity) + { + return std::pair(-std::numeric_limits::infinity(), std::numeric_limits::infinity()); // - to + infinity. + } + else + { // Can only use max_value. using boost::math::tools::max_value; return std::pair(-max_value(), max_value()); // - to + max value. + } } template @@ -96,17 +109,8 @@ inline RealType pdf(const normal_distribution& dist, const Rea RealType mean = dist.mean(); static const char* function = "boost::math::pdf(const normal_distribution<%1%>&, %1%)"; - if((boost::math::isinf)(x)) - { - return 0; // pdf + and - infinity is zero. - } - // Below produces MSVC 4127 warnings, so the above used instead. - //if(std::numeric_limits::has_infinity && abs(x) == std::numeric_limits::infinity()) - //{ // pdf + and - infinity is zero. - // return 0; - //} - RealType result; + RealType result = 0; if(false == detail::check_scale(function, sd, &result, Policy())) { return result; @@ -115,6 +119,15 @@ inline RealType pdf(const normal_distribution& dist, const Rea { return result; } + if((boost::math::isinf)(x)) + { + return 0; // pdf + and - infinity is zero. + } + // Below produces MSVC 4127 warnings, so the above used instead. + //if(std::numeric_limits::has_infinity && abs(x) == std::numeric_limits::infinity()) + //{ // pdf + and - infinity is zero. + // return 0; + //} if(false == detail::check_x(function, x, &result, Policy())) { return result; @@ -138,7 +151,7 @@ inline RealType cdf(const normal_distribution& dist, const Rea RealType sd = dist.standard_deviation(); RealType mean = dist.mean(); static const char* function = "boost::math::cdf(const normal_distribution<%1%>&, %1%)"; - RealType result; + RealType result = 0; if(false == detail::check_scale(function, sd, &result, Policy())) { return result; @@ -179,7 +192,7 @@ inline RealType quantile(const normal_distribution& dist, cons RealType mean = dist.mean(); static const char* function = "boost::math::quantile(const normal_distribution<%1%>&, %1%)"; - RealType result; + RealType result = 0; if(false == detail::check_scale(function, sd, &result, Policy())) return result; if(false == detail::check_location(function, mean, &result, Policy())) @@ -204,6 +217,11 @@ inline RealType cdf(const complemented2_type