boostorg/math

bug in boost libraries used by scipy.stats.beta

Gabriel-Kissin opened this issue · 0 comments

I've found a bug in a couple of python scipy probability functions which leads to the kernel crashing. In the case of the beta function, the error originates in the source in boost which appears to be at boost.org and on github in one of the lines reading BOOST_MATH_ASSERT(*p_derivative >= 0).

I originally posted this issue at scipy/scipy#18906. But am now reposting the python code here as requested there by @jzmaddock.

import scipy.stats
print([shape_param.domain for shape_param in scipy.stats.beta._shape_info()])
# [[5e-324, inf], [5e-324, inf]]
print(scipy.stats.beta(a=1e-308, b=5).ppf(.2))
# 0.0
print(scipy.stats.beta(a=1e-309, b=5).ppf(.2))
# OverflowError: Error in function boost::math::tgamma<d>(d): Overflow Error
# (raises error, but kernel doesn't crash)
print(scipy.stats.beta(a=1e-323, b=5).ppf(.2))
# KERNEL CRASHES with message: `Assertion failed: *p_derivative >= 0, file  
 ..\..\scipy\_lib\boost/boost/math/special_functions/beta.hpp, line 739`