Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r75591 - trunk/boost/math/distributions
From: pbristow_at_[hidden]
Date: 2011-11-21 07:57:34


Author: pbristow
Date: 2011-11-21 07:57:33 EST (Mon, 21 Nov 2011)
New Revision: 75591
URL: http://svn.boost.org/trac/boost/changeset/75591

Log:
Corrected complement cdf with Yan Zhou patch.
Text files modified:
   trunk/boost/math/distributions/laplace.hpp | 28 +++++++++++++++++-----------
   1 files changed, 17 insertions(+), 11 deletions(-)

Modified: trunk/boost/math/distributions/laplace.hpp
==============================================================================
--- trunk/boost/math/distributions/laplace.hpp (original)
+++ trunk/boost/math/distributions/laplace.hpp 2011-11-21 07:57:33 EST (Mon, 21 Nov 2011)
@@ -143,10 +143,13 @@
    RealType location( dist.location() );
 
    if (x < location)
+ {
       result = exp( (x-location)/scale )/2;
+ }
    else
+ {
       result = 1 - exp( (location-x)/scale )/2;
-
+ }
    return result;
 } // cdf
 
@@ -203,21 +206,24 @@
    const char* function = "boost::math::cdf(const complemented2_type<laplace_distribution<%1%>, %1%>&)";
    if(false == detail::check_x(function, x, &result, Policy()))return result;
 
- // Calculate cdf
+ // Calculate complement of cdf.
 
    // Special cdf value
    if((boost::math::isinf)(x))
    {
      if(x < 0) return 1; // cdf complement -infinity is unity.
- return 0; // cdf complement +infinity is zero
+ return 0; // cdf complement +infinity is zero.
    }
 
- // Cdf interval value
- if (-x < location)
- result = exp( (-x-location)/scale )/2;
+ // Cdf interval value.
+ if (-x < -location)
+ {
+ result = exp( (-x+location)/scale )/2;
+ }
    else
- result = 1 - exp( (location+x)/scale )/2;
-
+ {
+ result = 1 - exp( (-location+x)/scale )/2;
+ }
    return result;
 } // cdf complement
 
@@ -225,14 +231,14 @@
 template <class RealType, class Policy>
 inline RealType quantile(const complemented2_type<laplace_distribution<RealType, Policy>, RealType>& c)
 {
- BOOST_MATH_STD_USING // for ADL of std functions
+ BOOST_MATH_STD_USING // for ADL of std functions.
 
- // Calculate quantile
+ // Calculate quantile.
    RealType scale = c.dist.scale();
    RealType location = c.dist.location();
    RealType q = c.param;
 
- // Checking function argument
+ // Checking function argument.
    RealType result = 0;
    const char* function = "quantile(const complemented2_type<laplace_distribution<%1%>, %1%>&)";
    if(false == detail::check_probability(function, q, &result, Policy())) return result;


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk