mdiggory 2003/06/20 19:21:49
Modified: math/src/java/org/apache/commons/math/special Beta.java
Gamma.java
math/src/java/org/apache/commons/math/stat/distribution
ChiSquaredDistribution.java GammaDistribution.java
DistributionFactory.java GammaDistributionImpl.java
TDistributionImpl.java ExponentialDistribution.java
ExponentialDistributionImpl.java
AbstractContinuousDistribution.java
TDistribution.java FDistributionImpl.java
FDistribution.java
math/src/java/org/apache/commons/math ContinuedFraction.java
Log:
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: [EMAIL PROTECTED]
Revision Changes Path
1.5 +31 -24
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/special/Beta.java
Index: Beta.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/special/Beta.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Beta.java 18 Jun 2003 20:02:27 -0000 1.4
+++ Beta.java 21 Jun 2003 02:21:48 -0000 1.5
@@ -73,9 +73,7 @@
}
/**
- * <p>
* Returns the regularized beta function I(x, a, b).
- * </p>
*
* @param x ???
* @param a ???
@@ -87,39 +85,40 @@
}
/**
- * <p>
* Returns the regularized beta function I(x, a, b).
- * </p>
*
* @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);
}
/**
- * <p>
* Returns the regularized beta function I(x, a, b).
- * </p>
*
* @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);
}
/**
- * <p>
* Returns the regularized beta function I(x, a, b).
- * </p>
*
- * <p>
* The implementation of this method is based on:
* <ul>
* <li>
@@ -129,14 +128,19 @@
* <a href="http://functions.wolfram.com/06.21.10.0001.01">
* Regularized Beta Function</a>.</li>
* </ul>
- * </p>
*
* @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 @@
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 @@
}
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;
}
/**
- * <p>
* Returns the natural logarithm of the beta function B(a, b).
- * </p>
*
* @param a ???
* @param b ???
@@ -201,23 +206,25 @@
}
/**
- * <p>
* Returns the natural logarithm of the beta function B(a, b).
- * </p>
*
- * <p>
* The implementation of this method is based on:
* <ul>
* <li><a href="http://mathworld.wolfram.com/BetaFunction.html">
* Beta Function</a>, equation (1).</li>
* </ul>
- * </p>
*
* @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)) {
1.7 +0 -10
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/special/Gamma.java
Index: Gamma.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/special/Gamma.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Gamma.java 18 Jun 2003 20:02:27 -0000 1.6
+++ Gamma.java 21 Jun 2003 02:21:48 -0000 1.7
@@ -94,9 +94,7 @@
}
/**
- * <p>
* Returns the regularized gamma function P(a, x).
- * </p>
*
* @param a ???
* @param x ???
@@ -107,11 +105,8 @@
}
/**
- * <p>
* Returns the regularized gamma function P(a, x).
- * </p>
*
- * <p>
* The implementation of this method is based on:
* <ul>
* <li>
@@ -125,7 +120,6 @@
* Confluent Hypergeometric Function of the First Kind</a>, equation (1).
* </li>
* </ul>
- * </p>
*
* @param a ???
* @param x ???
@@ -173,11 +167,8 @@
}
/**
- * <p>
* Returns the natural logarithm of the gamma function Γ(x).
- * </p>
*
- * <p>
* The implementation of this method is based on:
* <ul>
* <li><a href="http://mathworld.wolfram.com/GammaFunction.html">
@@ -188,7 +179,6 @@
* the computation of the convergent Lanczos complex Gamma approximation
* </a></li>
* </ul>
- * </p>
*
* @param x ???
* @return log(Γ(x))
1.4 +3 -8
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/distribution/ChiSquaredDistribution.java
Index: ChiSquaredDistribution.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/distribution/ChiSquaredDistribution.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ChiSquaredDistribution.java 5 Jun 2003 14:02:28 -0000 1.3
+++ ChiSquaredDistribution.java 21 Jun 2003 02:21:48 -0000 1.4
@@ -54,21 +54,16 @@
package org.apache.commons.math.stat.distribution;
/**
- * <p>
- * The Chi-Squared Distribution
- * </p>
+ * The Chi-Squared Distribution.
*
- * <p>
* Instances of ChiSquaredDistribution objects should be created using
- * [EMAIL PROTECTED] DistributionFactory#createChiSquareDistribution(double)}
- * </p>
+ * [EMAIL PROTECTED] DistributionFactory#createChiSquareDistribution(double)}.
*
- * <p>
* References:
* <ul>
* <li><a href="http://mathworld.wolfram.com/Chi-SquaredDistribution.html">
* Chi-Squared Distribution</a></li>
- * </p>
+ * </ul>
*
* @author Brent Worden
*/
1.5 +3 -8
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/distribution/GammaDistribution.java
Index: GammaDistribution.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/distribution/GammaDistribution.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- GammaDistribution.java 11 Jun 2003 11:14:41 -0000 1.4
+++ GammaDistribution.java 21 Jun 2003 02:21:48 -0000 1.5
@@ -54,21 +54,16 @@
package org.apache.commons.math.stat.distribution;
/**
- * <p>
- * The Gamma Distribution
- * </p>
+ * The Gamma Distribution.
*
- * <p>
* Instances of GammaDistribution objects should be created using
- * [EMAIL PROTECTED] DistributionFactory#createGammaDistribution(double,double)}
- * </p>
+ * [EMAIL PROTECTED] DistributionFactory#createGammaDistribution(double,double)}.
*
- * <p>
* References:
* <ul>
* <li><a href="http://mathworld.wolfram.com/GammaDistribution.html">
* Gamma Distribution</a></li>
- * </p>
+ * </ul>
*
* @author Brent Worden
*/
1.7 +0 -4
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/distribution/DistributionFactory.java
Index: DistributionFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/distribution/DistributionFactory.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- DistributionFactory.java 13 Jun 2003 13:22:41 -0000 1.6
+++ DistributionFactory.java 21 Jun 2003 02:21:48 -0000 1.7
@@ -54,7 +54,6 @@
package org.apache.commons.math.stat.distribution;
/**
- * <p>
* This factory provids the means to create common statistical distributions.
* The following distributions are supported:
* <ul>
@@ -63,16 +62,13 @@
* <li>Gamma</li>
* <li>Student's t</li>
* </ul>
- * </p>
*
- * <p>
* Common usage:<pre>
* DistributionFactory factory = DistributionFactory.newInstance();
*
* // create a Chi-Square distribution with 5 degrees of freedom.
* ChiSquaredDistribution chi = factory.createChiSquareDistribution(5.0);
* </pre>
- * </p>
*
* @author Brent Worden
*/
1.4 +2 -6
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/distribution/GammaDistributionImpl.java
Index: GammaDistributionImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/distribution/GammaDistributionImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- GammaDistributionImpl.java 5 Jun 2003 14:02:29 -0000 1.3
+++ GammaDistributionImpl.java 21 Jun 2003 02:21:48 -0000 1.4
@@ -81,11 +81,8 @@
}
/**
- * <p>
* For this disbution, X, this method returns P(X < x).
- * </p>
*
- * <p>
* The implementation of this method is based on:
* <ul>
* <li>
@@ -94,7 +91,6 @@
* <li>Casella, G., & Berger, R. (1990). <i>Statistical Inference</i>.
* Belmont, CA: Duxbury Press.</li>
* </ul>
- * </p>
*
* @param x the value at which the CDF is evaluated.
* @return CDF for this distribution.
@@ -179,7 +175,7 @@
double ret;
- if(p < .5){
+ if (p < .5) {
// use mean
ret = getAlpha() * getBeta();
} else {
@@ -205,7 +201,7 @@
double ret;
- if(p < .5){
+ if (p < .5) {
// use 1/2 mean
ret = getAlpha() * getBeta() * .5;
} else {
1.3 +7 -7
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/distribution/TDistributionImpl.java
Index: TDistributionImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/distribution/TDistributionImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TDistributionImpl.java 14 Jun 2003 04:17:49 -0000 1.2
+++ TDistributionImpl.java 21 Jun 2003 02:21:48 -0000 1.3
@@ -72,7 +72,7 @@
* 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 @@
* @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 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 @@
* @return domain value lower bound, i.e.
* P(X < <i>lower bound</i>) < <code>p</code>
*/
- protected double getDomainLowerBound(double p){
+ protected double getDomainLowerBound(double p) {
return -Double.MAX_VALUE;
}
@@ -143,7 +143,7 @@
* @return domain value upper bound, i.e.
* P(X < <i>upper bound</i>) > <code>p</code>
*/
- protected double getDomainUpperBound(double p){
+ protected double getDomainUpperBound(double p) {
return Double.MAX_VALUE;
}
@@ -155,7 +155,7 @@
* @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;
}
}
1.2 +2 -8
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/distribution/ExponentialDistribution.java
Index: ExponentialDistribution.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/distribution/ExponentialDistribution.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ExponentialDistribution.java 13 Jun 2003 13:22:41 -0000 1.1
+++ ExponentialDistribution.java 21 Jun 2003 02:21:48 -0000 1.2
@@ -54,21 +54,15 @@
package org.apache.commons.math.stat.distribution;
/**
- * <p>
- * The Exponential Distribution
- * </p>
+ * The Exponential Distribution.
*
- * <p>
* Instances of ExponentialDistribution objects should be created using
- * [EMAIL PROTECTED] DistributionFactory#createExponentialDistribution(double)}
- * </p>
+ * [EMAIL PROTECTED] DistributionFactory#createExponentialDistribution(double)}.
*
- * <p>
* References:
* <ul>
* <li><a href="http://mathworld.wolfram.com/ExponentialDistribution.html">
* Exponential Distribution</a></li>
- * </p>
*
* @author Brent Worden
*/
1.3 +72 -23
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/distribution/ExponentialDistributionImpl.java
Index: ExponentialDistributionImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/distribution/ExponentialDistributionImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ExponentialDistributionImpl.java 14 Jun 2003 04:24:43 -0000 1.2
+++ ExponentialDistributionImpl.java 21 Jun 2003 02:21:48 -0000 1.3
@@ -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 [EMAIL PROTECTED]
+ *
+ * 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
+ * <http://www.apache.org/>.
+ */
package org.apache.commons.math.stat.distribution;
/**
@@ -6,65 +59,61 @@
* @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;
+ }
/**
- * <p>
* For this disbution, X, this method returns P(X < x).
- * </p>
*
- * <p>
* The implementation of this method is based on:
* <ul>
* <li>
* <a href="http://mathworld.wolfram.com/ExponentialDistribution.html">
* Exponential Distribution</a>, equation (1).</li>
* </ul>
- * </p>
*
* @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 @@
* @param p the desired probability
* @return x, such that P(X < x) = <code>p</code>
*/
- 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);
1.4 +1 -1
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/distribution/AbstractContinuousDistribution.java
Index: AbstractContinuousDistribution.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/distribution/AbstractContinuousDistribution.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AbstractContinuousDistribution.java 11 Jun 2003 11:14:41 -0000 1.3
+++ AbstractContinuousDistribution.java 21 Jun 2003 02:21:48 -0000 1.4
@@ -94,7 +94,7 @@
* @return x, such that P(X < x) = <code>p</code>
*/
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.");
}
1.2 +5 -9
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/distribution/TDistribution.java
Index: TDistribution.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/distribution/TDistribution.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TDistribution.java 7 Jun 2003 13:57:54 -0000 1.1
+++ TDistribution.java 21 Jun 2003 02:21:48 -0000 1.2
@@ -54,20 +54,16 @@
package org.apache.commons.math.stat.distribution;
/**
- * <p>
* Student's t-Distribution.
- * </p>
*
- * <p>
* Instances of TDistribution objects should be created using
* [EMAIL PROTECTED] DistributionFactory#createTDistribution(double)}
- * </p>
*
- * <p>
- * Reference:<br/>
- * <a href="http://mathworld.wolfram.com/Studentst-Distribution.html">
- * Student's t-Distribution</a>
- * </p>
+ * References:
+ * <ul>
+ * <li><a href="http://mathworld.wolfram.com/Studentst-Distribution.html">
+ * Student's t-Distribution</a></li>
+ * </ul>
*
* @author Brent Worden
*/
1.3 +17 -19
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/distribution/FDistributionImpl.java
Index: FDistributionImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/distribution/FDistributionImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FDistributionImpl.java 11 Jun 2003 14:50:30 -0000 1.2
+++ FDistributionImpl.java 21 Jun 2003 02:21:48 -0000 1.3
@@ -57,7 +57,7 @@
/**
* Default implementation of
- * [EMAIL PROTECTED] org.apache.commons.math.stat.distribution.TDistribution}.
+ * [EMAIL PROTECTED] org.apache.commons.math.stat.distribution.FDistribution}.
*
* @author Brent Worden
*/
@@ -73,35 +73,32 @@
/**
* 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);
}
/**
- * <p>
* For this disbution, X, this method returns P(X < x).
- * </p>
*
- * <p>
* The implementation of this method is based on:
* <ul>
* <li>
* <a href="http://mathworld.wolfram.com/F-Distribution.html">
* F-Distribution</a>, equation (4).</li>
- * </p>
+ * </ul>
*
* @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 @@
* @return domain value lower bound, i.e.
* P(X < <i>lower bound</i>) < <code>p</code>
*/
- protected double getDomainLowerBound(double p){
+ protected double getDomainLowerBound(double p) {
return 0.0;
}
@@ -136,7 +133,7 @@
* @return domain value upper bound, i.e.
* P(X < <i>upper bound</i>) > <code>p</code>
*/
- protected double getDomainUpperBound(double p){
+ protected double getDomainUpperBound(double p) {
return Double.MAX_VALUE;
}
@@ -148,16 +145,17 @@
* @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 @@
* Access the numerator degrees of freedom.
* @return the numerator degrees of freedom.
*/
- public double getNumeratorDegreesOfFreedom(){
+ public double getNumeratorDegreesOfFreedom() {
return numeratorDegreesOfFreedom;
}
@@ -176,8 +174,8 @@
* 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 @@
* Access the denominator degrees of freedom.
* @return the denominator degrees of freedom.
*/
- public double getDenominatorDegreesOfFreedom(){
+ public double getDenominatorDegreesOfFreedom() {
return denominatorDegreesOfFreedom;
}
}
1.3 +6 -10
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/distribution/FDistribution.java
Index: FDistribution.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/distribution/FDistribution.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FDistribution.java 11 Jun 2003 11:14:41 -0000 1.2
+++ FDistribution.java 21 Jun 2003 02:21:48 -0000 1.3
@@ -54,20 +54,16 @@
package org.apache.commons.math.stat.distribution;
/**
- * <p>
* F-Distribution.
- * </p>
*
- * <p>
* Instances of FDistribution objects should be created using
- * [EMAIL PROTECTED] DistributionFactory#createFDistribution(double,double)}
- * </p>
+ * [EMAIL PROTECTED] DistributionFactory#createFDistribution(double,double)}.
*
- * <p>
- * Reference:<br/>
- * <a href="http://mathworld.wolfram.com/F-Distribution.html">
- * F-Distribution</a>
- * </p>
+ * References:
+ * <ul>
+ * <li><a href="http://mathworld.wolfram.com/F-Distribution.html">
+ * F-Distribution</a></li>
+ * </ul>
*
* @author Brent Worden
*/
1.3 +8 -14
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/ContinuedFraction.java
Index: ContinuedFraction.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/ContinuedFraction.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ContinuedFraction.java 11 Jun 2003 11:14:41 -0000 1.2
+++ ContinuedFraction.java 21 Jun 2003 02:21:49 -0000 1.3
@@ -54,16 +54,14 @@
package org.apache.commons.math;
/**
- * <p>
* Provides a generic means to evaluate continued fractions. Subclasses simply
* provided the a and b coefficients to evaluate the continued fraction.
- * </p>
*
- * <p>
- * Reference:<br/>
- * <a href="http://mathworld.wolfram.com/ContinuedFraction.html">
- * Continued Fraction</a>
- * </p>
+ * References:
+ * <ul>
+ * <li><a href="http://mathworld.wolfram.com/ContinuedFraction.html">
+ * Continued Fraction</a></li>
+ * </ul>
*
* @author Brent Worden
*/
@@ -126,11 +124,8 @@
}
/**
- * <p>
* Evaluates the continued fraction at the value x.
- * </p>
*
- * <p>
* The implementation of this method is based on:
* <ul>
* <li>O. E-gecio-glu, C . K. Koc, J. Rifa i Coma,
@@ -138,7 +133,6 @@
* Fast Computation of Continued Fractions</a>, Computers Math. Applic.,
* 21(2--3), 1991, 167--169.</li>
* </ul>
- * </p>
*
* @param x the evaluation point.
* @param epsilon maximum error allowed.
@@ -188,11 +182,11 @@
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.");
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]