RealType pdf(const lognormal_distribution<RealType, Policy>& dist, const RealType& x) { BOOST_MATH_STD_USING // for ADL of std functions RealType mu = dist.location(); RealType sigma = dist.scale(); static const char* function = "boost::math::pdf(const lognormal_distribution<%1%>&, %1%)"; RealType result = 0; if(0 == detail::check_scale(function, sigma, &result, Policy())) return result; if(0 == detail::check_location(function, mu, &result, Policy())) return result; if(0 == detail::check_lognormal_x(function, x, &result, Policy())) return result; if(x == 0) return 0; RealType exponent = log(x) - mu; exponent *= -exponent; exponent /= 2 * sigma * sigma; result = exp(exponent); result /= sigma * sqrt(2 * constants::pi<RealType>()) * x; return result; }
inline RealType mode(const lognormal_distribution<RealType, Policy>& dist) { BOOST_MATH_STD_USING // for ADL of std functions RealType mu = dist.location(); RealType sigma = dist.scale(); RealType result = 0; if(0 == detail::check_scale("lslboost::math::mode(const lognormal_distribution<%1%>&)", sigma, &result, Policy())) return result; return exp(mu - sigma * sigma); }
inline RealType variance(const lognormal_distribution<RealType, Policy>& dist) { BOOST_MATH_STD_USING // for ADL of std functions RealType mu = dist.location(); RealType sigma = dist.scale(); RealType result = 0; if(0 == detail::check_scale("boost::math::variance(const lognormal_distribution<%1%>&)", sigma, &result, Policy())) return result; if(0 == detail::check_location("boost::math::variance(const lognormal_distribution<%1%>&)", mu, &result, Policy())) return result; return boost::math::expm1(sigma * sigma, Policy()) * exp(2 * mu + sigma * sigma); }
inline RealType cdf(const lognormal_distribution<RealType, Policy>& dist, const RealType& x) { BOOST_MATH_STD_USING // for ADL of std functions static const char* function = "lslboost::math::cdf(const lognormal_distribution<%1%>&, %1%)"; RealType result = 0; if(0 == detail::check_lognormal_x(function, x, &result, Policy())) return result; if(x == 0) return 0; normal_distribution<RealType, Policy> norm(dist.location(), dist.scale()); return cdf(norm, log(x)); }
inline RealType quantile(const lognormal_distribution<RealType, Policy>& dist, const RealType& p) { BOOST_MATH_STD_USING // for ADL of std functions static const char* function = "lslboost::math::quantile(const lognormal_distribution<%1%>&, %1%)"; RealType result = 0; if(0 == detail::check_probability(function, p, &result, Policy())) return result; if(p == 0) return 0; if(p == 1) return policies::raise_overflow_error<RealType>(function, 0, Policy()); normal_distribution<RealType, Policy> norm(dist.location(), dist.scale()); return exp(quantile(norm, p)); }
inline RealType kurtosis_excess(const lognormal_distribution<RealType, Policy>& dist) { BOOST_MATH_STD_USING // for ADL of std functions // RealType mu = dist.location(); RealType sigma = dist.scale(); RealType ss = sigma * sigma; RealType result = 0; if(0 == detail::check_scale("lslboost::math::kurtosis_excess(const lognormal_distribution<%1%>&)", sigma, &result, Policy())) return result; return exp(4 * ss) + 2 * exp(3 * ss) + 3 * exp(2 * ss) - 6; }
inline RealType skewness(const lognormal_distribution<RealType, Policy>& dist) { BOOST_MATH_STD_USING // for ADL of std functions //RealType mu = dist.location(); RealType sigma = dist.scale(); RealType ss = sigma * sigma; RealType ess = exp(ss); RealType result = 0; if(0 == detail::check_scale("lslboost::math::skewness(const lognormal_distribution<%1%>&)", sigma, &result, Policy())) return result; return (ess + 2) * sqrt(lslboost::math::expm1(ss, Policy())); }
inline RealType median(const lognormal_distribution<RealType, Policy>& dist) { BOOST_MATH_STD_USING // for ADL of std functions RealType mu = dist.location(); return exp(mu); // e^mu }