Subject: [Boost-bugs] [Boost C++ Libraries] #9834: Negative Binomial Distribution: degenerate cases
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-04-04 07:20:01
#9834: Negative Binomial Distribution: degenerate cases
-------------------------------------+-------------------------
Reporter: HS <tan@â¦> | Owner: johnmaddock
Type: Feature Requests | Status: new
Milestone: To Be Determined | Component: math
Version: Boost Development Trunk | Severity: Problem
Keywords: |
-------------------------------------+-------------------------
In the following calculations (please see code included below), the 4
results cannot be all correct at the same time.
Also, if one will to uncomment the last block of code, one would find that
its calculation would fail.
'''Thoughts:'''
* Now when the probability of "success" p0 (you used p in your
documentation) is 1, shouldn't the value of the corresponding random
variable be simply 0? If so, shouldn't the quantiles at p=0 and p=1 be
both at 0?
* Similarly, when p0 is 0, I would think it is quite "natural" to
set/define the corresponding random variable to be one with mass 1 at
infinity ... no need to work so hard to search for the zero as the error
to the final calculation shows.
Thank you.[[br]]
HS
P.S. Please copy the included code to a test.cpp and then build with g++
-o test test.cpp.
P.ps. If the evaluation policy will to change to ignore the error, it
''appears'' that the calculation never complete. Can something be done to
prevent this? Suggestions?
{{{
#define BOOST_MATH_DOMAIN_ERROR_POLICY ignore_error
#define BOOST_MATH_OVERFLOW_ERROR_POLICY ignore_error
// #define BOOST_MATH_EVALUATION_ERROR_POLICY ignore_error
#define BOOST_MATH_DISCRETE_QUANTILE_POLICY integer_round_up
#include <cstdlib>
#include <cstdio>
#include <boost/math/distributions/negative_binomial.hpp>
int main()
{
double _r0 = 3.0;
double _p0 = 1.0;
boost::math::negative_binomial_distribution<> _dist( _r0, _p0 );
std::printf(
"\n"
" r = %g\n"
" p = %g\n\n",
_r0,
_p0 );
std::printf(
" Quantile(%g;upperTail=false) = %g\n",
1.0,
boost::math::quantile( _dist, 1.0 ) );
std::printf(
" Quantile(%g;upperTail=true) = %g\n\n",
1.0,
boost::math::quantile(
boost::math::complement(
_dist,
1.0 ) ) );
std::printf(
" Quantile(%g;upperTail=false) = %g\n",
0.0,
boost::math::quantile( _dist, 0.0 ) );
std::printf(
" Quantile(%g;upperTail=true) = %g\n\n",
0.0,
boost::math::quantile(
boost::math::complement(
_dist,
0.0 ) ) );
/*
{
_p0 = 0.0;
boost::math::negative_binomial_distribution<> _dist( _r0, _p0 );
std::printf(
"\n"
" r = %g\n"
" p = %g\n\n",
_r0,
_p0 );
std::printf(
" Quantile(%g;upperTail=false) = %g\n",
0.32,
boost::math::quantile( _dist, 0.32 ) );
}
*/
return EXIT_SUCCESS;
}
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/9834> 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:15 UTC