brentworden 2004/04/08 13:46:01
Modified: math/src/java/org/apache/commons/math/distribution
BinomialDistributionImpl.java
ExponentialDistributionImpl.java
FDistributionImpl.java
AbstractContinuousDistribution.java
ChiSquaredDistributionImpl.java
DiscreteDistribution.java
AbstractDiscreteDistribution.java
ContinuousDistribution.java
NormalDistributionImpl.java
HypergeometricDistributionImpl.java
TDistributionImpl.java GammaDistributionImpl.java
math/src/java/org/apache/commons/math
ConvergenceException.java
math/src/java/org/apache/commons/math/stat
TestStatistic.java TestStatisticImpl.java
math/src/java/org/apache/commons/math/complex
ComplexFormat.java
math/src/java/org/apache/commons/math/util MathUtils.java
math/src/java/org/apache/commons/math/linear
RealMatrixImpl.java MatrixIndexException.java
InvalidMatrixException.java
Log:
Added serveral javadoc comments. Added constructors to the matrix exception classes
to mimic the existing math exceptions.
Revision Changes Path
1.12 +3 -1
jakarta-commons/math/src/java/org/apache/commons/math/distribution/BinomialDistributionImpl.java
Index: BinomialDistributionImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/distribution/BinomialDistributionImpl.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- BinomialDistributionImpl.java 21 Feb 2004 21:35:14 -0000 1.11
+++ BinomialDistributionImpl.java 8 Apr 2004 20:45:59 -0000 1.12
@@ -114,6 +114,8 @@
* For this disbution, X, this method returns P(X ≤ x).
* @param x the value at which the PDF is evaluated.
* @return PDF for this distribution.
+ * @exception MathException if the cumulative probability can not be
+ * computed due to convergence or other numerical errors.
*/
public double cumulativeProbability(int x) throws MathException {
double ret;
1.14 +7 -1
jakarta-commons/math/src/java/org/apache/commons/math/distribution/ExponentialDistributionImpl.java
Index: ExponentialDistributionImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/distribution/ExponentialDistributionImpl.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- ExponentialDistributionImpl.java 21 Feb 2004 21:35:14 -0000 1.13
+++ ExponentialDistributionImpl.java 8 Apr 2004 20:45:59 -0000 1.14
@@ -70,6 +70,8 @@
*
* @param x the value at which the CDF is evaluated.
* @return CDF for this distribution.
+ * @exception MathException if the cumulative probability can not be
+ * computed due to convergence or other numerical errors.
*/
public double cumulativeProbability(double x) throws MathException{
double ret;
@@ -87,6 +89,8 @@
*
* @param p the desired probability
* @return x, such that P(X < x) = <code>p</code>
+ * @exception MathException if the inverse cumulative probability can not be
+ * computed due to convergence or other numerical errors.
*/
public double inverseCumulativeProbability(double p) throws MathException{
double ret;
@@ -107,6 +111,8 @@
* @param x0 the lower bound
* @param x1 the upper bound
* @return the cumulative probability.
+ * @exception MathException if the cumulative probability can not be
+ * computed due to convergence or other numerical errors.
*/
public double cumulativeProbability(double x0, double x1) throws MathException{
return cumulativeProbability(x1) - cumulativeProbability(x0);
1.15 +3 -1
jakarta-commons/math/src/java/org/apache/commons/math/distribution/FDistributionImpl.java
Index: FDistributionImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/distribution/FDistributionImpl.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- FDistributionImpl.java 21 Feb 2004 21:35:14 -0000 1.14
+++ FDistributionImpl.java 8 Apr 2004 20:45:59 -0000 1.15
@@ -60,6 +60,8 @@
*
* @param x the value at which the CDF is evaluated.
* @return CDF for this distribution.
+ * @exception MathException if the cumulative probability can not be
+ * computed due to convergence or other numerical errors.
*/
public double cumulativeProbability(double x) throws MathException {
double ret;
1.20 +5 -1
jakarta-commons/math/src/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java
Index: AbstractContinuousDistribution.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- AbstractContinuousDistribution.java 21 Feb 2004 21:35:14 -0000 1.19
+++ AbstractContinuousDistribution.java 8 Apr 2004 20:45:59 -0000 1.20
@@ -44,6 +44,8 @@
* @param x0 the lower bound
* @param x1 the upper bound
* @return the cumulative probability.
+ * @exception MathException if the cumulative probability can not be
+ * computed due to convergence or other numerical errors.
*/
public double cumulativeProbability(double x0, double x1)
throws MathException {
@@ -56,6 +58,8 @@
*
* @param p the desired probability
* @return x, such that P(X < x) = <code>p</code>
+ * @exception MathException if the inverse cumulative probability can not be
+ * computed due to convergence or other numerical errors.
*/
public double inverseCumulativeProbability(final double p)
throws MathException {
1.15 +3 -1
jakarta-commons/math/src/java/org/apache/commons/math/distribution/ChiSquaredDistributionImpl.java
Index: ChiSquaredDistributionImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/distribution/ChiSquaredDistributionImpl.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- ChiSquaredDistributionImpl.java 21 Feb 2004 21:35:14 -0000 1.14
+++ ChiSquaredDistributionImpl.java 8 Apr 2004 20:45:59 -0000 1.15
@@ -61,6 +61,8 @@
* For this disbution, X, this method returns P(X < x).
* @param x the value at which the CDF is evaluated.
* @return CDF for this distribution.
+ * @exception MathException if the cumulative probability can not be
+ * computed due to convergence or other numerical errors.
*/
public double cumulativeProbability(double x) throws MathException {
return getGamma().cumulativeProbability(x);
1.11 +7 -1
jakarta-commons/math/src/java/org/apache/commons/math/distribution/DiscreteDistribution.java
Index: DiscreteDistribution.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/distribution/DiscreteDistribution.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- DiscreteDistribution.java 21 Feb 2004 21:35:14 -0000 1.10
+++ DiscreteDistribution.java 8 Apr 2004 20:45:59 -0000 1.11
@@ -34,6 +34,8 @@
* For this disbution, X, this method returns P(X ≤ x).
* @param x the value at which the PDF is evaluated.
* @return PDF for this distribution.
+ * @exception MathException if the cumulative probability can not be
+ * computed due to convergence or other numerical errors.
*/
double cumulativeProbability(int x) throws MathException;
@@ -42,6 +44,8 @@
* @param x0 the inclusive, lower bound
* @param x1 the inclusive, upper bound
* @return the cumulative probability.
+ * @exception MathException if the cumulative probability can not be
+ * computed due to convergence or other numerical errors.
*/
double cumulativeProbability(int x0, int x1) throws MathException;
@@ -49,6 +53,8 @@
* For this disbution, X, this method returns x such that P(X ≤ x) <= p.
* @param p the cumulative probability.
* @return x.
+ * @exception MathException if the inverse cumulative probability can not be
+ * computed due to convergence or other numerical errors.
*/
int inverseCumulativeProbability(double p) throws MathException;
}
1.12 +5 -1
jakarta-commons/math/src/java/org/apache/commons/math/distribution/AbstractDiscreteDistribution.java
Index: AbstractDiscreteDistribution.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/distribution/AbstractDiscreteDistribution.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- AbstractDiscreteDistribution.java 21 Feb 2004 21:35:14 -0000 1.11
+++ AbstractDiscreteDistribution.java 8 Apr 2004 20:45:59 -0000 1.12
@@ -40,6 +40,8 @@
* @param x0 the inclusive, lower bound
* @param x1 the inclusive, upper bound
* @return the cumulative probability.
+ * @exception MathException if the cumulative probability can not be
+ * computed due to convergence or other numerical errors.
*/
public double cumulativeProbability(int x0, int x1) throws MathException{
return cumulativeProbability(x1) -
@@ -52,6 +54,8 @@
*
* @param p the desired probability
* @return x, such that P(X < x) = <code>p</code>
+ * @exception MathException if the inverse cumulative probability can not be
+ * computed due to convergence or other numerical errors.
*/
public int inverseCumulativeProbability(final double p) throws MathException{
if (p < 0.0 || p > 1.0) {
1.13 +7 -1
jakarta-commons/math/src/java/org/apache/commons/math/distribution/ContinuousDistribution.java
Index: ContinuousDistribution.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/distribution/ContinuousDistribution.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- ContinuousDistribution.java 21 Feb 2004 21:35:14 -0000 1.12
+++ ContinuousDistribution.java 8 Apr 2004 20:45:59 -0000 1.13
@@ -27,6 +27,8 @@
* For this disbution, X, this method returns P(X < x).
* @param x the value at which the CDF is evaluated.
* @return CDF for this distribution.
+ * @exception MathException if the cumulative probability can not be
+ * computed due to convergence or other numerical errors.
*/
double cumulativeProbability(double x) throws MathException;
@@ -35,6 +37,8 @@
* @param x0 the lower bound
* @param x1 the upper bound
* @return the cumulative probability.
+ * @exception MathException if the cumulative probability can not be
+ * computed due to convergence or other numerical errors.
*/
double cumulativeProbability(double x0, double x1) throws MathException;
@@ -42,6 +46,8 @@
* For this disbution, X, this method returns x such that P(X < x) = p.
* @param p the cumulative probability.
* @return x.
+ * @exception MathException if the inverse cumulative probability can not be
+ * computed due to convergence or other numerical errors.
*/
double inverseCumulativeProbability(double p) throws MathException;
}
1.4 +6 -0
jakarta-commons/math/src/java/org/apache/commons/math/distribution/NormalDistributionImpl.java
Index: NormalDistributionImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/distribution/NormalDistributionImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- NormalDistributionImpl.java 21 Feb 2004 21:35:14 -0000 1.3
+++ NormalDistributionImpl.java 8 Apr 2004 20:45:59 -0000 1.4
@@ -27,8 +27,14 @@
*/
public class NormalDistributionImpl extends AbstractContinuousDistribution
implements NormalDistribution, Serializable {
+
+ /** The mean of this distribution. */
private double mean = 0;
+
+ /** The standard deviation of this distribution. */
private double standardDeviation = 1;
+
+ /** The algorithm used to compute cumulative probabilities. */
private NormalCDFAlgorithm cdfAlgorithm = new NormalCDFPreciseAlgorithm();
/**
1.11 +3 -1
jakarta-commons/math/src/java/org/apache/commons/math/distribution/HypergeometricDistributionImpl.java
Index: HypergeometricDistributionImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/distribution/HypergeometricDistributionImpl.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- HypergeometricDistributionImpl.java 21 Feb 2004 21:35:14 -0000 1.10
+++ HypergeometricDistributionImpl.java 8 Apr 2004 20:45:59 -0000 1.11
@@ -59,6 +59,8 @@
* For this disbution, X, this method returns P(X ≤ x).
* @param x the value at which the PDF is evaluated.
* @return PDF for this distribution.
+ * @exception MathException if the cumulative probability can not be
+ * computed due to convergence or other numerical errors.
*/
public double cumulativeProbability(int x) throws MathException{
double ret;
1.15 +3 -1
jakarta-commons/math/src/java/org/apache/commons/math/distribution/TDistributionImpl.java
Index: TDistributionImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/distribution/TDistributionImpl.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- TDistributionImpl.java 21 Feb 2004 21:35:14 -0000 1.14
+++ TDistributionImpl.java 8 Apr 2004 20:45:59 -0000 1.15
@@ -65,6 +65,8 @@
* For this disbution, X, this method returns P(X < <code>x</code>).
* @param x the value at which the CDF is evaluated.
* @return CDF evaluted at <code>x</code>.
+ * @exception MathException if the cumulative probability can not be
+ * computed due to convergence or other numerical errors.
*/
public double cumulativeProbability(double x) throws MathException{
double ret;
1.18 +3 -1
jakarta-commons/math/src/java/org/apache/commons/math/distribution/GammaDistributionImpl.java
Index: GammaDistributionImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/distribution/GammaDistributionImpl.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- GammaDistributionImpl.java 21 Feb 2004 21:35:14 -0000 1.17
+++ GammaDistributionImpl.java 8 Apr 2004 20:45:59 -0000 1.18
@@ -59,6 +59,8 @@
*
* @param x the value at which the CDF is evaluated.
* @return CDF for this distribution.
+ * @exception MathException if the cumulative probability can not be
+ * computed due to convergence or other numerical errors.
*/
public double cumulativeProbability(double x) throws MathException{
double ret;
1.11 +1 -2
jakarta-commons/math/src/java/org/apache/commons/math/ConvergenceException.java
Index: ConvergenceException.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/ConvergenceException.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ConvergenceException.java 18 Feb 2004 03:24:19 -0000 1.10
+++ ConvergenceException.java 8 Apr 2004 20:46:00 -0000 1.11
@@ -57,5 +57,4 @@
public ConvergenceException(Throwable throwable) {
this(null, throwable);
}
-
}
1.14 +3 -1
jakarta-commons/math/src/java/org/apache/commons/math/stat/TestStatistic.java
Index: TestStatistic.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/stat/TestStatistic.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- TestStatistic.java 8 Mar 2004 04:22:12 -0000 1.13
+++ TestStatistic.java 8 Apr 2004 20:46:00 -0000 1.14
@@ -152,6 +152,8 @@
* @param sample2 array of sample data values
* @return t statistic
* @throws IllegalArgumentException if the precondition is not met
+ * @throws MathException if the statistic can not be computed do to a
+ * convergence or other numerical error.
*/
double t(double[] sample1, double[] sample2)
throws IllegalArgumentException, MathException;
1.15 +3 -1
jakarta-commons/math/src/java/org/apache/commons/math/stat/TestStatisticImpl.java
Index: TestStatisticImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/stat/TestStatisticImpl.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- TestStatisticImpl.java 8 Mar 2004 04:22:12 -0000 1.14
+++ TestStatisticImpl.java 8 Apr 2004 20:46:00 -0000 1.15
@@ -342,6 +342,7 @@
* @param n1 first sample n
* @param n2 second sample n
* @return p-value
+ * @throws MathException if an error occurs computing the p-value
*/
private double tTest(double m1, double m2, double v1, double v2, double n1,
double n2)
throws MathException {
@@ -359,6 +360,7 @@
* @param v sample variance
* @param n sample n
* @return p-value
+ * @throws MathException if an error occurs computing the p-value
*/
private double tTest(double m, double mu, double v, double n)
throws MathException {
1.4 +8 -1
jakarta-commons/math/src/java/org/apache/commons/math/complex/ComplexFormat.java
Index: ComplexFormat.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/complex/ComplexFormat.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ComplexFormat.java 29 Feb 2004 19:40:39 -0000 1.3
+++ ComplexFormat.java 8 Apr 2004 20:46:00 -0000 1.4
@@ -28,11 +28,15 @@
*/
public class ComplexFormat {
+ /** The default complex format. */
private static final ComplexFormat DEFAULT = new ComplexFormat();
// @TODO This class only allows for max fraction digits, we might want to
allow other parameters
+
+ /** The notation used to signify the imaginary part of the complex number. */
private String imaginaryCharacter = "i";
+ /** The maximum number of decimal digits in the formatted output. */
private int fractionDigits = 2;
/**
@@ -44,6 +48,7 @@
/**
* Create an instance with a custom imaginary character, and the default number
* of decimal places - 2.
+ * @param imaginaryCharacter The custom imaginary character.
*/
public ComplexFormat(String imaginaryCharacter) {
this.imaginaryCharacter = imaginaryCharacter;
@@ -52,6 +57,8 @@
/**
* Create an instance with a custom imaginary character, and a custom number of
* decimal places.
+ * @param imaginaryCharacter The custom imaginary character.
+ * @param fractionDigits The custom number of decimal places.
*/
public ComplexFormat(String imaginaryCharacter, int fractionDigits) {
this.imaginaryCharacter = imaginaryCharacter;
1.14 +7 -1
jakarta-commons/math/src/java/org/apache/commons/math/util/MathUtils.java
Index: MathUtils.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/util/MathUtils.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- MathUtils.java 5 Apr 2004 03:47:49 -0000 1.13
+++ MathUtils.java 8 Apr 2004 20:46:01 -0000 1.14
@@ -23,16 +23,22 @@
*/
public final class MathUtils {
+ /** 0.0 cast as a byte. */
private static final byte ZB = (byte) 0;
+ /** -1.0 cast as a byte. */
private static final byte NB = (byte) -1;
+ /** 1.0 cast as a byte. */
private static final byte PB = (byte) 1;
+ /** 0.0 cast as a short. */
private static final short ZS = (short) 0;
+ /** -1.0 cast as a short. */
private static final short NS = (short) -1;
+ /** 1.0 cast as a short. */
private static final short PS = (short) 1;
/**
1.17 +2 -2
jakarta-commons/math/src/java/org/apache/commons/math/linear/RealMatrixImpl.java
Index: RealMatrixImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/linear/RealMatrixImpl.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- RealMatrixImpl.java 8 Apr 2004 07:01:17 -0000 1.16
+++ RealMatrixImpl.java 8 Apr 2004 20:46:01 -0000 1.17
@@ -417,7 +417,7 @@
/**
* @return determinant
- * @throws IllegalArgumentException if matrix is not square
+ * @throws InvalidMatrixException if matrix is not square
*/
public double getDeterminant() throws InvalidMatrixException {
if (!isSquare()) {
1.3 +32 -4
jakarta-commons/math/src/java/org/apache/commons/math/linear/MatrixIndexException.java
Index: MatrixIndexException.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/linear/MatrixIndexException.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MatrixIndexException.java 29 Jan 2004 16:48:49 -0000 1.2
+++ MatrixIndexException.java 8 Apr 2004 20:46:01 -0000 1.3
@@ -18,15 +18,43 @@
package org.apache.commons.math.linear;
+import org.apache.commons.lang.exception.NestableRuntimeException;
+
/**
* Thrown when an operation addresses a matrix coordinate (row,col)
* which is outside of the dimensions of a matrix.
* @version $Revision$ $Date$
*/
-public class MatrixIndexException extends RuntimeException {
+public class MatrixIndexException extends NestableRuntimeException {
+ /**
+ * Default constructor.
+ */
+ public MatrixIndexException() {
+ this(null, null);
+ }
+
+ /**
+ * Construct an exception with the given message.
+ * @param message descriptive error message.
+ */
+ public MatrixIndexException(String message) {
+ this(message, null);
+ }
- public MatrixIndexException(String s) {
- super( s );
+ /**
+ * Construct an exception with the given message and root cause.
+ * @param message descriptive error message.
+ * @param cause root cause.
+ */
+ public MatrixIndexException(String message, Throwable cause) {
+ super(message, cause);
}
+ /**
+ * Create an exception with a given root cause.
+ * @param throwable caught exception causing this problem
+ */
+ public MatrixIndexException(Throwable throwable) {
+ this(null, throwable);
+ }
}
1.3 +32 -4
jakarta-commons/math/src/java/org/apache/commons/math/linear/InvalidMatrixException.java
Index: InvalidMatrixException.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/linear/InvalidMatrixException.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- InvalidMatrixException.java 29 Jan 2004 16:48:49 -0000 1.2
+++ InvalidMatrixException.java 8 Apr 2004 20:46:01 -0000 1.3
@@ -18,16 +18,44 @@
package org.apache.commons.math.linear;
+import org.apache.commons.lang.exception.NestableRuntimeException;
+
/**
* Thrown when a system attempts an operation on a matrix, and
* that matrix does not satisfy the preconditions for the
* aforementioned operation.
* @version $Revision$ $Date$
*/
-public class InvalidMatrixException extends RuntimeException {
+public class InvalidMatrixException extends NestableRuntimeException {
+ /**
+ * Default constructor.
+ */
+ public InvalidMatrixException() {
+ this(null, null);
+ }
+
+ /**
+ * Construct an exception with the given message.
+ * @param message descriptive error message.
+ */
+ public InvalidMatrixException(String message) {
+ this(message, null);
+ }
- public InvalidMatrixException(String s) {
- super( s );
+ /**
+ * Construct an exception with the given message and root cause.
+ * @param message descriptive error message.
+ * @param cause root cause.
+ */
+ public InvalidMatrixException(String message, Throwable cause) {
+ super(message, cause);
}
+ /**
+ * Create an exception with a given root cause.
+ * @param throwable caught exception causing this problem
+ */
+ public InvalidMatrixException(Throwable throwable) {
+ this(null, throwable);
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]