#3533 closed Bugs (fixed)
Parameter range not checked in Incomplete Beta Function
Reported by: | Owned by: | John Maddock | |
---|---|---|---|
Milestone: | Boost 1.41.0 | Component: | math |
Version: | Boost 1.40.0 | Severity: | Problem |
Keywords: | Cc: |
Description
The incomplete beta function is defined for a > 0, b > 0 and 0 <= x <= 1.
A call to boost::math::ibeta(0,1,0.5) should raise an std::domain_error under default policy. The domain error on a (first parameter) is not detected.
Here is some very simple code : #include <iterator> #include <algorithm> #include "boost/math/special_functions/beta.hpp" #include "boost/math/special_functions/gamma.hpp" #include "boost/math/special_functions/log1p.hpp"
int main() {
double df1,df2; double x; double ret_val;
df1=0.0; df2=1; x=0.5;
ret_val=boost::math::ibeta(df1,df2,x);
std::cout<<" df1 = "<<df1<<" df2= "<<df2<<" x= "<< x <<" I_x(df1,df2)= "<<ret_val<<std::endl;
}
and the output :
df1 = 0 df2= 1 x= 0.5 I_x(df1,df2)= 1
(using g++ 4.3.2)
Change History (3)
comment:1 by , 13 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
comment:2 by , 13 years ago
Many thanks for this quick response.
I would then suggest : 1) to change the doc. ( which says "All of these functions require a > 0, b > 0 and 0 <= x <= 1. ") 2) to raise an exception for a=b=0 as I_x(0,0) is indeterminate.
Any way, the workaround is more than easy and the library very usefull !
comment:3 by , 13 years ago
Resolution: | wontfix → fixed |
---|
Whether it's a good idea or not I don't know, but the behaviour is deliberate as Ix(0,b) for b > 0 is well defined, finite, and real valued. Likewise Ix(a,0) for a > 0.
HTH, John.