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
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>
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;
{
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;
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;
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()))
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.
//{ // 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;
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()))