Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/math/distributions/geometric.hpp @ 101:c530137014c0
Update Boost headers (1.58.0)
author | Chris Cannam |
---|---|
date | Mon, 07 Sep 2015 11:12:49 +0100 |
parents | 2665513ce2d3 |
children |
comparison
equal
deleted
inserted
replaced
100:793467b5e61c | 101:c530137014c0 |
---|---|
370 return p; // success_fraction | 370 return p; // success_fraction |
371 } | 371 } |
372 //RealType q = 1 - p; // Bad for small p | 372 //RealType q = 1 - p; // Bad for small p |
373 //RealType probability = 1 - std::pow(q, k+1); | 373 //RealType probability = 1 - std::pow(q, k+1); |
374 | 374 |
375 RealType z = boost::math::log1p(-p) * (k+1); | 375 RealType z = boost::math::log1p(-p, Policy()) * (k + 1); |
376 RealType probability = -boost::math::expm1(z); | 376 RealType probability = -boost::math::expm1(z, Policy()); |
377 | 377 |
378 return probability; | 378 return probability; |
379 } // cdf Cumulative Distribution Function geometric. | 379 } // cdf Cumulative Distribution Function geometric. |
380 | 380 |
381 template <class RealType, class Policy> | 381 template <class RealType, class Policy> |
396 k, | 396 k, |
397 &result, Policy())) | 397 &result, Policy())) |
398 { | 398 { |
399 return result; | 399 return result; |
400 } | 400 } |
401 RealType z = boost::math::log1p(-p) * (k+1); | 401 RealType z = boost::math::log1p(-p, Policy()) * (k+1); |
402 RealType probability = exp(z); | 402 RealType probability = exp(z); |
403 return probability; | 403 return probability; |
404 } // cdf Complemented Cumulative Distribution Function geometric. | 404 } // cdf Complemented Cumulative Distribution Function geometric. |
405 | 405 |
406 template <class RealType, class Policy> | 406 template <class RealType, class Policy> |
446 { | 446 { |
447 return 0; | 447 return 0; |
448 } | 448 } |
449 | 449 |
450 // log(1-x) /log(1-success_fraction) -1; but use log1p in case success_fraction is small | 450 // log(1-x) /log(1-success_fraction) -1; but use log1p in case success_fraction is small |
451 result = boost::math::log1p(-x) / boost::math::log1p(-success_fraction) -1; | 451 result = boost::math::log1p(-x, Policy()) / boost::math::log1p(-success_fraction, Policy()) - 1; |
452 // Subtract a few epsilons here too? | 452 // Subtract a few epsilons here too? |
453 // to make sure it doesn't slip over, so ceil would be one too many. | 453 // to make sure it doesn't slip over, so ceil would be one too many. |
454 return result; | 454 return result; |
455 } // RealType quantile(const geometric_distribution dist, p) | 455 } // RealType quantile(const geometric_distribution dist, p) |
456 | 456 |
494 return result; | 494 return result; |
495 // usually means return +std::numeric_limits<RealType>::infinity(); | 495 // usually means return +std::numeric_limits<RealType>::infinity(); |
496 // unless #define BOOST_MATH_THROW_ON_OVERFLOW_ERROR | 496 // unless #define BOOST_MATH_THROW_ON_OVERFLOW_ERROR |
497 } | 497 } |
498 // log(x) /log(1-success_fraction) -1; but use log1p in case success_fraction is small | 498 // log(x) /log(1-success_fraction) -1; but use log1p in case success_fraction is small |
499 result = log(x) / boost::math::log1p(-success_fraction) -1; | 499 result = log(x) / boost::math::log1p(-success_fraction, Policy()) - 1; |
500 return result; | 500 return result; |
501 | 501 |
502 } // quantile complement | 502 } // quantile complement |
503 | 503 |
504 } // namespace math | 504 } // namespace math |