[
https://issues.apache.org/jira/browse/MATH-1067?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Gilles resolved MATH-1067.
--------------------------
Resolution: Fixed
Fix Version/s: 3.3
Thanks for the report, and the fix!
Committed in revision 1546350.
> Stack overflow in Beta.regularizedBeta
> --------------------------------------
>
> Key: MATH-1067
> URL: https://issues.apache.org/jira/browse/MATH-1067
> Project: Commons Math
> Issue Type: Bug
> Affects Versions: 3.2
> Environment: Java build 1.7.0_45-b18
> Reporter: Florian Erhard
> Labels: easyfix, performance
> Fix For: 3.3
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> In
> org.apache.commons.math3.special.Beta.regularizedBeta(double,double,double,double,int),
> the case
> } else if (x > (a + 1.0) / (a + b + 2.0)) {
> ret = 1.0 - regularizedBeta(1.0 - x, b, a, epsilon, maxIterations);
> }
> is prone to infinite recursion: If x is approximately the tested value, then
> 1-x is approximately the tested value in the recursion. Thus, due to loss of
> precision after the subtraction, this condition can be true for the recursive
> call as well.
> Example:
> double x= Double.longBitsToDouble(4597303555101269224L);
> double a= Double.longBitsToDouble(4634227472812299606L);
> double b = Double.longBitsToDouble(4642050131540049920L);
> System.out.println(x > (a + 1.0) / (a + b + 2.0));
> System.out.println(1-x>(b + 1.0) / (b + a + 2.0));
> System.out.println(1-(1-x)>(a + 1.0) / (a + b + 2.0));
> Possible solution: change the condition to
> x > (a + 1.0) / (a + b + 2.0) && 1-x<=(b + 1.0) / (b + a + 2.0)
--
This message was sent by Atlassian JIRA
(v6.1#6144)