From b84e9460b523946b4579966421b25fc2febc4880 Mon Sep 17 00:00:00 2001
From: "Mark R. Diggory"
Date: Sat, 21 Jun 2003 02:21:49 +0000
Subject: [PATCH] This is a multifile commit, it covers checkstyle errors in
javadoc etc. PR: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20936
Submitted by: brent@worden.org
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/math/trunk@140936 13f79535-47bb-0310-9956-ffa450edef68
---
.../commons/math/ContinuedFraction.java | 22 ++---
.../AbstractContinuousDistribution.java | 2 +-
.../distribution/ChiSquaredDistribution.java | 11 +--
.../distribution/DistributionFactory.java | 4 -
.../distribution/ExponentialDistribution.java | 10 +-
.../ExponentialDistributionImpl.java | 95 ++++++++++++++-----
.../math/distribution/FDistribution.java | 16 ++--
.../math/distribution/FDistributionImpl.java | 36 ++++---
.../math/distribution/GammaDistribution.java | 11 +--
.../distribution/GammaDistributionImpl.java | 8 +-
.../math/distribution/TDistribution.java | 14 +--
.../math/distribution/TDistributionImpl.java | 14 +--
.../org/apache/commons/math/special/Beta.java | 55 ++++++-----
.../apache/commons/math/special/Gamma.java | 10 --
14 files changed, 157 insertions(+), 151 deletions(-)
diff --git a/src/java/org/apache/commons/math/ContinuedFraction.java b/src/java/org/apache/commons/math/ContinuedFraction.java
index 332b93104..93c076775 100644
--- a/src/java/org/apache/commons/math/ContinuedFraction.java
+++ b/src/java/org/apache/commons/math/ContinuedFraction.java
@@ -54,16 +54,14 @@
package org.apache.commons.math;
/**
- *
* Provides a generic means to evaluate continued fractions. Subclasses simply
* provided the a and b coefficients to evaluate the continued fraction.
- *
*
- *
- * Reference:
- *
- * Continued Fraction
- *
+ * References:
+ *
*
* @author Brent Worden
*/
@@ -126,11 +124,8 @@ public abstract class ContinuedFraction {
}
/**
- *
* Evaluates the continued fraction at the value x.
- *
*
- *
* The implementation of this method is based on:
*
* - O. E-gecio-glu, C . K. Koc, J. Rifa i Coma,
@@ -138,7 +133,6 @@ public abstract class ContinuedFraction {
* Fast Computation of Continued Fractions, Computers Math. Applic.,
* 21(2--3), 1991, 167--169.
*
- *
*
* @param x the evaluation point.
* @param epsilon maximum error allowed.
@@ -188,11 +182,11 @@ public abstract class ContinuedFraction {
f[1][1] = (a[1][0] * an[0][1]) + (a[1][1] * an[1][1]);
// determine if we're close enough
- if(Math.abs((f[0][0] * f[1][1]) - (f[1][0] * f[0][1])) <
- Math.abs(epsilon * f[1][0] * f[1][1])){
+ if (Math.abs((f[0][0] * f[1][1]) - (f[1][0] * f[0][1])) <
+ Math.abs(epsilon * f[1][0] * f[1][1])) {
ret = f[0][0] / f[1][0];
} else {
- if(n >= maxIterations){
+ if (n >= maxIterations) {
throw new ConvergenceException(
"Continued fraction convergents failed to converge.");
}
diff --git a/src/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java b/src/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java
index 6ace83fc2..ce3276614 100644
--- a/src/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java
+++ b/src/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java
@@ -94,7 +94,7 @@ public abstract class AbstractContinuousDistribution
* @return x, such that P(X < x) = p
*/
public double inverseCummulativeProbability(final double p) {
- if (p < 0.0 || p > 1.0){
+ if (p < 0.0 || p > 1.0) {
throw new IllegalArgumentException(
"p must be between 0.0 and 1.0, inclusive.");
}
diff --git a/src/java/org/apache/commons/math/distribution/ChiSquaredDistribution.java b/src/java/org/apache/commons/math/distribution/ChiSquaredDistribution.java
index 0ca8ec4dc..e6bcd9581 100644
--- a/src/java/org/apache/commons/math/distribution/ChiSquaredDistribution.java
+++ b/src/java/org/apache/commons/math/distribution/ChiSquaredDistribution.java
@@ -54,21 +54,16 @@
package org.apache.commons.math.stat.distribution;
/**
- *
- * The Chi-Squared Distribution
- *
+ * The Chi-Squared Distribution.
*
- *
* Instances of ChiSquaredDistribution objects should be created using
- * {@link DistributionFactory#createChiSquareDistribution(double)}
- *
+ * {@link DistributionFactory#createChiSquareDistribution(double)}.
*
- *
* References:
*
*
* @author Brent Worden
*/
diff --git a/src/java/org/apache/commons/math/distribution/DistributionFactory.java b/src/java/org/apache/commons/math/distribution/DistributionFactory.java
index 96f3f49f8..95ab012d1 100644
--- a/src/java/org/apache/commons/math/distribution/DistributionFactory.java
+++ b/src/java/org/apache/commons/math/distribution/DistributionFactory.java
@@ -54,7 +54,6 @@
package org.apache.commons.math.stat.distribution;
/**
- *
* This factory provids the means to create common statistical distributions.
* The following distributions are supported:
*
@@ -63,16 +62,13 @@ package org.apache.commons.math.stat.distribution;
* - Gamma
* - Student's t
*
- *
*
- *
* Common usage:
* DistributionFactory factory = DistributionFactory.newInstance();
*
* // create a Chi-Square distribution with 5 degrees of freedom.
* ChiSquaredDistribution chi = factory.createChiSquareDistribution(5.0);
*
- *
*
* @author Brent Worden
*/
diff --git a/src/java/org/apache/commons/math/distribution/ExponentialDistribution.java b/src/java/org/apache/commons/math/distribution/ExponentialDistribution.java
index 6b0f60277..8a1e8d56b 100644
--- a/src/java/org/apache/commons/math/distribution/ExponentialDistribution.java
+++ b/src/java/org/apache/commons/math/distribution/ExponentialDistribution.java
@@ -54,21 +54,15 @@
package org.apache.commons.math.stat.distribution;
/**
- *
- * The Exponential Distribution
- *
+ * The Exponential Distribution.
*
- *
* Instances of ExponentialDistribution objects should be created using
- * {@link DistributionFactory#createExponentialDistribution(double)}
- *
+ * {@link DistributionFactory#createExponentialDistribution(double)}.
*
- *
* References:
*
* -
* Exponential Distribution
- *
*
* @author Brent Worden
*/
diff --git a/src/java/org/apache/commons/math/distribution/ExponentialDistributionImpl.java b/src/java/org/apache/commons/math/distribution/ExponentialDistributionImpl.java
index 424be9b07..313e4a4ce 100644
--- a/src/java/org/apache/commons/math/distribution/ExponentialDistributionImpl.java
+++ b/src/java/org/apache/commons/math/distribution/ExponentialDistributionImpl.java
@@ -1,3 +1,56 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Commons", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ */
package org.apache.commons.math.stat.distribution;
/**
@@ -6,65 +59,61 @@ package org.apache.commons.math.stat.distribution;
* @author Brent Worden
*/
public class ExponentialDistributionImpl
- implements ExponentialDistribution {
+ implements ExponentialDistribution {
/** The mean of this distribution. */
private double mean;
/**
* Create a exponential distribution with the given mean.
- * @param degreesOfFreedom degrees of freedom.
+ * @param mean mean of this distribution.
*/
- public ExponentialDistributionImpl(double mean) {
- super();
+ public ExponentialDistributionImpl(double mean) {
+ super();
setMean(mean);
- }
+ }
/**
* Modify the mean.
* @param mean the new mean.
*/
- public void setMean(double mean) {
- if(mean <= 0.0){
+ public void setMean(double mean) {
+ if (mean <= 0.0) {
throw new IllegalArgumentException("mean must be positive.");
}
this.mean = mean;
- }
+ }
/**
* Access the mean.
* @return the mean.
*/
- public double getMean() {
- return mean;
- }
+ public double getMean() {
+ return mean;
+ }
/**
- *
* For this disbution, X, this method returns P(X < x).
- *
*
- *
* The implementation of this method is based on:
*
- *
*
* @param x the value at which the CDF is evaluated.
* @return CDF for this distribution.
*/
- public double cummulativeProbability(double x) {
+ public double cummulativeProbability(double x) {
double ret;
- if(x <= 0.0){
+ if (x <= 0.0) {
ret = 0.0;
- } else {
+ } else {
ret = 1.0 - Math.exp(-x / getMean());
- }
+ }
return ret;
- }
+ }
/**
* For this distribution, X, this method returns the critical point x, such
@@ -73,12 +122,12 @@ public class ExponentialDistributionImpl
* @param p the desired probability
* @return x, such that P(X < x) = p
*/
- public double inverseCummulativeProbability(double p){
+ public double inverseCummulativeProbability(double p) {
double ret;
- if(p < 0.0 || p > 1.0){
+ if (p < 0.0 || p > 1.0) {
ret = Double.NaN;
- } else if(p == 1.0){
+ } else if (p == 1.0) {
ret = Double.POSITIVE_INFINITY;
} else {
ret = -getMean() * Math.log(1.0 - p);
diff --git a/src/java/org/apache/commons/math/distribution/FDistribution.java b/src/java/org/apache/commons/math/distribution/FDistribution.java
index 76b09b389..aadc52a55 100644
--- a/src/java/org/apache/commons/math/distribution/FDistribution.java
+++ b/src/java/org/apache/commons/math/distribution/FDistribution.java
@@ -54,20 +54,16 @@
package org.apache.commons.math.stat.distribution;
/**
- *
* F-Distribution.
- *
*
- *
* Instances of FDistribution objects should be created using
- * {@link DistributionFactory#createFDistribution(double,double)}
- *
+ * {@link DistributionFactory#createFDistribution(double,double)}.
*
- *
- * Reference:
- *
- * F-Distribution
- *
+ * References:
+ *
*
* @author Brent Worden
*/
diff --git a/src/java/org/apache/commons/math/distribution/FDistributionImpl.java b/src/java/org/apache/commons/math/distribution/FDistributionImpl.java
index 89665a637..56913d865 100644
--- a/src/java/org/apache/commons/math/distribution/FDistributionImpl.java
+++ b/src/java/org/apache/commons/math/distribution/FDistributionImpl.java
@@ -57,7 +57,7 @@ import org.apache.commons.math.special.Beta;
/**
* Default implementation of
- * {@link org.apache.commons.math.stat.distribution.TDistribution}.
+ * {@link org.apache.commons.math.stat.distribution.FDistribution}.
*
* @author Brent Worden
*/
@@ -73,35 +73,32 @@ public class FDistributionImpl
/**
* Create a F distribution using the given degrees of freedom.
- * @param numeratorDegreesOfFreedom the degrees of freedom.
- * @param denominatorDegreesOfFreedom
+ * @param numeratorDegreesOfFreedom the numerator degrees of freedom.
+ * @param denominatorDegreesOfFreedom the denominator degrees of freedom.
*/
public FDistributionImpl(double numeratorDegreesOfFreedom,
- double denominatorDegreesOfFreedom){
+ double denominatorDegreesOfFreedom) {
super();
setNumeratorDegreesOfFreedom(numeratorDegreesOfFreedom);
setDenominatorDegreesOfFreedom(denominatorDegreesOfFreedom);
}
/**
- *
* For this disbution, X, this method returns P(X < x).
- *
*
- *
* The implementation of this method is based on:
*
*
* @param x the value at which the CDF is evaluated.
* @return CDF for this distribution.
*/
public double cummulativeProbability(double x) {
double ret;
- if(x <= 0.0){
+ if (x <= 0.0) {
ret = 0.0;
} else {
double n = getNumeratorDegreesOfFreedom();
@@ -123,7 +120,7 @@ public class FDistributionImpl
* @return domain value lower bound, i.e.
* P(X < lower bound) < p
*/
- protected double getDomainLowerBound(double p){
+ protected double getDomainLowerBound(double p) {
return 0.0;
}
@@ -136,7 +133,7 @@ public class FDistributionImpl
* @return domain value upper bound, i.e.
* P(X < upper bound) > p
*/
- protected double getDomainUpperBound(double p){
+ protected double getDomainUpperBound(double p) {
return Double.MAX_VALUE;
}
@@ -148,16 +145,17 @@ public class FDistributionImpl
* @param p the desired probability for the critical value
* @return initial domain value
*/
- protected double getInitialDomain(double p){
- return getDenominatorDegreesOfFreedom() / (getDenominatorDegreesOfFreedom() - 2.0);
+ protected double getInitialDomain(double p) {
+ return getDenominatorDegreesOfFreedom() /
+ (getDenominatorDegreesOfFreedom() - 2.0);
}
/**
* Modify the numerator degrees of freedom.
* @param degreesOfFreedom the new numerator degrees of freedom.
*/
- public void setNumeratorDegreesOfFreedom(double degreesOfFreedom){
- if(degreesOfFreedom <= 0.0){
+ public void setNumeratorDegreesOfFreedom(double degreesOfFreedom) {
+ if (degreesOfFreedom <= 0.0) {
throw new IllegalArgumentException(
"degrees of freedom must be positive.");
}
@@ -168,7 +166,7 @@ public class FDistributionImpl
* Access the numerator degrees of freedom.
* @return the numerator degrees of freedom.
*/
- public double getNumeratorDegreesOfFreedom(){
+ public double getNumeratorDegreesOfFreedom() {
return numeratorDegreesOfFreedom;
}
@@ -176,8 +174,8 @@ public class FDistributionImpl
* Modify the denominator degrees of freedom.
* @param degreesOfFreedom the new denominator degrees of freedom.
*/
- public void setDenominatorDegreesOfFreedom(double degreesOfFreedom){
- if(degreesOfFreedom <= 0.0){
+ public void setDenominatorDegreesOfFreedom(double degreesOfFreedom) {
+ if (degreesOfFreedom <= 0.0) {
throw new IllegalArgumentException(
"degrees of freedom must be positive.");
}
@@ -188,7 +186,7 @@ public class FDistributionImpl
* Access the denominator degrees of freedom.
* @return the denominator degrees of freedom.
*/
- public double getDenominatorDegreesOfFreedom(){
+ public double getDenominatorDegreesOfFreedom() {
return denominatorDegreesOfFreedom;
}
}
diff --git a/src/java/org/apache/commons/math/distribution/GammaDistribution.java b/src/java/org/apache/commons/math/distribution/GammaDistribution.java
index 1c6c389f2..c86713591 100644
--- a/src/java/org/apache/commons/math/distribution/GammaDistribution.java
+++ b/src/java/org/apache/commons/math/distribution/GammaDistribution.java
@@ -54,21 +54,16 @@
package org.apache.commons.math.stat.distribution;
/**
- *
- * The Gamma Distribution
- *
+ * The Gamma Distribution.
*
- *
* Instances of GammaDistribution objects should be created using
- * {@link DistributionFactory#createGammaDistribution(double,double)}
- *
+ * {@link DistributionFactory#createGammaDistribution(double,double)}.
*
- *
* References:
*
*
* @author Brent Worden
*/
diff --git a/src/java/org/apache/commons/math/distribution/GammaDistributionImpl.java b/src/java/org/apache/commons/math/distribution/GammaDistributionImpl.java
index 110717a9e..2585cf474 100644
--- a/src/java/org/apache/commons/math/distribution/GammaDistributionImpl.java
+++ b/src/java/org/apache/commons/math/distribution/GammaDistributionImpl.java
@@ -81,11 +81,8 @@ public class GammaDistributionImpl extends AbstractContinuousDistribution
}
/**
- *
* For this disbution, X, this method returns P(X < x).
- *
*
- *
* The implementation of this method is based on:
*
* -
@@ -94,7 +91,6 @@ public class GammaDistributionImpl extends AbstractContinuousDistribution
*
- Casella, G., & Berger, R. (1990). Statistical Inference.
* Belmont, CA: Duxbury Press.
*
- *
*
* @param x the value at which the CDF is evaluated.
* @return CDF for this distribution.
@@ -179,7 +175,7 @@ public class GammaDistributionImpl extends AbstractContinuousDistribution
double ret;
- if(p < .5){
+ if (p < .5) {
// use mean
ret = getAlpha() * getBeta();
} else {
@@ -205,7 +201,7 @@ public class GammaDistributionImpl extends AbstractContinuousDistribution
double ret;
- if(p < .5){
+ if (p < .5) {
// use 1/2 mean
ret = getAlpha() * getBeta() * .5;
} else {
diff --git a/src/java/org/apache/commons/math/distribution/TDistribution.java b/src/java/org/apache/commons/math/distribution/TDistribution.java
index 0a00773e2..6ba3a7a99 100644
--- a/src/java/org/apache/commons/math/distribution/TDistribution.java
+++ b/src/java/org/apache/commons/math/distribution/TDistribution.java
@@ -54,20 +54,16 @@
package org.apache.commons.math.stat.distribution;
/**
- *
* Student's t-Distribution.
- *
*
- *
* Instances of TDistribution objects should be created using
* {@link DistributionFactory#createTDistribution(double)}
- *
*
- *
- * Reference:
- *
- * Student's t-Distribution
- *
+ * References:
+ *
*
* @author Brent Worden
*/
diff --git a/src/java/org/apache/commons/math/distribution/TDistributionImpl.java b/src/java/org/apache/commons/math/distribution/TDistributionImpl.java
index cec3c965d..f35d36818 100644
--- a/src/java/org/apache/commons/math/distribution/TDistributionImpl.java
+++ b/src/java/org/apache/commons/math/distribution/TDistributionImpl.java
@@ -72,7 +72,7 @@ public class TDistributionImpl
* Create a t distribution using the given degrees of freedom.
* @param degreesOfFreedom the degrees of freedom.
*/
- public TDistributionImpl(double degreesOfFreedom){
+ public TDistributionImpl(double degreesOfFreedom) {
super();
setDegreesOfFreedom(degreesOfFreedom);
}
@@ -82,7 +82,7 @@ public class TDistributionImpl
* @param degreesOfFreedom the new degrees of freedom.
*/
public void setDegreesOfFreedom(double degreesOfFreedom) {
- if(degreesOfFreedom <= 0.0){
+ if (degreesOfFreedom <= 0.0) {
throw new IllegalArgumentException(
"degrees of freedom must be positive.");
}
@@ -104,14 +104,14 @@ public class TDistributionImpl
*/
public double cummulativeProbability(double x) {
double ret;
- if(x == 0.0){
+ if (x == 0.0) {
ret = 0.5;
} else {
double t = Beta.regularizedBeta(
getDegreesOfFreedom() / (getDegreesOfFreedom() + (x * x)),
0.5 * getDegreesOfFreedom(), 0.5);
- if(x < 0.0){
+ if (x < 0.0) {
ret = 0.5 * t;
} else {
ret = 1.0 - 0.5 * t;
@@ -130,7 +130,7 @@ public class TDistributionImpl
* @return domain value lower bound, i.e.
* P(X < lower bound) < p
*/
- protected double getDomainLowerBound(double p){
+ protected double getDomainLowerBound(double p) {
return -Double.MAX_VALUE;
}
@@ -143,7 +143,7 @@ public class TDistributionImpl
* @return domain value upper bound, i.e.
* P(X < upper bound) > p
*/
- protected double getDomainUpperBound(double p){
+ protected double getDomainUpperBound(double p) {
return Double.MAX_VALUE;
}
@@ -155,7 +155,7 @@ public class TDistributionImpl
* @param p the desired probability for the critical value
* @return initial domain value
*/
- protected double getInitialDomain(double p){
+ protected double getInitialDomain(double p) {
return 0.0;
}
}
diff --git a/src/java/org/apache/commons/math/special/Beta.java b/src/java/org/apache/commons/math/special/Beta.java
index 1af354b96..8ec4ad72d 100644
--- a/src/java/org/apache/commons/math/special/Beta.java
+++ b/src/java/org/apache/commons/math/special/Beta.java
@@ -73,9 +73,7 @@ public class Beta {
}
/**
- *
* Returns the regularized beta function I(x, a, b).
- *
*
* @param x ???
* @param a ???
@@ -87,39 +85,40 @@ public class Beta {
}
/**
- *
* Returns the regularized beta function I(x, a, b).
- *
*
* @param x ???
* @param a ???
* @param b ???
+ * @param epsilon When the absolute value of the nth item in the
+ * series is less than epsilon the approximation ceases
+ * to calculate further elements in the series.
* @return the regularized beta function I(x, a, b)
*/
- public static double regularizedBeta(double x, double a, double b, double epsilon) {
+ public static double regularizedBeta(double x, double a, double b,
+ double epsilon) {
+
return regularizedBeta(x, a, b, epsilon, Integer.MAX_VALUE);
}
/**
- *
* Returns the regularized beta function I(x, a, b).
- *
*
* @param x ???
* @param a ???
* @param b ???
+ * @param maxIterations Maximum number of "iterations" to complete.
* @return the regularized beta function I(x, a, b)
*/
- public static double regularizedBeta(double x, double a, double b, int maxIterations) {
+ public static double regularizedBeta(double x, double a, double b,
+ int maxIterations) {
+
return regularizedBeta(x, a, b, DEFAULT_EPSILON, maxIterations);
}
/**
- *
* Returns the regularized beta function I(x, a, b).
- *
*
- *
* The implementation of this method is based on:
*
- *
*
* @param x ???
* @param a ???
* @param b ???
+ * @param epsilon When the absolute value of the nth item in the
+ * series is less than epsilon the approximation ceases
+ * to calculate further elements in the series.
+ * @param maxIterations Maximum number of "iterations" to complete.
* @return the regularized beta function I(x, a, b)
*/
- public static double regularizedBeta(double x, final double a, final double b, double epsilon, int maxIterations) {
+ public static double regularizedBeta(double x, final double a,
+ final double b, double epsilon, int maxIterations) {
+
double ret;
if (Double.isNaN(x) || Double.isNaN(a) || Double.isNaN(b) || (x < 0)
@@ -155,8 +159,9 @@ public class Beta {
if (n % 2 == 0) { // even
m = (n - 2.0) / 2.0;
ret =
- - ((a + m) * (a + b + m) * x)
- / ((a + (2 * m)) * (a + (2 * m) + 1.0));
+ -((a + m) * (a + b + m) * x)
+ / ((a + (2 * m))
+ * (a + (2 * m) + 1.0));
} else {
m = (n - 1.0) / 2.0;
ret =
@@ -180,17 +185,17 @@ public class Beta {
}
return ret;
}
- };
- ret = Math.exp((a * Math.log(x)) + (b * Math.log(1.0 - x)) - Math.log(a) - logBeta(a, b, epsilon, maxIterations)) * fraction.evaluate(x, epsilon, maxIterations);
+ };
+ ret = Math.exp((a * Math.log(x)) + (b * Math.log(1.0 - x))
+ - Math.log(a) - logBeta(a, b, epsilon, maxIterations))
+ * fraction.evaluate(x, epsilon, maxIterations);
}
return ret;
}
/**
- *
* Returns the natural logarithm of the beta function B(a, b).
- *
*
* @param a ???
* @param b ???
@@ -201,23 +206,25 @@ public class Beta {
}
/**
- *
* Returns the natural logarithm of the beta function B(a, b).
- *
*
- *
* The implementation of this method is based on:
*
- *
*
* @param a ???
* @param b ???
+ * @param epsilon When the absolute value of the nth item in the
+ * series is less than epsilon the approximation ceases
+ * to calculate further elements in the series.
+ * @param maxIterations Maximum number of "iterations" to complete.
* @return log(B(a, b))
*/
- public static double logBeta(double a, double b, double epsilon, int maxIterations) {
+ public static double logBeta(double a, double b, double epsilon,
+ int maxIterations) {
+
double ret;
if (Double.isNaN(a) || Double.isNaN(b) || (a <= 0.0) || (b <= 0.0)) {
diff --git a/src/java/org/apache/commons/math/special/Gamma.java b/src/java/org/apache/commons/math/special/Gamma.java
index 00a6bb2d2..1a770a5a1 100644
--- a/src/java/org/apache/commons/math/special/Gamma.java
+++ b/src/java/org/apache/commons/math/special/Gamma.java
@@ -94,9 +94,7 @@ public class Gamma {
}
/**
- *
* Returns the regularized gamma function P(a, x).
- *
*
* @param a ???
* @param x ???
@@ -107,11 +105,8 @@ public class Gamma {
}
/**
- *
* Returns the regularized gamma function P(a, x).
- *
*
- *
* The implementation of this method is based on:
*
* -
@@ -125,7 +120,6 @@ public class Gamma {
* Confluent Hypergeometric Function of the First Kind, equation (1).
*
*
- *
*
* @param a ???
* @param x ???
@@ -173,11 +167,8 @@ public class Gamma {
}
/**
- *
* Returns the natural logarithm of the gamma function Γ(x).
- *
*
- *
* The implementation of this method is based on:
*
- *
*
* @param x ???
* @return log(Γ(x))