[Boost-bugs] [Boost C++ Libraries] #11273: Incorrect use of abs() function in libs/math/example/normal_misc_examples.cpp

Subject: [Boost-bugs] [Boost C++ Libraries] #11273: Incorrect use of abs() function in libs/math/example/normal_misc_examples.cpp
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-05-06 12:03:35


#11273: Incorrect use of abs() function in
libs/math/example/normal_misc_examples.cpp
------------------------------------------+-------------------------
 Reporter: Quentin Armitage <quentin@…> | Owner: johnmaddock
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: math
  Version: Boost 1.57.0 | Severity: Problem
 Keywords: |
------------------------------------------+-------------------------
 When running normal_misc_examples, it produces the following error:
 {{{
 If we want the 0.0500 th quantile to be located at 2.90, would need a
 standard deviation of 0.00

 Message from thrown exception was:
    Error in function
 boost::math::normal_distribution<double>::normal_distribution: Scale
 parameter is 0, but must be > 0 !
 }}}

 The reason for this is line 373:
 {{{
 double sd95 = abs((x - mean)) / qp;
 }}}
 where the abs() function is the C function which takes an int parameter.
 Passing it the double (x - mean) returns 0.

 As a temporary workaround, I have modified the code to
 {{{
 double sd95 = (x - mean) / qp;
 if (sd95 < 0)
     sd95 = -sd95 ;
 }}}
 and this resolves the problem.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11273>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:18 UTC