removed some condition logic by changing the continued fraction representation.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/math/trunk@141290 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d83250a890
commit
15aac108f1
|
@ -25,7 +25,7 @@ import org.apache.commons.math.util.ContinuedFraction;
|
||||||
* This is a utility class that provides computation methods related to the
|
* This is a utility class that provides computation methods related to the
|
||||||
* Gamma family of functions.
|
* Gamma family of functions.
|
||||||
*
|
*
|
||||||
* @version $Revision: 1.19 $ $Date: 2004/06/07 20:30:16 $
|
* @version $Revision: 1.20 $ $Date: 2004/06/10 18:34:53 $
|
||||||
*/
|
*/
|
||||||
public class Gamma implements Serializable {
|
public class Gamma implements Serializable {
|
||||||
|
|
||||||
|
@ -236,30 +236,15 @@ public class Gamma implements Serializable {
|
||||||
// create continued fraction
|
// create continued fraction
|
||||||
ContinuedFraction cf = new ContinuedFraction() {
|
ContinuedFraction cf = new ContinuedFraction() {
|
||||||
protected double getA(int n, double x) {
|
protected double getA(int n, double x) {
|
||||||
double ret;
|
return ((2.0 * n) + 1.0) - a + x;
|
||||||
switch(n) {
|
|
||||||
case 0: ret = 0.0; break;
|
|
||||||
default:
|
|
||||||
ret = ((2.0 * n) - 1.0) - a + x; break;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected double getB(int n, double x) {
|
protected double getB(int n, double x) {
|
||||||
double ret;
|
return n * (a - n);
|
||||||
double t;
|
|
||||||
switch(n) {
|
|
||||||
case 1: ret = 1.0; break;
|
|
||||||
default:
|
|
||||||
t = n - 1.0;
|
|
||||||
ret = t * (a - t);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ret = cf.evaluate(x, epsilon, maxIterations);
|
ret = 1.0 / cf.evaluate(x, epsilon, maxIterations);
|
||||||
ret = Math.exp(-x + (a * Math.log(x)) - logGamma(a)) * ret;
|
ret = Math.exp(-x + (a * Math.log(x)) - logGamma(a)) * ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue