]> git.donarmstrong.com Git - rsem.git/blobdiff - boost/math/distributions/normal.hpp
Updated boost to v1.55.0
[rsem.git] / boost / math / distributions / normal.hpp
index 69da2dc3885967c45358d82e8748df350b3b4240..73039679f19d5859f511378e01f02b2792ca896d 100644 (file)
@@ -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<double> normal;
 template <class RealType, class Policy>
 inline const std::pair<RealType, RealType> range(const normal_distribution<RealType, Policy>& /*dist*/)
 { // Range of permissible values for random variable x.
-   using boost::math::tools::max_value;
-   return std::pair<RealType, RealType>(-max_value<RealType>(), max_value<RealType>()); // - to + max value.
+  if (std::numeric_limits<RealType>::has_infinity)
+  { 
+     return std::pair<RealType, RealType>(-std::numeric_limits<RealType>::infinity(), std::numeric_limits<RealType>::infinity()); // - to + infinity.
+  }
+  else
+  { // Can only use max_value.
+    using boost::math::tools::max_value;
+    return std::pair<RealType, RealType>(-max_value<RealType>(), max_value<RealType>()); // - to + max value.
+  }
 }
 
 template <class RealType, class Policy>
 inline const std::pair<RealType, RealType> support(const normal_distribution<RealType, Policy>& /*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<RealType>::has_infinity)
+  { 
+     return std::pair<RealType, RealType>(-std::numeric_limits<RealType>::infinity(), std::numeric_limits<RealType>::infinity()); // - to + infinity.
+  }
+  else
+  { // Can only use max_value.
    using boost::math::tools::max_value;
    return std::pair<RealType, RealType>(-max_value<RealType>(),  max_value<RealType>()); // - to + max value.
+  }
 }
 
 template <class RealType, class Policy>
@@ -96,17 +109,8 @@ inline RealType pdf(const normal_distribution<RealType, Policy>& 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<RealType>::has_infinity && abs(x) == std::numeric_limits<RealType>::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<RealType, Policy>& 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<RealType>::has_infinity && abs(x) == std::numeric_limits<RealType>::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<RealType, Policy>& 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<RealType, Policy>& 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<normal_distribution<RealType, Polic
    RealType x = c.param;
    static const char* function = "boost::math::cdf(const complement(normal_distribution<%1%>&), %1%)";
 
+   RealType result = 0;
+   if(false == detail::check_scale(function, sd, &result, Policy()))
+      return result;
+   if(false == detail::check_location(function, mean, &result, Policy()))
+      return result;
    if((boost::math::isinf)(x))
    {
      if(x < 0) return 1; // cdf complement -infinity is unity.
@@ -218,11 +236,6 @@ inline RealType cdf(const complemented2_type<normal_distribution<RealType, Polic
    //{ // cdf complement -infinity is unity.
    //  return 1;
    //}
-   RealType result;
-   if(false == detail::check_scale(function, sd, &result, Policy()))
-      return result;
-   if(false == detail::check_location(function, mean, &result, Policy()))
-      return result;
    if(false == detail::check_x(function, x, &result, Policy()))
       return result;
 
@@ -239,7 +252,7 @@ inline RealType quantile(const complemented2_type<normal_distribution<RealType,
    RealType sd = c.dist.standard_deviation();
    RealType mean = c.dist.mean();
    static const char* function = "boost::math::quantile(const complement(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()))