Re: [Boost-bugs] [Boost C++ Libraries] #10110: boost::random::negative_binomial_distribution unnecessary restriction to IntType for parameter k

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #10110: boost::random::negative_binomial_distribution unnecessary restriction to IntType for parameter k
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-03-10 22:29:19


#10110: boost::random::negative_binomial_distribution unnecessary restriction to
IntType for parameter k
-------------------------------------+-------------------------------------
  Reporter: Maximilian Kleinert | Owner: no-maintainer
  <kleinert.max@…> | Status: new
      Type: Bugs | Component: random
 Milestone: To Be Determined | Severity: Problem
   Version: Boost 1.55.0 | Keywords: random, negative
Resolution: | binomial distribution
-------------------------------------+-------------------------------------

Comment (by Maximilian Kleinert <kleinert.max@…>):

 Hi Steven,

 thanks for your reply.
 I think that this implicit cast can lead to non-obvious bugs as well,
 since it changes the distribution in case for non integer parameter k. The
 standard only describes the negative binomial distribution for trials,
 e.g. integer parameters. So the behavior for a non integer value is
 unspecified by the standard.
 In practice, e.g. claim number modeling, real positive parameters are
 widely used.
 To avoid the implicit cast bug it would be possible to delete the
 constructor for non integer types. Then still no real parameters are
 usable (in fact they are not proper right now) but the compiler will
 reject it if someone tries.

 Regarding the issue about the assertions. I did some tests comparing
 std::negative_binomial_distribution and the one from boost. Summarizing,
 the parameter checks are not very satisfying either, see the attached
 comparison.txt.

 In my opinion it makes no sense that a negative_binomial_distribution with
 invalid parameters can be constructed and then may or may not fail during
 the sampling process. Especially in the case k=0 were -2^31 is produced
 which can happen if someone calculates with the (in principal) valid
 parameter k = 0.99.

 I produced these results with g++-4.9.real (Ubuntu 4.9.1-16ubuntu6) 4.9.1
 and compiled the attached example with: g++ -D_GLIBCXX_DEBUG -std=c++11 -o
 test test.cpp and without the _GLIBCXX_DEBUG flag.

 It would be great if both implementations of the negative binomial
 distribution will improve.

 Thank you, Max

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/10110#comment:2>
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