commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject svn commit: r1061839 - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math/ main/java/org/apache/commons/math/random/ main/java/org/apache/commons/math/stat/descriptive/ main/java/org/apache/commons/math/stat/descriptive/moment/ site/x...
Date Fri, 21 Jan 2011 15:12:56 GMT
Author: erans
Date: Fri Jan 21 15:12:55 2011
New Revision: 1061839

URL: http://svn.apache.org/viewvc?rev=1061839&view=rev
Log:
MATH-491
Replaced old (checked) "DimensionMismatchException" by its unchecked
equivalent in package "exception".

Removed:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/DimensionMismatchException.java
Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/CorrelatedRandomVectorGenerator.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/MultivariateSummaryStatistics.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/SynchronizedMultivariateSummaryStatistics.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/VectorialCovariance.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/VectorialMean.java
    commons/proper/math/trunk/src/site/xdoc/changes.xml
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/random/CorrelatedRandomVectorGeneratorTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/random/UncorrelatedRandomVectorGeneratorTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/MultivariateSummaryStatisticsTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/SynchronizedMultivariateSummaryStatisticsTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/moment/VectorialCovarianceTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/moment/VectorialMeanTest.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/CorrelatedRandomVectorGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/CorrelatedRandomVectorGenerator.java?rev=1061839&r1=1061838&r2=1061839&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/CorrelatedRandomVectorGenerator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/CorrelatedRandomVectorGenerator.java Fri Jan 21 15:12:55 2011
@@ -17,7 +17,7 @@
 
 package org.apache.commons.math.random;
 
-import org.apache.commons.math.DimensionMismatchException;
+import org.apache.commons.math.exception.DimensionMismatchException;
 import org.apache.commons.math.exception.NonPositiveDefiniteMatrixException;
 import org.apache.commons.math.linear.MatrixUtils;
 import org.apache.commons.math.linear.RealMatrix;
@@ -62,19 +62,14 @@ import org.apache.commons.math.util.Fast
 
 public class CorrelatedRandomVectorGenerator
     implements RandomVectorGenerator {
-
     /** Mean vector. */
     private final double[] mean;
-
     /** Underlying generator. */
     private final NormalizedRandomGenerator generator;
-
     /** Storage for the normalized vector. */
     private final double[] normalized;
-
     /** Permutated Cholesky root of the covariance matrix. */
     private RealMatrix root;
-
     /** Rank of the covariance matrix. */
     private int rank;
 
@@ -87,18 +82,14 @@ public class CorrelatedRandomVectorGener
      * considered to be dependent on previous ones and are discarded
      * @param generator underlying generator for uncorrelated normalized
      * components
-     * @exception IllegalArgumentException if there is a dimension
-     * mismatch between the mean vector and the covariance matrix
-     * @exception NonPositiveDefiniteMatrixException if the
+     * @throws NonPositiveDefiniteMatrixException if the
      * covariance matrix is not strictly positive definite
-     * @exception DimensionMismatchException if the mean and covariance
-     * arrays dimensions don't match
+     * @throws DimensionMismatchException if the mean and covariance
+     * arrays dimensions do not match.
      */
     public CorrelatedRandomVectorGenerator(double[] mean,
                                            RealMatrix covariance, double small,
-                                           NormalizedRandomGenerator generator)
-    throws DimensionMismatchException {
-
+                                           NormalizedRandomGenerator generator) {
         int order = covariance.getRowDimension();
         if (mean.length != order) {
             throw new DimensionMismatchException(mean.length, order);
@@ -180,8 +171,8 @@ public class CorrelatedRandomVectorGener
      * @param covariance covariance matrix
      * @param small diagonal elements threshold under which  column are
      * considered to be dependent on previous ones and are discarded
-     * @exception NonPositiveDefiniteMatrixException if the
-     * covariance matrix is not strictly positive definite
+     * @throws NonPositiveDefiniteMatrixException if the
+     * covariance matrix is not strictly positive definite.
      */
     private void decompose(RealMatrix covariance, double small) {
         int order = covariance.getRowDimension();
@@ -258,9 +249,7 @@ public class CorrelatedRandomVectorGener
 
                 // prepare next iteration
                 loop = ++rank < order;
-
             }
-
         }
 
         // build the root matrix
@@ -294,7 +283,5 @@ public class CorrelatedRandomVectorGener
         }
 
         return correlated;
-
     }
-
 }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/MultivariateSummaryStatistics.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/MultivariateSummaryStatistics.java?rev=1061839&r1=1061838&r2=1061839&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/MultivariateSummaryStatistics.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/MultivariateSummaryStatistics.java Fri Jan 21 15:12:55 2011
@@ -19,9 +19,9 @@ package org.apache.commons.math.stat.des
 import java.io.Serializable;
 import java.util.Arrays;
 
-import org.apache.commons.math.DimensionMismatchException;
 import org.apache.commons.math.MathRuntimeException;
 import org.apache.commons.math.exception.util.LocalizedFormats;
+import org.apache.commons.math.exception.DimensionMismatchException;
 import org.apache.commons.math.linear.RealMatrix;
 import org.apache.commons.math.stat.descriptive.moment.GeometricMean;
 import org.apache.commons.math.stat.descriptive.moment.Mean;
@@ -68,7 +68,7 @@ import org.apache.commons.math.util.Fast
  * @version $Revision$ $Date$
  */
 public class MultivariateSummaryStatistics
-  implements StatisticalMultivariateSummary, Serializable {
+    implements StatisticalMultivariateSummary, Serializable {
 
     /** Serialization UID */
     private static final long serialVersionUID = 2271900808994826718L;
@@ -143,8 +143,7 @@ public class MultivariateSummaryStatisti
      * @throws DimensionMismatchException if the length of the array
      * does not match the one used at construction
      */
-    public void addValue(double[] value)
-      throws DimensionMismatchException {
+    public void addValue(double[] value) {
         checkDimension(value.length);
         for (int i = 0; i < k; ++i) {
             double v = value[i];
@@ -415,8 +414,7 @@ public class MultivariateSummaryStatisti
      *  (i.e if n > 0)
      */
     private void setImpl(StorelessUnivariateStatistic[] newImpl,
-                         StorelessUnivariateStatistic[] oldImpl)
-       throws DimensionMismatchException, IllegalStateException {
+                         StorelessUnivariateStatistic[] oldImpl) {
         checkEmpty();
         checkDimension(newImpl.length);
         System.arraycopy(newImpl, 0, oldImpl, 0, newImpl.length);
@@ -444,8 +442,7 @@ public class MultivariateSummaryStatisti
      * @throws IllegalStateException if data has already been added
      *  (i.e if n > 0)
      */
-    public void setSumImpl(StorelessUnivariateStatistic[] sumImpl)
-      throws DimensionMismatchException {
+    public void setSumImpl(StorelessUnivariateStatistic[] sumImpl) {
         setImpl(sumImpl, this.sumImpl);
     }
 
@@ -471,8 +468,7 @@ public class MultivariateSummaryStatisti
      * @throws IllegalStateException if data has already been added
      *  (i.e if n > 0)
      */
-    public void setSumsqImpl(StorelessUnivariateStatistic[] sumsqImpl)
-      throws DimensionMismatchException {
+    public void setSumsqImpl(StorelessUnivariateStatistic[] sumsqImpl) {
         setImpl(sumsqImpl, this.sumSqImpl);
     }
 
@@ -498,8 +494,7 @@ public class MultivariateSummaryStatisti
      * @throws IllegalStateException if data has already been added
      *  (i.e if n > 0)
      */
-    public void setMinImpl(StorelessUnivariateStatistic[] minImpl)
-      throws DimensionMismatchException {
+    public void setMinImpl(StorelessUnivariateStatistic[] minImpl) {
         setImpl(minImpl, this.minImpl);
     }
 
@@ -525,8 +520,7 @@ public class MultivariateSummaryStatisti
      * @throws IllegalStateException if data has already been added
      *  (i.e if n > 0)
      */
-    public void setMaxImpl(StorelessUnivariateStatistic[] maxImpl)
-      throws DimensionMismatchException {
+    public void setMaxImpl(StorelessUnivariateStatistic[] maxImpl) {
         setImpl(maxImpl, this.maxImpl);
     }
 
@@ -552,8 +546,7 @@ public class MultivariateSummaryStatisti
      * @throws IllegalStateException if data has already been added
      *  (i.e if n > 0)
      */
-    public void setSumLogImpl(StorelessUnivariateStatistic[] sumLogImpl)
-      throws DimensionMismatchException {
+    public void setSumLogImpl(StorelessUnivariateStatistic[] sumLogImpl) {
         setImpl(sumLogImpl, this.sumLogImpl);
     }
 
@@ -579,8 +572,7 @@ public class MultivariateSummaryStatisti
      * @throws IllegalStateException if data has already been added
      *  (i.e if n > 0)
      */
-    public void setGeoMeanImpl(StorelessUnivariateStatistic[] geoMeanImpl)
-      throws DimensionMismatchException {
+    public void setGeoMeanImpl(StorelessUnivariateStatistic[] geoMeanImpl) {
         setImpl(geoMeanImpl, this.geoMeanImpl);
     }
 
@@ -606,8 +598,7 @@ public class MultivariateSummaryStatisti
      * @throws IllegalStateException if data has already been added
      *  (i.e if n > 0)
      */
-    public void setMeanImpl(StorelessUnivariateStatistic[] meanImpl)
-      throws DimensionMismatchException {
+    public void setMeanImpl(StorelessUnivariateStatistic[] meanImpl) {
         setImpl(meanImpl, this.meanImpl);
     }
 
@@ -627,11 +618,9 @@ public class MultivariateSummaryStatisti
      * @param dimension dimension to check
      * @throws DimensionMismatchException if dimension != k
      */
-    private void checkDimension(int dimension)
-      throws DimensionMismatchException {
+    private void checkDimension(int dimension) {
         if (dimension != k) {
             throw new DimensionMismatchException(dimension, k);
         }
     }
-
 }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/SynchronizedMultivariateSummaryStatistics.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/SynchronizedMultivariateSummaryStatistics.java?rev=1061839&r1=1061838&r2=1061839&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/SynchronizedMultivariateSummaryStatistics.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/SynchronizedMultivariateSummaryStatistics.java Fri Jan 21 15:12:55 2011
@@ -16,7 +16,6 @@
  */
 package org.apache.commons.math.stat.descriptive;
 
-import org.apache.commons.math.DimensionMismatchException;
 import org.apache.commons.math.linear.RealMatrix;
 
 /**
@@ -32,7 +31,7 @@ import org.apache.commons.math.linear.Re
  * @version $Revision$ $Date$
  */
 public class SynchronizedMultivariateSummaryStatistics
-  extends MultivariateSummaryStatistics {
+    extends MultivariateSummaryStatistics {
 
     /** Serialization UID */
     private static final long serialVersionUID = 7099834153347155363L;
@@ -52,8 +51,7 @@ public class SynchronizedMultivariateSum
      * {@inheritDoc}
      */
     @Override
-    public synchronized void addValue(double[] value)
-      throws DimensionMismatchException {
+    public synchronized void addValue(double[] value) {
       super.addValue(value);
     }
 
@@ -189,8 +187,7 @@ public class SynchronizedMultivariateSum
      * {@inheritDoc}
      */
     @Override
-    public synchronized void setSumImpl(StorelessUnivariateStatistic[] sumImpl)
-      throws DimensionMismatchException {
+    public synchronized void setSumImpl(StorelessUnivariateStatistic[] sumImpl) {
         super.setSumImpl(sumImpl);
     }
 
@@ -206,8 +203,7 @@ public class SynchronizedMultivariateSum
      * {@inheritDoc}
      */
     @Override
-    public synchronized void setSumsqImpl(StorelessUnivariateStatistic[] sumsqImpl)
-      throws DimensionMismatchException {
+    public synchronized void setSumsqImpl(StorelessUnivariateStatistic[] sumsqImpl) {
         super.setSumsqImpl(sumsqImpl);
     }
 
@@ -223,8 +219,7 @@ public class SynchronizedMultivariateSum
      * {@inheritDoc}
      */
     @Override
-    public synchronized void setMinImpl(StorelessUnivariateStatistic[] minImpl)
-      throws DimensionMismatchException {
+    public synchronized void setMinImpl(StorelessUnivariateStatistic[] minImpl) {
         super.setMinImpl(minImpl);
     }
 
@@ -240,8 +235,7 @@ public class SynchronizedMultivariateSum
      * {@inheritDoc}
      */
     @Override
-    public synchronized void setMaxImpl(StorelessUnivariateStatistic[] maxImpl)
-      throws DimensionMismatchException {
+    public synchronized void setMaxImpl(StorelessUnivariateStatistic[] maxImpl) {
         super.setMaxImpl(maxImpl);
     }
 
@@ -257,8 +251,7 @@ public class SynchronizedMultivariateSum
      * {@inheritDoc}
      */
     @Override
-    public synchronized void setSumLogImpl(StorelessUnivariateStatistic[] sumLogImpl)
-      throws DimensionMismatchException {
+    public synchronized void setSumLogImpl(StorelessUnivariateStatistic[] sumLogImpl) {
         super.setSumLogImpl(sumLogImpl);
     }
 
@@ -274,8 +267,7 @@ public class SynchronizedMultivariateSum
      * {@inheritDoc}
      */
     @Override
-    public synchronized void setGeoMeanImpl(StorelessUnivariateStatistic[] geoMeanImpl)
-      throws DimensionMismatchException {
+    public synchronized void setGeoMeanImpl(StorelessUnivariateStatistic[] geoMeanImpl) {
         super.setGeoMeanImpl(geoMeanImpl);
     }
 
@@ -291,9 +283,7 @@ public class SynchronizedMultivariateSum
      * {@inheritDoc}
      */
     @Override
-    public synchronized void setMeanImpl(StorelessUnivariateStatistic[] meanImpl)
-      throws DimensionMismatchException {
+    public synchronized void setMeanImpl(StorelessUnivariateStatistic[] meanImpl) {
         super.setMeanImpl(meanImpl);
     }
-
 }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/VectorialCovariance.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/VectorialCovariance.java?rev=1061839&r1=1061838&r2=1061839&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/VectorialCovariance.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/VectorialCovariance.java Fri Jan 21 15:12:55 2011
@@ -19,7 +19,7 @@ package org.apache.commons.math.stat.des
 import java.io.Serializable;
 import java.util.Arrays;
 
-import org.apache.commons.math.DimensionMismatchException;
+import org.apache.commons.math.exception.DimensionMismatchException;
 import org.apache.commons.math.linear.MatrixUtils;
 import org.apache.commons.math.linear.RealMatrix;
 
@@ -60,7 +60,7 @@ public class VectorialCovariance impleme
     /**
      * Add a new vector to the sample.
      * @param v vector to add
-     * @exception DimensionMismatchException if the vector does not have the right dimension
+     * @throws DimensionMismatchException if the vector does not have the right dimension
      */
     public void increment(double[] v) throws DimensionMismatchException {
         if (v.length != sums.length) {

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/VectorialMean.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/VectorialMean.java?rev=1061839&r1=1061838&r2=1061839&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/VectorialMean.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/VectorialMean.java Fri Jan 21 15:12:55 2011
@@ -19,7 +19,7 @@ package org.apache.commons.math.stat.des
 import java.io.Serializable;
 import java.util.Arrays;
 
-import org.apache.commons.math.DimensionMismatchException;
+import org.apache.commons.math.exception.DimensionMismatchException;
 
 /**
  * Returns the arithmetic mean of the available vectors.
@@ -47,9 +47,9 @@ public class VectorialMean implements Se
     /**
      * Add a new vector to the sample.
      * @param v vector to add
-     * @exception DimensionMismatchException if the vector does not have the right dimension
+     * @throws DimensionMismatchException if the vector does not have the right dimension
      */
-    public void increment(double[] v) throws DimensionMismatchException {
+    public void increment(double[] v) {
         if (v.length != means.length) {
             throw new DimensionMismatchException(v.length, means.length);
         }

Modified: commons/proper/math/trunk/src/site/xdoc/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/site/xdoc/changes.xml?rev=1061839&r1=1061838&r2=1061839&view=diff
==============================================================================
--- commons/proper/math/trunk/src/site/xdoc/changes.xml (original)
+++ commons/proper/math/trunk/src/site/xdoc/changes.xml Fri Jan 21 15:12:55 2011
@@ -52,6 +52,10 @@ The <action> type attribute can be add,u
     If the output is not quite correct, check for invisible trailing spaces!
      -->
     <release version="3.0" date="TBD" description="TBD">
+      <action dev="erans" type="fix" issue="MATH-491">
+        Removed unchecked "DimensionMismatchException". Replaced all occurrences by its
+        equivalent from package "exception".
+      </action>
       <action dev="sebb" type="fix" issue="MATH-489">
           FastMath acos fails when input abs value is less than about 5.7851920321187236E-300 - returns NaN
       </action>

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/random/CorrelatedRandomVectorGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/random/CorrelatedRandomVectorGeneratorTest.java?rev=1061839&r1=1061838&r2=1061839&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/random/CorrelatedRandomVectorGeneratorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/random/CorrelatedRandomVectorGeneratorTest.java Fri Jan 21 15:12:55 2011
@@ -17,9 +17,7 @@
 
 package org.apache.commons.math.random;
 
-import junit.framework.TestCase;
-
-import org.apache.commons.math.DimensionMismatchException;
+import org.apache.commons.math.exception.DimensionMismatchException;
 import org.apache.commons.math.exception.NonPositiveDefiniteMatrixException;
 import org.apache.commons.math.linear.MatrixUtils;
 import org.apache.commons.math.linear.RealMatrix;
@@ -27,22 +25,51 @@ import org.apache.commons.math.stat.desc
 import org.apache.commons.math.stat.descriptive.moment.VectorialMean;
 import org.apache.commons.math.util.FastMath;
 
-public class CorrelatedRandomVectorGeneratorTest
-extends TestCase {
+import org.junit.Test;
+import org.junit.Assert;
+
+public class CorrelatedRandomVectorGeneratorTest {
+    private double[] mean;
+    private RealMatrix covariance;
+    private CorrelatedRandomVectorGenerator generator;
+
+    public CorrelatedRandomVectorGeneratorTest() {
+        mean = new double[] { 0.0, 1.0, -3.0, 2.3 };
+
+        RealMatrix b = MatrixUtils.createRealMatrix(4, 3);
+        int counter = 0;
+        for (int i = 0; i < b.getRowDimension(); ++i) {
+            for (int j = 0; j < b.getColumnDimension(); ++j) {
+                b.setEntry(i, j, 1.0 + 0.1 * ++counter);
+            }
+        }
+        RealMatrix bbt = b.multiply(b.transpose());
+        covariance = MatrixUtils.createRealMatrix(mean.length, mean.length);
+        for (int i = 0; i < covariance.getRowDimension(); ++i) {
+            covariance.setEntry(i, i, bbt.getEntry(i, i));
+            for (int j = 0; j < covariance.getColumnDimension(); ++j) {
+                double s = bbt.getEntry(i, j);
+                covariance.setEntry(i, j, s);
+                covariance.setEntry(j, i, s);
+            }
+        }
 
-    public CorrelatedRandomVectorGeneratorTest(String name) {
-        super(name);
-        mean       = null;
-        covariance = null;
-        generator  = null;
+        RandomGenerator rg = new JDKRandomGenerator();
+        rg.setSeed(17399225432l);
+        GaussianRandomGenerator rawGenerator = new GaussianRandomGenerator(rg);
+        generator = new CorrelatedRandomVectorGenerator(mean,
+                                                        covariance,
+                                                        1.0e-12 * covariance.getNorm(),
+                                                        rawGenerator);
     }
 
+    @Test
     public void testRank() {
-        assertEquals(3, generator.getRank());
+        Assert.assertEquals(3, generator.getRank());
     }
 
-    public void testMath226()
-        throws DimensionMismatchException {
+    @Test
+    public void testMath226() {
         double[] mean = { 1, 1, 10, 1 };
         double[][] cov = {
                 { 1, 3, 2, 6 },
@@ -59,22 +86,24 @@ extends TestCase {
 
         for (int i = 0; i < 10; i++) {
             double[] generated = sg.nextVector();
-            assertTrue(FastMath.abs(generated[0] - 1) > 0.1);
+            Assert.assertTrue(FastMath.abs(generated[0] - 1) > 0.1);
         }
 
     }
 
+    @Test
     public void testRootMatrix() {
         RealMatrix b = generator.getRootMatrix();
         RealMatrix bbt = b.multiply(b.transpose());
         for (int i = 0; i < covariance.getRowDimension(); ++i) {
             for (int j = 0; j < covariance.getColumnDimension(); ++j) {
-                assertEquals(covariance.getEntry(i, j), bbt.getEntry(i, j), 1.0e-12);
+                Assert.assertEquals(covariance.getEntry(i, j), bbt.getEntry(i, j), 1.0e-12);
             }
         }
     }
 
-    public void testMeanAndCovariance() throws DimensionMismatchException {
+    @Test
+    public void testMeanAndCovariance() {
 
         VectorialMean meanStat = new VectorialMean(mean.length);
         VectorialCovariance covStat = new VectorialCovariance(mean.length, true);
@@ -87,62 +116,13 @@ extends TestCase {
         double[] estimatedMean = meanStat.getResult();
         RealMatrix estimatedCovariance = covStat.getResult();
         for (int i = 0; i < estimatedMean.length; ++i) {
-            assertEquals(mean[i], estimatedMean[i], 0.07);
+            Assert.assertEquals(mean[i], estimatedMean[i], 0.07);
             for (int j = 0; j <= i; ++j) {
-                assertEquals(covariance.getEntry(i, j),
-                        estimatedCovariance.getEntry(i, j),
-                        0.1 * (1.0 + FastMath.abs(mean[i])) * (1.0 + FastMath.abs(mean[j])));
+                Assert.assertEquals(covariance.getEntry(i, j),
+                                    estimatedCovariance.getEntry(i, j),
+                                    0.1 * (1.0 + FastMath.abs(mean[i])) * (1.0 + FastMath.abs(mean[j])));
             }
         }
 
     }
-
-    @Override
-    public void setUp() {
-        try {
-            mean = new double[] { 0.0, 1.0, -3.0, 2.3};
-
-            RealMatrix b = MatrixUtils.createRealMatrix(4, 3);
-            int counter = 0;
-            for (int i = 0; i < b.getRowDimension(); ++i) {
-                for (int j = 0; j < b.getColumnDimension(); ++j) {
-                    b.setEntry(i, j, 1.0 + 0.1 * ++counter);
-                }
-            }
-            RealMatrix bbt = b.multiply(b.transpose());
-            covariance = MatrixUtils.createRealMatrix(mean.length, mean.length);
-            for (int i = 0; i < covariance.getRowDimension(); ++i) {
-                covariance.setEntry(i, i, bbt.getEntry(i, i));
-                for (int j = 0; j < covariance.getColumnDimension(); ++j) {
-                    double s = bbt.getEntry(i, j);
-                    covariance.setEntry(i, j, s);
-                    covariance.setEntry(j, i, s);
-                }
-            }
-
-            RandomGenerator rg = new JDKRandomGenerator();
-            rg.setSeed(17399225432l);
-            GaussianRandomGenerator rawGenerator = new GaussianRandomGenerator(rg);
-            generator = new CorrelatedRandomVectorGenerator(mean,
-                                                            covariance,
-                                                            1.0e-12 * covariance.getNorm(),
-                                                            rawGenerator);
-        } catch (DimensionMismatchException e) {
-            fail(e.getMessage());
-        } catch (NonPositiveDefiniteMatrixException e) {
-            fail("not positive definite matrix");
-        }
-    }
-
-    @Override
-    public void tearDown() {
-        mean       = null;
-        covariance = null;
-        generator  = null;
-    }
-
-    private double[] mean;
-    private RealMatrix covariance;
-    private CorrelatedRandomVectorGenerator generator;
-
 }

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/random/UncorrelatedRandomVectorGeneratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/random/UncorrelatedRandomVectorGeneratorTest.java?rev=1061839&r1=1061838&r2=1061839&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/random/UncorrelatedRandomVectorGeneratorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/random/UncorrelatedRandomVectorGeneratorTest.java Fri Jan 21 15:12:55 2011
@@ -17,24 +17,31 @@
 
 package org.apache.commons.math.random;
 
-import org.apache.commons.math.DimensionMismatchException;
+import org.apache.commons.math.exception.DimensionMismatchException;
 import org.apache.commons.math.linear.RealMatrix;
 import org.apache.commons.math.stat.descriptive.moment.VectorialCovariance;
 import org.apache.commons.math.stat.descriptive.moment.VectorialMean;
 
-import junit.framework.*;
+import org.junit.Test;
+import org.junit.Assert;
 
-public class UncorrelatedRandomVectorGeneratorTest
-extends TestCase {
+public class UncorrelatedRandomVectorGeneratorTest {
+    private double[] mean;
+    private double[] standardDeviation;
+    private UncorrelatedRandomVectorGenerator generator;
 
-    public UncorrelatedRandomVectorGeneratorTest(String name) {
-        super(name);
-        mean = null;
-        standardDeviation = null;
-        generator = null;
+    public UncorrelatedRandomVectorGeneratorTest() {
+        mean              = new double[] {0.0, 1.0, -3.0, 2.3};
+        standardDeviation = new double[] {1.0, 2.0, 10.0, 0.1};
+        RandomGenerator rg = new JDKRandomGenerator();
+        rg.setSeed(17399225432l);
+        generator =
+            new UncorrelatedRandomVectorGenerator(mean, standardDeviation,
+                    new GaussianRandomGenerator(rg));
     }
 
-    public void testMeanAndCorrelation() throws DimensionMismatchException {
+    @Test
+    public void testMeanAndCorrelation() {
 
         VectorialMean meanStat = new VectorialMean(mean.length);
         VectorialCovariance covStat = new VectorialCovariance(mean.length, true);
@@ -48,37 +55,13 @@ extends TestCase {
         double scale;
         RealMatrix estimatedCorrelation = covStat.getResult();
         for (int i = 0; i < estimatedMean.length; ++i) {
-            assertEquals(mean[i], estimatedMean[i], 0.07);
+            Assert.assertEquals(mean[i], estimatedMean[i], 0.07);
             for (int j = 0; j < i; ++j) {
                 scale = standardDeviation[i] * standardDeviation[j];
-                assertEquals(0, estimatedCorrelation.getEntry(i, j) / scale, 0.03);
+                Assert.assertEquals(0, estimatedCorrelation.getEntry(i, j) / scale, 0.03);
             }
             scale = standardDeviation[i] * standardDeviation[i];
-            assertEquals(1, estimatedCorrelation.getEntry(i, i) / scale, 0.025);
+            Assert.assertEquals(1, estimatedCorrelation.getEntry(i, i) / scale, 0.025);
         }
-
     }
-
-    @Override
-    public void setUp() {
-        mean              = new double[] {0.0, 1.0, -3.0, 2.3};
-        standardDeviation = new double[] {1.0, 2.0, 10.0, 0.1};
-        RandomGenerator rg = new JDKRandomGenerator();
-        rg.setSeed(17399225432l);
-        generator =
-            new UncorrelatedRandomVectorGenerator(mean, standardDeviation,
-                    new GaussianRandomGenerator(rg));
-    }
-
-    @Override
-    public void tearDown() {
-        mean = null;
-        standardDeviation = null;
-        generator = null;
-    }
-
-    private double[] mean;
-    private double[] standardDeviation;
-    private UncorrelatedRandomVectorGenerator generator;
-
 }

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/MultivariateSummaryStatisticsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/MultivariateSummaryStatisticsTest.java?rev=1061839&r1=1061838&r2=1061839&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/MultivariateSummaryStatisticsTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/MultivariateSummaryStatisticsTest.java Fri Jan 21 15:12:55 2011
@@ -19,29 +19,27 @@ package org.apache.commons.math.stat.des
 
 import java.util.Locale;
 
-import junit.framework.TestCase;
-
-import org.apache.commons.math.DimensionMismatchException;
+import org.apache.commons.math.exception.DimensionMismatchException;
 import org.apache.commons.math.TestUtils;
 import org.apache.commons.math.stat.descriptive.moment.Mean;
 import org.apache.commons.math.util.FastMath;
 
+import org.junit.Test;
+import org.junit.Assert;
+
 /**
  * Test cases for the {@link MultivariateSummaryStatistics} class.
  *
  * @version $Revision$ $Date$
  */
 
-public class MultivariateSummaryStatisticsTest extends TestCase {
-
-    public MultivariateSummaryStatisticsTest(String name) {
-        super(name);
-    }
+public class MultivariateSummaryStatisticsTest {
 
     protected MultivariateSummaryStatistics createMultivariateSummaryStatistics(int k, boolean isCovarianceBiasCorrected) {
         return new MultivariateSummaryStatistics(k, isCovarianceBiasCorrected);
     }
 
+    @Test
     public void testSetterInjection() throws Exception {
         MultivariateSummaryStatistics u = createMultivariateSummaryStatistics(2, true);
         u.setMeanImpl(new StorelessUnivariateStatistic[] {
@@ -49,24 +47,25 @@ public class MultivariateSummaryStatisti
                       });
         u.addValue(new double[] { 1, 2 });
         u.addValue(new double[] { 3, 4 });
-        assertEquals(4, u.getMean()[0], 1E-14);
-        assertEquals(6, u.getMean()[1], 1E-14);
+        Assert.assertEquals(4, u.getMean()[0], 1E-14);
+        Assert.assertEquals(6, u.getMean()[1], 1E-14);
         u.clear();
         u.addValue(new double[] { 1, 2 });
         u.addValue(new double[] { 3, 4 });
-        assertEquals(4, u.getMean()[0], 1E-14);
-        assertEquals(6, u.getMean()[1], 1E-14);
+        Assert.assertEquals(4, u.getMean()[0], 1E-14);
+        Assert.assertEquals(6, u.getMean()[1], 1E-14);
         u.clear();
         u.setMeanImpl(new StorelessUnivariateStatistic[] {
                         new Mean(), new Mean()
                       }); // OK after clear
         u.addValue(new double[] { 1, 2 });
         u.addValue(new double[] { 3, 4 });
-        assertEquals(2, u.getMean()[0], 1E-14);
-        assertEquals(3, u.getMean()[1], 1E-14);
-        assertEquals(2, u.getDimension());
+        Assert.assertEquals(2, u.getMean()[0], 1E-14);
+        Assert.assertEquals(3, u.getMean()[1], 1E-14);
+        Assert.assertEquals(2, u.getDimension());
     }
 
+    @Test
     public void testSetterIllegalState() throws Exception {
         MultivariateSummaryStatistics u = createMultivariateSummaryStatistics(2, true);
         u.addValue(new double[] { 1, 2 });
@@ -75,13 +74,14 @@ public class MultivariateSummaryStatisti
             u.setMeanImpl(new StorelessUnivariateStatistic[] {
                             new sumMean(), new sumMean()
                           });
-            fail("Expecting IllegalStateException");
+            Assert.fail("Expecting IllegalStateException");
         } catch (IllegalStateException ex) {
             // expected
         }
     }
 
-    public void testToString() throws DimensionMismatchException {
+    @Test
+    public void testToString() {
         MultivariateSummaryStatistics stats = createMultivariateSummaryStatistics(2, true);
         stats.addValue(new double[] {1, 3});
         stats.addValue(new double[] {2, 2});
@@ -89,7 +89,7 @@ public class MultivariateSummaryStatisti
         Locale d = Locale.getDefault();
         Locale.setDefault(Locale.US);
         final String suffix = System.getProperty("line.separator");
-        assertEquals("MultivariateSummaryStatistics:" + suffix+
+        Assert.assertEquals("MultivariateSummaryStatistics:" + suffix+
                      "n: 3" +suffix+
                      "min: 1.0, 1.0" +suffix+
                      "max: 3.0, 3.0" +suffix+
@@ -103,7 +103,8 @@ public class MultivariateSummaryStatisti
         Locale.setDefault(d);
     }
 
-    public void testShuffledStatistics() throws DimensionMismatchException {
+    @Test
+    public void testShuffledStatistics() {
         // the purpose of this test is only to check the get/set methods
         // we are aware shuffling statistics like this is really not
         // something sensible to do in production ...
@@ -170,86 +171,91 @@ public class MultivariateSummaryStatisti
         }
     }
 
+    @Test
     public void testDimension() {
         try {
             createMultivariateSummaryStatistics(2, true).addValue(new double[3]);
-            fail("Expecting DimensionMismatchException");
+            Assert.fail("Expecting DimensionMismatchException");
         } catch (DimensionMismatchException dme) {
             // expected behavior
         }
     }
 
     /** test stats */
-    public void testStats() throws DimensionMismatchException {
+    @Test
+    public void testStats() {
         MultivariateSummaryStatistics u = createMultivariateSummaryStatistics(2, true);
-        assertEquals(0, u.getN());
+        Assert.assertEquals(0, u.getN());
         u.addValue(new double[] { 1, 2 });
         u.addValue(new double[] { 2, 3 });
         u.addValue(new double[] { 2, 3 });
         u.addValue(new double[] { 3, 4 });
-        assertEquals( 4, u.getN());
-        assertEquals( 8, u.getSum()[0], 1.0e-10);
-        assertEquals(12, u.getSum()[1], 1.0e-10);
-        assertEquals(18, u.getSumSq()[0], 1.0e-10);
-        assertEquals(38, u.getSumSq()[1], 1.0e-10);
-        assertEquals( 1, u.getMin()[0], 1.0e-10);
-        assertEquals( 2, u.getMin()[1], 1.0e-10);
-        assertEquals( 3, u.getMax()[0], 1.0e-10);
-        assertEquals( 4, u.getMax()[1], 1.0e-10);
-        assertEquals(2.4849066497880003102, u.getSumLog()[0], 1.0e-10);
-        assertEquals( 4.276666119016055311, u.getSumLog()[1], 1.0e-10);
-        assertEquals( 1.8612097182041991979, u.getGeometricMean()[0], 1.0e-10);
-        assertEquals( 2.9129506302439405217, u.getGeometricMean()[1], 1.0e-10);
-        assertEquals( 2, u.getMean()[0], 1.0e-10);
-        assertEquals( 3, u.getMean()[1], 1.0e-10);
-        assertEquals(FastMath.sqrt(2.0 / 3.0), u.getStandardDeviation()[0], 1.0e-10);
-        assertEquals(FastMath.sqrt(2.0 / 3.0), u.getStandardDeviation()[1], 1.0e-10);
-        assertEquals(2.0 / 3.0, u.getCovariance().getEntry(0, 0), 1.0e-10);
-        assertEquals(2.0 / 3.0, u.getCovariance().getEntry(0, 1), 1.0e-10);
-        assertEquals(2.0 / 3.0, u.getCovariance().getEntry(1, 0), 1.0e-10);
-        assertEquals(2.0 / 3.0, u.getCovariance().getEntry(1, 1), 1.0e-10);
+        Assert.assertEquals( 4, u.getN());
+        Assert.assertEquals( 8, u.getSum()[0], 1.0e-10);
+        Assert.assertEquals(12, u.getSum()[1], 1.0e-10);
+        Assert.assertEquals(18, u.getSumSq()[0], 1.0e-10);
+        Assert.assertEquals(38, u.getSumSq()[1], 1.0e-10);
+        Assert.assertEquals( 1, u.getMin()[0], 1.0e-10);
+        Assert.assertEquals( 2, u.getMin()[1], 1.0e-10);
+        Assert.assertEquals( 3, u.getMax()[0], 1.0e-10);
+        Assert.assertEquals( 4, u.getMax()[1], 1.0e-10);
+        Assert.assertEquals(2.4849066497880003102, u.getSumLog()[0], 1.0e-10);
+        Assert.assertEquals( 4.276666119016055311, u.getSumLog()[1], 1.0e-10);
+        Assert.assertEquals( 1.8612097182041991979, u.getGeometricMean()[0], 1.0e-10);
+        Assert.assertEquals( 2.9129506302439405217, u.getGeometricMean()[1], 1.0e-10);
+        Assert.assertEquals( 2, u.getMean()[0], 1.0e-10);
+        Assert.assertEquals( 3, u.getMean()[1], 1.0e-10);
+        Assert.assertEquals(FastMath.sqrt(2.0 / 3.0), u.getStandardDeviation()[0], 1.0e-10);
+        Assert.assertEquals(FastMath.sqrt(2.0 / 3.0), u.getStandardDeviation()[1], 1.0e-10);
+        Assert.assertEquals(2.0 / 3.0, u.getCovariance().getEntry(0, 0), 1.0e-10);
+        Assert.assertEquals(2.0 / 3.0, u.getCovariance().getEntry(0, 1), 1.0e-10);
+        Assert.assertEquals(2.0 / 3.0, u.getCovariance().getEntry(1, 0), 1.0e-10);
+        Assert.assertEquals(2.0 / 3.0, u.getCovariance().getEntry(1, 1), 1.0e-10);
         u.clear();
-        assertEquals(0, u.getN());
+        Assert.assertEquals(0, u.getN());
     }
 
+    @Test
     public void testN0andN1Conditions() throws Exception {
         MultivariateSummaryStatistics u = createMultivariateSummaryStatistics(1, true);
-        assertTrue(Double.isNaN(u.getMean()[0]));
-        assertTrue(Double.isNaN(u.getStandardDeviation()[0]));
+        Assert.assertTrue(Double.isNaN(u.getMean()[0]));
+        Assert.assertTrue(Double.isNaN(u.getStandardDeviation()[0]));
 
         /* n=1 */
         u.addValue(new double[] { 1 });
-        assertEquals(1.0, u.getMean()[0], 1.0e-10);
-        assertEquals(1.0, u.getGeometricMean()[0], 1.0e-10);
-        assertEquals(0.0, u.getStandardDeviation()[0], 1.0e-10);
+        Assert.assertEquals(1.0, u.getMean()[0], 1.0e-10);
+        Assert.assertEquals(1.0, u.getGeometricMean()[0], 1.0e-10);
+        Assert.assertEquals(0.0, u.getStandardDeviation()[0], 1.0e-10);
 
         /* n=2 */
         u.addValue(new double[] { 2 });
-        assertTrue(u.getStandardDeviation()[0] > 0);
+        Assert.assertTrue(u.getStandardDeviation()[0] > 0);
 
     }
 
-    public void testNaNContracts() throws DimensionMismatchException {
+    @Test
+    public void testNaNContracts() {
         MultivariateSummaryStatistics u = createMultivariateSummaryStatistics(1, true);
-        assertTrue(Double.isNaN(u.getMean()[0]));
-        assertTrue(Double.isNaN(u.getMin()[0]));
-        assertTrue(Double.isNaN(u.getStandardDeviation()[0]));
-        assertTrue(Double.isNaN(u.getGeometricMean()[0]));
+        Assert.assertTrue(Double.isNaN(u.getMean()[0]));
+        Assert.assertTrue(Double.isNaN(u.getMin()[0]));
+        Assert.assertTrue(Double.isNaN(u.getStandardDeviation()[0]));
+        Assert.assertTrue(Double.isNaN(u.getGeometricMean()[0]));
 
         u.addValue(new double[] { 1.0 });
-        assertFalse(Double.isNaN(u.getMean()[0]));
-        assertFalse(Double.isNaN(u.getMin()[0]));
-        assertFalse(Double.isNaN(u.getStandardDeviation()[0]));
-        assertFalse(Double.isNaN(u.getGeometricMean()[0]));
+        Assert.assertFalse(Double.isNaN(u.getMean()[0]));
+        Assert.assertFalse(Double.isNaN(u.getMin()[0]));
+        Assert.assertFalse(Double.isNaN(u.getStandardDeviation()[0]));
+        Assert.assertFalse(Double.isNaN(u.getGeometricMean()[0]));
 
     }
 
-    public void testSerialization() throws DimensionMismatchException {
+    @Test
+    public void testSerialization() {
         MultivariateSummaryStatistics u = createMultivariateSummaryStatistics(2, true);
         // Empty test
         TestUtils.checkSerializedEquality(u);
         MultivariateSummaryStatistics s = (MultivariateSummaryStatistics) TestUtils.serializeAndRecover(u);
-        assertEquals(u, s);
+        Assert.assertEquals(u, s);
 
         // Add some data
         u.addValue(new double[] { 2d, 1d });
@@ -261,21 +267,22 @@ public class MultivariateSummaryStatisti
         // Test again
         TestUtils.checkSerializedEquality(u);
         s = (MultivariateSummaryStatistics) TestUtils.serializeAndRecover(u);
-        assertEquals(u, s);
+        Assert.assertEquals(u, s);
 
     }
 
-    public void testEqualsAndHashCode() throws DimensionMismatchException {
+    @Test
+    public void testEqualsAndHashCode() {
         MultivariateSummaryStatistics u = createMultivariateSummaryStatistics(2, true);
         MultivariateSummaryStatistics t = null;
         int emptyHash = u.hashCode();
-        assertTrue(u.equals(u));
-        assertFalse(u.equals(t));
-        assertFalse(u.equals(Double.valueOf(0)));
+        Assert.assertTrue(u.equals(u));
+        Assert.assertFalse(u.equals(t));
+        Assert.assertFalse(u.equals(Double.valueOf(0)));
         t = createMultivariateSummaryStatistics(2, true);
-        assertTrue(t.equals(u));
-        assertTrue(u.equals(t));
-        assertEquals(emptyHash, t.hashCode());
+        Assert.assertTrue(t.equals(u));
+        Assert.assertTrue(u.equals(t));
+        Assert.assertEquals(emptyHash, t.hashCode());
 
         // Add some data to u
         u.addValue(new double[] { 2d, 1d });
@@ -283,9 +290,9 @@ public class MultivariateSummaryStatisti
         u.addValue(new double[] { 3d, 1d });
         u.addValue(new double[] { 4d, 1d });
         u.addValue(new double[] { 5d, 1d });
-        assertFalse(t.equals(u));
-        assertFalse(u.equals(t));
-        assertTrue(u.hashCode() != t.hashCode());
+        Assert.assertFalse(t.equals(u));
+        Assert.assertFalse(u.equals(t));
+        Assert.assertTrue(u.hashCode() != t.hashCode());
 
         //Add data in same order to t
         t.addValue(new double[] { 2d, 1d });
@@ -293,17 +300,16 @@ public class MultivariateSummaryStatisti
         t.addValue(new double[] { 3d, 1d });
         t.addValue(new double[] { 4d, 1d });
         t.addValue(new double[] { 5d, 1d });
-        assertTrue(t.equals(u));
-        assertTrue(u.equals(t));
-        assertEquals(u.hashCode(), t.hashCode());
+        Assert.assertTrue(t.equals(u));
+        Assert.assertTrue(u.equals(t));
+        Assert.assertEquals(u.hashCode(), t.hashCode());
 
         // Clear and make sure summaries are indistinguishable from empty summary
         u.clear();
         t.clear();
-        assertTrue(t.equals(u));
-        assertTrue(u.equals(t));
-        assertEquals(emptyHash, t.hashCode());
-        assertEquals(emptyHash, u.hashCode());
+        Assert.assertTrue(t.equals(u));
+        Assert.assertTrue(u.equals(t));
+        Assert.assertEquals(emptyHash, t.hashCode());
+        Assert.assertEquals(emptyHash, u.hashCode());
     }
-
 }

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/SynchronizedMultivariateSummaryStatisticsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/SynchronizedMultivariateSummaryStatisticsTest.java?rev=1061839&r1=1061838&r2=1061839&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/SynchronizedMultivariateSummaryStatisticsTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/SynchronizedMultivariateSummaryStatisticsTest.java Fri Jan 21 15:12:55 2011
@@ -19,15 +19,10 @@ package org.apache.commons.math.stat.des
  * @version $Revision$ $Date: 2007-08-16 15:36:33 -0500 (Thu, 16 Aug
  *          2007) $
  */
-public final class SynchronizedMultivariateSummaryStatisticsTest extends MultivariateSummaryStatisticsTest {
-
-    public SynchronizedMultivariateSummaryStatisticsTest(String name) {
-        super(name);
-    }
-
+public final class SynchronizedMultivariateSummaryStatisticsTest
+    extends MultivariateSummaryStatisticsTest {
     @Override
     protected MultivariateSummaryStatistics createMultivariateSummaryStatistics(int k, boolean isCovarianceBiasCorrected) {
         return new SynchronizedMultivariateSummaryStatistics(k, isCovarianceBiasCorrected);
     }
-
 }

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/moment/VectorialCovarianceTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/moment/VectorialCovarianceTest.java?rev=1061839&r1=1061838&r2=1061839&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/moment/VectorialCovarianceTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/moment/VectorialCovarianceTest.java Fri Jan 21 15:12:55 2011
@@ -17,48 +17,57 @@
 
 package org.apache.commons.math.stat.descriptive.moment;
 
-import junit.framework.TestCase;
-
-import org.apache.commons.math.DimensionMismatchException;
+import org.apache.commons.math.exception.DimensionMismatchException;
 import org.apache.commons.math.TestUtils;
 import org.apache.commons.math.linear.RealMatrix;
 
-public class VectorialCovarianceTest
-extends TestCase {
+import org.junit.Test;
+import org.junit.Assert;
+
+public class VectorialCovarianceTest {
+    private double[][] points;
 
-    public VectorialCovarianceTest(String name) {
-        super(name);
-        points = null;
+    public VectorialCovarianceTest() {
+        points = new double[][] {
+            { 1.2, 2.3,  4.5},
+            {-0.7, 2.3,  5.0},
+            { 3.1, 0.0, -3.1},
+            { 6.0, 1.2,  4.2},
+            {-0.7, 2.3,  5.0}
+        };
     }
 
+    @Test
     public void testMismatch() {
         try {
             new VectorialCovariance(8, true).increment(new double[5]);
-            fail("an exception should have been thrown");
+            Assert.fail("an exception should have been thrown");
         } catch (DimensionMismatchException dme) {
-            assertEquals(5, dme.getDimension1());
-            assertEquals(8, dme.getDimension2());
+            Assert.assertEquals(5, dme.getArgument());
+            Assert.assertEquals(8, dme.getDimension());
         }
     }
 
-    public void testSimplistic() throws DimensionMismatchException {
+    @Test
+    public void testSimplistic() {
         VectorialCovariance stat = new VectorialCovariance(2, true);
         stat.increment(new double[] {-1.0,  1.0});
         stat.increment(new double[] { 1.0, -1.0});
         RealMatrix c = stat.getResult();
-        assertEquals( 2.0, c.getEntry(0, 0), 1.0e-12);
-        assertEquals(-2.0, c.getEntry(1, 0), 1.0e-12);
-        assertEquals( 2.0, c.getEntry(1, 1), 1.0e-12);
+        Assert.assertEquals( 2.0, c.getEntry(0, 0), 1.0e-12);
+        Assert.assertEquals(-2.0, c.getEntry(1, 0), 1.0e-12);
+        Assert.assertEquals( 2.0, c.getEntry(1, 1), 1.0e-12);
     }
 
-    public void testBasicStats() throws DimensionMismatchException {
+    @Test
+    public void testBasicStats() {
 
         VectorialCovariance stat = new VectorialCovariance(points[0].length, true);
         for (int i = 0; i < points.length; ++i) {
             stat.increment(points[i]);
         }
 
-        assertEquals(points.length, stat.getN());
+        Assert.assertEquals(points.length, stat.getN());
 
         RealMatrix c = stat.getResult();
         double[][] refC    = new double[][] {
@@ -69,33 +78,15 @@ extends TestCase {
 
         for (int i = 0; i < c.getRowDimension(); ++i) {
             for (int j = 0; j <= i; ++j) {
-                assertEquals(refC[i][j], c.getEntry(i, j), 1.0e-12);
+                Assert.assertEquals(refC[i][j], c.getEntry(i, j), 1.0e-12);
             }
         }
 
     }
 
+    @Test
     public void testSerial(){
         VectorialCovariance stat = new VectorialCovariance(points[0].length, true);
-        assertEquals(stat, TestUtils.serializeAndRecover(stat));
-    }
-
-    @Override
-    public void setUp() {
-        points = new double[][] {
-                { 1.2, 2.3,  4.5},
-                {-0.7, 2.3,  5.0},
-                { 3.1, 0.0, -3.1},
-                { 6.0, 1.2,  4.2},
-                {-0.7, 2.3,  5.0}
-        };
-    }
-
-    @Override
-    public void tearDown() {
-        points = null;
+        Assert.assertEquals(stat, TestUtils.serializeAndRecover(stat));
     }
-
-    private double [][] points;
-
 }

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/moment/VectorialMeanTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/moment/VectorialMeanTest.java?rev=1061839&r1=1061838&r2=1061839&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/moment/VectorialMeanTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/descriptive/moment/VectorialMeanTest.java Fri Jan 21 15:12:55 2011
@@ -17,79 +17,71 @@
 
 package org.apache.commons.math.stat.descriptive.moment;
 
-import junit.framework.TestCase;
-
-import org.apache.commons.math.DimensionMismatchException;
+import org.apache.commons.math.exception.DimensionMismatchException;
 import org.apache.commons.math.TestUtils;
 
-public class VectorialMeanTest
-extends TestCase {
+import org.junit.Test;
+import org.junit.Assert;
+
+public class VectorialMeanTest {
+    private double[][] points;
 
-    public VectorialMeanTest(String name) {
-        super(name);
-        points = null;
+    public VectorialMeanTest() {
+        points = new double[][] {
+            { 1.2, 2.3,  4.5},
+            {-0.7, 2.3,  5.0},
+            { 3.1, 0.0, -3.1},
+            { 6.0, 1.2,  4.2},
+            {-0.7, 2.3,  5.0}
+        };
     }
 
+    @Test
     public void testMismatch() {
         try {
             new VectorialMean(8).increment(new double[5]);
-            fail("an exception should have been thrown");
+            Assert.fail("an exception should have been thrown");
         } catch (DimensionMismatchException dme) {
-            assertEquals(5, dme.getDimension1());
-            assertEquals(8, dme.getDimension2());
+            Assert.assertEquals(5, dme.getArgument());
+            Assert.assertEquals(8, dme.getDimension());
         }
     }
 
-    public void testSimplistic() throws DimensionMismatchException {
+    @Test
+    public void testSimplistic() {
         VectorialMean stat = new VectorialMean(2);
         stat.increment(new double[] {-1.0,  1.0});
         stat.increment(new double[] { 1.0, -1.0});
         double[] mean = stat.getResult();
-        assertEquals(0.0, mean[0], 1.0e-12);
-        assertEquals(0.0, mean[1], 1.0e-12);
+        Assert.assertEquals(0.0, mean[0], 1.0e-12);
+        Assert.assertEquals(0.0, mean[1], 1.0e-12);
     }
 
-    public void testBasicStats() throws DimensionMismatchException {
+    @Test
+    public void testBasicStats() {
 
         VectorialMean stat = new VectorialMean(points[0].length);
         for (int i = 0; i < points.length; ++i) {
             stat.increment(points[i]);
         }
 
-        assertEquals(points.length, stat.getN());
+        Assert.assertEquals(points.length, stat.getN());
 
         double[] mean = stat.getResult();
         double[]   refMean = new double[] { 1.78, 1.62,  3.12};
 
         for (int i = 0; i < mean.length; ++i) {
-            assertEquals(refMean[i], mean[i], 1.0e-12);
+            Assert.assertEquals(refMean[i], mean[i], 1.0e-12);
         }
 
     }
 
-    public void testSerial() throws DimensionMismatchException {
+    @Test
+    public void testSerial() {
         VectorialMean stat = new VectorialMean(points[0].length);
         for (int i = 0; i < points.length; ++i) {
             stat.increment(points[i]);
         }
-        assertEquals(stat, TestUtils.serializeAndRecover(stat));
+        Assert.assertEquals(stat, TestUtils.serializeAndRecover(stat));
     }
-    @Override
-    public void setUp() {
-        points = new double[][] {
-                { 1.2, 2.3,  4.5},
-                {-0.7, 2.3,  5.0},
-                { 3.1, 0.0, -3.1},
-                { 6.0, 1.2,  4.2},
-                {-0.7, 2.3,  5.0}
-        };
-    }
-
-    @Override
-    public void tearDown() {
-        points = null;
-    }
-
-    private double [][] points;
-
 }



Mime
View raw message