Opened 12 years ago
Closed 12 years ago
#4879 closed Bugs (fixed)
Apparent bugs in ibeta_inv_imp (math::specialfunctions)
Reported by: | Owned by: | John Maddock | |
---|---|---|---|
Milestone: | To Be Determined | Component: | math |
Version: | Boost 1.44.0 | Severity: | Problem |
Keywords: | Cc: |
Description
Hi,
There seem to be a couple of bugs in the above function (which is in boost\math\special_functions\detail\ibeta_inverse.hpp):
The first is the condition:
if((lambda >= 0.2) && (lambda <= 0.8) && (lambda >= 10))
This clearly can never evaluate to true (lambda <= 0.8 AND >= 10) - so the following code block can never be executed. I'm guessing that the third lambda should be replaced with r (a parameter defined a couple of lines higher which could reasonably satisfy the condition) - but I'm not a mathematician and so this is just a guess.
The second apparent problem is an inconsistency in the handling of the boolean flag invert. Initially set to false, in some parts of the code it is toggled to its complement whenever parameters a and b are swapped (which can happen more than once). However in other parts of the code it is simply set to true. Again I'm afraid I don't know enough to be sure that the latter is wrong, but changing all instances where it is set to true to instead set it to its complement fixes a problem I was getting with the Fisher_F distribution which relies on this function.
Could someone with more understanding than me of what's going here have a look at these ?
I believe you're correct on both counts - using r for the conditional agrees with my notes - and setting invert = !invert is a safer approach than we have now - it looks like this got broken when we added another inversion method as an optimisation which broke the invert == false precondition - looks like the issue can only be triggered when a == 0.5 and b < 0.5 - does this ring a bell?
John Maddock