You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by tn...@apache.org on 2015/04/26 22:12:01 UTC

[1/2] [math] [MATH-853] MathRuntimeException becomes the commons base class for all other exceptions.

Repository: commons-math
Updated Branches:
  refs/heads/master 2f461bdb0 -> afcfbf57b


http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/stat/regression/GLSMultipleLinearRegressionTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/regression/GLSMultipleLinearRegressionTest.java b/src/test/java/org/apache/commons/math4/stat/regression/GLSMultipleLinearRegressionTest.java
index a2f5f62..06fbc26 100644
--- a/src/test/java/org/apache/commons/math4/stat/regression/GLSMultipleLinearRegressionTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/regression/GLSMultipleLinearRegressionTest.java
@@ -20,6 +20,7 @@ import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.apache.commons.math4.TestUtils;
+import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.apache.commons.math4.exception.NullArgumentException;
 import org.apache.commons.math4.linear.MatrixUtils;
 import org.apache.commons.math4.linear.RealMatrix;
@@ -38,7 +39,7 @@ public class GLSMultipleLinearRegressionTest extends MultipleLinearRegressionAbs
     private double[] y;
     private double[][] x;
     private double[][] omega;
-    private double[] longley = new double[] {
+    private final double[] longley = new double[] {
             60323,83.0,234289,2356,1590,107608,1947,
             61122,88.5,259426,2325,1456,108632,1948,
             60171,88.2,258054,3682,1616,109773,1949,
@@ -88,7 +89,7 @@ public class GLSMultipleLinearRegressionTest extends MultipleLinearRegressionAbs
         createRegression().newSampleData(null, new double[][]{}, null);
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected=MathIllegalArgumentException.class)
     public void cannotAddSampleDataWithSizeMismatch() {
         double[] y = new double[]{1.0, 2.0};
         double[][] x = new double[1][];
@@ -96,12 +97,12 @@ public class GLSMultipleLinearRegressionTest extends MultipleLinearRegressionAbs
         createRegression().newSampleData(y, x, null);
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected=MathIllegalArgumentException.class)
     public void cannotAddNullCovarianceData() {
         createRegression().newSampleData(new double[]{}, new double[][]{}, null);
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected=MathIllegalArgumentException.class)
     public void notEnoughData() {
         double[]   reducedY = new double[y.length - 1];
         double[][] reducedX = new double[x.length - 1][];
@@ -112,7 +113,7 @@ public class GLSMultipleLinearRegressionTest extends MultipleLinearRegressionAbs
         createRegression().newSampleData(reducedY, reducedX, reducedO);
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected=MathIllegalArgumentException.class)
     public void cannotAddCovarianceDataWithSampleSizeMismatch() {
         double[] y = new double[]{1.0, 2.0};
         double[][] x = new double[2][];
@@ -123,7 +124,7 @@ public class GLSMultipleLinearRegressionTest extends MultipleLinearRegressionAbs
         createRegression().newSampleData(y, x, omega);
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected=MathIllegalArgumentException.class)
     public void cannotAddCovarianceDataThatIsNotSquare() {
         double[] y = new double[]{1.0, 2.0};
         double[][] x = new double[2][];
@@ -165,18 +166,18 @@ public class GLSMultipleLinearRegressionTest extends MultipleLinearRegressionAbs
         model.newSampleData(y, x, omega);
         TestUtils.assertEquals(model.calculateYVariance(), 3.5, 0);
     }
-    
+
     /**
      * Verifies that setting X, Y and covariance separately has the same effect as newSample(X,Y,cov).
      */
     @Test
     public void testNewSample2() {
-        double[] y = new double[] {1, 2, 3, 4}; 
+        double[] y = new double[] {1, 2, 3, 4};
         double[][] x = new double[][] {
           {19, 22, 33},
           {20, 30, 40},
           {25, 35, 45},
-          {27, 37, 47}   
+          {27, 37, 47}
         };
         double[][] covariance = MatrixUtils.createRealIdentityMatrix(4).scalarMultiply(2).getData();
         GLSMultipleLinearRegression regression = new GLSMultipleLinearRegression();
@@ -190,13 +191,13 @@ public class GLSMultipleLinearRegressionTest extends MultipleLinearRegressionAbs
         Assert.assertEquals(combinedY, regression.getY());
         Assert.assertEquals(combinedCovInv, regression.getOmegaInverse());
     }
-    
+
     /**
      * Verifies that GLS with identity covariance matrix gives the same results
      * as OLS.
      */
     @Test
-    public void testGLSOLSConsistency() {      
+    public void testGLSOLSConsistency() {
         RealMatrix identityCov = MatrixUtils.createRealIdentityMatrix(16);
         GLSMultipleLinearRegression glsModel = new GLSMultipleLinearRegression();
         OLSMultipleLinearRegression olsModel = new OLSMultipleLinearRegression();
@@ -211,7 +212,7 @@ public class GLSMultipleLinearRegressionTest extends MultipleLinearRegressionAbs
             TestUtils.assertRelativelyEquals(olsBeta[i], glsBeta[i], 10E-7);
         }
     }
-    
+
     /**
      * Generate an error covariance matrix and sample data representing models
      * with this error structure. Then verify that GLS estimated coefficients,
@@ -221,7 +222,7 @@ public class GLSMultipleLinearRegressionTest extends MultipleLinearRegressionAbs
     public void testGLSEfficiency() {
         RandomGenerator rg = new JDKRandomGenerator();
         rg.setSeed(200);  // Seed has been selected to generate non-trivial covariance
-        
+
         // Assume model has 16 observations (will use Longley data).  Start by generating
         // non-constant variances for the 16 error terms.
         final int nObs = 16;
@@ -229,7 +230,7 @@ public class GLSMultipleLinearRegressionTest extends MultipleLinearRegressionAbs
         for (int i = 0; i < nObs; i++) {
             sigma[i] = 10 * rg.nextDouble();
         }
-        
+
         // Now generate 1000 error vectors to use to estimate the covariance matrix
         // Columns are draws on N(0, sigma[col])
         final int numSeeds = 1000;
@@ -239,16 +240,16 @@ public class GLSMultipleLinearRegressionTest extends MultipleLinearRegressionAbs
                 errorSeeds.setEntry(i, j, rg.nextGaussian() * sigma[j]);
             }
         }
-        
+
         // Get covariance matrix for columns
         RealMatrix cov = (new Covariance(errorSeeds)).getCovarianceMatrix();
-          
+
         // Create a CorrelatedRandomVectorGenerator to use to generate correlated errors
         GaussianRandomGenerator rawGenerator = new GaussianRandomGenerator(rg);
         double[] errorMeans = new double[nObs];  // Counting on init to 0 here
         CorrelatedRandomVectorGenerator gen = new CorrelatedRandomVectorGenerator(errorMeans, cov,
          1.0e-12 * cov.getNorm(), rawGenerator);
-        
+
         // Now start generating models.  Use Longley X matrix on LHS
         // and Longley OLS beta vector as "true" beta.  Generate
         // Y values by XB + u where u is a CorrelatedRandomVector generated
@@ -257,44 +258,44 @@ public class GLSMultipleLinearRegressionTest extends MultipleLinearRegressionAbs
         ols.newSampleData(longley, nObs, 6);
         final RealVector b = ols.calculateBeta().copy();
         final RealMatrix x = ols.getX().copy();
-        
+
         // Create a GLS model to reuse
         GLSMultipleLinearRegression gls = new GLSMultipleLinearRegression();
         gls.newSampleData(longley, nObs, 6);
         gls.newCovarianceData(cov.getData());
-        
+
         // Create aggregators for stats measuring model performance
         DescriptiveStatistics olsBetaStats = new DescriptiveStatistics();
         DescriptiveStatistics glsBetaStats = new DescriptiveStatistics();
-        
+
         // Generate Y vectors for 10000 models, estimate GLS and OLS and
         // Verify that OLS estimates are better
         final int nModels = 10000;
         for (int i = 0; i < nModels; i++) {
-            
+
             // Generate y = xb + u with u cov
             RealVector u = MatrixUtils.createRealVector(gen.nextVector());
             double[] y = u.add(x.operate(b)).toArray();
-            
+
             // Estimate OLS parameters
             ols.newYSampleData(y);
             RealVector olsBeta = ols.calculateBeta();
-            
+
             // Estimate GLS parameters
             gls.newYSampleData(y);
             RealVector glsBeta = gls.calculateBeta();
-            
+
             // Record deviations from "true" beta
             double dist = olsBeta.getDistance(b);
             olsBetaStats.addValue(dist * dist);
             dist = glsBeta.getDistance(b);
             glsBetaStats.addValue(dist * dist);
-            
+
         }
-        
+
         // Verify that GLS is on average more efficient, lower variance
         assert(olsBetaStats.getMean() > 1.5 * glsBetaStats.getMean());
-        assert(olsBetaStats.getStandardDeviation() > glsBetaStats.getStandardDeviation());  
+        assert(olsBetaStats.getStandardDeviation() > glsBetaStats.getStandardDeviation());
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/stat/regression/MillerUpdatingRegressionTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/regression/MillerUpdatingRegressionTest.java b/src/test/java/org/apache/commons/math4/stat/regression/MillerUpdatingRegressionTest.java
index 0034d75..30c5bff 100644
--- a/src/test/java/org/apache/commons/math4/stat/regression/MillerUpdatingRegressionTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/regression/MillerUpdatingRegressionTest.java
@@ -17,6 +17,7 @@
 package org.apache.commons.math4.stat.regression;
 
 import org.apache.commons.math4.TestUtils;
+import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.apache.commons.math4.linear.RealMatrix;
 import org.apache.commons.math4.stat.correlation.PearsonsCorrelation;
 import org.apache.commons.math4.stat.regression.MillerUpdatingRegression;
@@ -33,9 +34,9 @@ public class MillerUpdatingRegressionTest {
 
     public MillerUpdatingRegressionTest() {
     }
-    /* This is the Greene Airline Cost data. 
+    /* This is the Greene Airline Cost data.
      * The data can be downloaded from http://www.indiana.edu/~statmath/stat/all/panel/airline.csv
-     */ 
+     */
     private final static double[][] airdata = {
         /*"I",*/new double[]{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6},
         /*"T",*/ new double[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
@@ -94,44 +95,44 @@ public class MillerUpdatingRegressionTest {
         MillerUpdatingRegression instance = new MillerUpdatingRegression(3, true);
         try {
             instance.addObservation(new double[]{1.0}, 0.0);
-            Assert.fail("Should throw IllegalArgumentException");
-        } catch (IllegalArgumentException iae) {
+            Assert.fail("Should throw MathIllegalArgumentException");
+        } catch (MathIllegalArgumentException iae) {
         } catch (Exception e) {
-            Assert.fail("Should throw IllegalArgumentException");
+            Assert.fail("Should throw MathIllegalArgumentException");
         }
         try {
             instance.addObservation(new double[]{1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}, 0.0);
-            Assert.fail("Should throw IllegalArgumentException");
-        } catch (IllegalArgumentException iae) {
+            Assert.fail("Should throw MathIllegalArgumentException");
+        } catch (MathIllegalArgumentException iae) {
         } catch (Exception e) {
-            Assert.fail("Should throw IllegalArgumentException");
+            Assert.fail("Should throw MathIllegalArgumentException");
         }
         try {
             instance.addObservation(new double[]{1.0, 1.0, 1.0}, 0.0);
         } catch (Exception e) {
-            Assert.fail("Should throw IllegalArgumentException");
+            Assert.fail("Should throw MathIllegalArgumentException");
         }
 
         //now we try it without an intercept
         instance = new MillerUpdatingRegression(3, false);
         try {
             instance.addObservation(new double[]{1.0}, 0.0);
-            Assert.fail("Should throw IllegalArgumentException [NOINTERCEPT]");
-        } catch (IllegalArgumentException iae) {
+            Assert.fail("Should throw MathIllegalArgumentException [NOINTERCEPT]");
+        } catch (MathIllegalArgumentException iae) {
         } catch (Exception e) {
-            Assert.fail("Should throw IllegalArgumentException [NOINTERCEPT]");
+            Assert.fail("Should throw MathIllegalArgumentException [NOINTERCEPT]");
         }
         try {
             instance.addObservation(new double[]{1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}, 0.0);
-            Assert.fail("Should throw IllegalArgumentException [NOINTERCEPT]");
-        } catch (IllegalArgumentException iae) {
+            Assert.fail("Should throw MathIllegalArgumentException [NOINTERCEPT]");
+        } catch (MathIllegalArgumentException iae) {
         } catch (Exception e) {
-            Assert.fail("Should throw IllegalArgumentException [NOINTERCEPT]");
+            Assert.fail("Should throw MathIllegalArgumentException [NOINTERCEPT]");
         }
         try {
             instance.addObservation(new double[]{1.0, 1.0, 1.0}, 0.0);
         } catch (Exception e) {
-            Assert.fail("Should throw IllegalArgumentException [NOINTERCEPT]");
+            Assert.fail("Should throw MathIllegalArgumentException [NOINTERCEPT]");
         }
     }
 
@@ -143,10 +144,10 @@ public class MillerUpdatingRegressionTest {
             double[] y = {1.0};
             instance.addObservations(tst, y);
 
-            Assert.fail("Should throw IllegalArgumentException");
-        } catch (IllegalArgumentException iae) {
+            Assert.fail("Should throw MathIllegalArgumentException");
+        } catch (MathIllegalArgumentException iae) {
         } catch (Exception e) {
-            Assert.fail("Should throw IllegalArgumentException");
+            Assert.fail("Should throw MathIllegalArgumentException");
         }
 
         try {
@@ -154,10 +155,10 @@ public class MillerUpdatingRegressionTest {
             double[] y = {1.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0};
             instance.addObservations(tst, y);
 
-            Assert.fail("Should throw IllegalArgumentException");
-        } catch (IllegalArgumentException iae) {
+            Assert.fail("Should throw MathIllegalArgumentException");
+        } catch (MathIllegalArgumentException iae) {
         } catch (Exception e) {
-            Assert.fail("Should throw IllegalArgumentException");
+            Assert.fail("Should throw MathIllegalArgumentException");
         }
     }
 
@@ -330,7 +331,7 @@ public class MillerUpdatingRegressionTest {
 //            tmp[6] = tmp[2] * tmp[3]; //^7
 //            tmp[7] = tmp[3] * tmp[3]; //^8
 //            tmp[8] = tmp[4] * tmp[3]; //^9
-//            tmp[9] = tmp[4] * tmp[4]; //^10           
+//            tmp[9] = tmp[4] * tmp[4]; //^10
             tmp[1] = tmp[0] * tmp[0];
             tmp[2] = tmp[0] * tmp[1];
             tmp[3] = tmp[0] * tmp[2];
@@ -681,12 +682,12 @@ public class MillerUpdatingRegressionTest {
                     0.214274163161675,
                     0.226073200069370,
                     455.478499142212}, errors, 1E-6);
-//        
+//
         // Check R-Square statistics against R
         TestUtils.assertEquals(0.995479004577296, result.getRSquared(), 1E-12);
         TestUtils.assertEquals(0.992465007628826, result.getAdjustedRSquared(), 1E-12);
-//        
-//        
+//
+//
 //        // Estimate model without intercept
         model = new MillerUpdatingRegression(6, false);
         off = 0;
@@ -702,13 +703,13 @@ public class MillerUpdatingRegressionTest {
                 new double[]{-52.99357013868291, 0.07107319907358,
                     -0.42346585566399, -0.57256866841929,
                     -0.41420358884978, 48.41786562001326}, 1E-11);
-//        
+//
         // Check standard errors from R
         errors = result.getStdErrorOfEstimates();
         TestUtils.assertEquals(new double[]{129.54486693117232, 0.03016640003786,
                     0.41773654056612, 0.27899087467676, 0.32128496193363,
                     17.68948737819961}, errors, 1E-11);
-//        
+//
 
 //        // Check R-Square statistics against R
         TestUtils.assertEquals(0.9999670130706, result.getRSquared(), 1E-12);
@@ -1048,11 +1049,11 @@ public class MillerUpdatingRegressionTest {
         }
         return;
     }
-    
-    
+
+
     @Test
     public void testSubsetRegression() {
-        
+
         MillerUpdatingRegression instance = new MillerUpdatingRegression(3, true);
         MillerUpdatingRegression redRegression = new MillerUpdatingRegression(2, true);
         double[][] x = new double[airdata[0].length][];
@@ -1063,23 +1064,23 @@ public class MillerUpdatingRegressionTest {
             x[i][0] = FastMath.log(airdata[3][i]);
             x[i][1] = FastMath.log(airdata[4][i]);
             x[i][2] = airdata[5][i];
-            
+
             xReduced[i] = new double[2];
             xReduced[i][0] = FastMath.log(airdata[3][i]);
             xReduced[i][1] = FastMath.log(airdata[4][i]);
-            
+
             y[i] = FastMath.log(airdata[2][i]);
         }
 
         instance.addObservations(x, y);
         redRegression.addObservations(xReduced, y);
-        
+
         RegressionResults resultsInstance = instance.regress( new int[]{0,1,2} );
         RegressionResults resultsReduced = redRegression.regress();
-        
+
         TestUtils.assertEquals(resultsInstance.getParameterEstimates(), resultsReduced.getParameterEstimates(), 1.0e-12);
         TestUtils.assertEquals(resultsInstance.getStdErrorOfEstimates(), resultsReduced.getStdErrorOfEstimates(), 1.0e-12);
     }
-    
-    
+
+
 }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/stat/regression/MultipleLinearRegressionAbstractTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/regression/MultipleLinearRegressionAbstractTest.java b/src/test/java/org/apache/commons/math4/stat/regression/MultipleLinearRegressionAbstractTest.java
index 1fc839b..b7ef50a 100644
--- a/src/test/java/org/apache/commons/math4/stat/regression/MultipleLinearRegressionAbstractTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/regression/MultipleLinearRegressionAbstractTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.commons.math4.stat.regression;
 
+import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.apache.commons.math4.exception.NullArgumentException;
 import org.apache.commons.math4.linear.RealMatrix;
 import org.apache.commons.math4.linear.RealVector;
@@ -65,7 +66,7 @@ public abstract class MultipleLinearRegressionAbstractTest {
             Assert.assertTrue(variance > 0.0);
         }
     }
-    
+
     /**
      * Verifies that newSampleData methods consistently insert unitary columns
      * in design matrix.  Confirms the fix for MATH-411.
@@ -78,12 +79,12 @@ public abstract class MultipleLinearRegressionAbstractTest {
           3, 25, 35, 45,
           4, 27, 37, 47
         };
-        double[] y = new double[] {1, 2, 3, 4}; 
+        double[] y = new double[] {1, 2, 3, 4};
         double[][] x = new double[][] {
           {19, 22, 33},
           {20, 30, 40},
           {25, 35, 45},
-          {27, 37, 47}   
+          {27, 37, 47}
         };
         AbstractMultipleLinearRegression regression = createRegression();
         regression.newSampleData(design, 4, 3);
@@ -93,7 +94,7 @@ public abstract class MultipleLinearRegressionAbstractTest {
         regression.newYSampleData(y);
         Assert.assertEquals(flatX, regression.getX());
         Assert.assertEquals(flatY, regression.getY());
-        
+
         // No intercept
         regression.setNoIntercept(true);
         regression.newSampleData(design, 4, 3);
@@ -104,30 +105,30 @@ public abstract class MultipleLinearRegressionAbstractTest {
         Assert.assertEquals(flatX, regression.getX());
         Assert.assertEquals(flatY, regression.getY());
     }
-    
+
     @Test(expected=NullArgumentException.class)
     public void testNewSampleNullData() {
         double[] data = null;
-        createRegression().newSampleData(data, 2, 3); 
+        createRegression().newSampleData(data, 2, 3);
     }
-    
-    @Test(expected=IllegalArgumentException.class)
+
+    @Test(expected=MathIllegalArgumentException.class)
     public void testNewSampleInvalidData() {
         double[] data = new double[] {1, 2, 3, 4};
         createRegression().newSampleData(data, 2, 3);
     }
-    
-    @Test(expected=IllegalArgumentException.class)
+
+    @Test(expected=MathIllegalArgumentException.class)
     public void testNewSampleInsufficientData() {
         double[] data = new double[] {1, 2, 3, 4};
         createRegression().newSampleData(data, 1, 3);
     }
-    
+
     @Test(expected=NullArgumentException.class)
     public void testXSampleDataNull() {
         createRegression().newXSampleData(null);
     }
-    
+
     @Test(expected=NullArgumentException.class)
     public void testYSampleDataNull() {
         createRegression().newYSampleData(null);

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/stat/regression/OLSMultipleLinearRegressionTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/regression/OLSMultipleLinearRegressionTest.java b/src/test/java/org/apache/commons/math4/stat/regression/OLSMultipleLinearRegressionTest.java
index d383d0f..16001d1 100644
--- a/src/test/java/org/apache/commons/math4/stat/regression/OLSMultipleLinearRegressionTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/regression/OLSMultipleLinearRegressionTest.java
@@ -18,6 +18,7 @@ package org.apache.commons.math4.stat.regression;
 
 
 import org.apache.commons.math4.TestUtils;
+import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.apache.commons.math4.exception.NullArgumentException;
 import org.apache.commons.math4.linear.Array2DRowRealMatrix;
 import org.apache.commons.math4.linear.DefaultRealMatrixChangingVisitor;
@@ -65,8 +66,8 @@ public class OLSMultipleLinearRegressionTest extends MultipleLinearRegressionAbs
     protected int getSampleSize() {
         return y.length;
     }
-    
-    @Test(expected=IllegalArgumentException.class)
+
+    @Test(expected=MathIllegalArgumentException.class)
     public void cannotAddSampleDataWithSizeMismatch() {
         double[] y = new double[]{1.0, 2.0};
         double[][] x = new double[1][];
@@ -172,33 +173,33 @@ public class OLSMultipleLinearRegressionTest extends MultipleLinearRegressionAbs
                        0.214274163161675,
                        0.226073200069370,
                        455.478499142212}, errors, 1E-6);
-        
+
         // Check regression standard error against R
         Assert.assertEquals(304.8540735619638, model.estimateRegressionStandardError(), 1E-10);
-        
+
         // Check R-Square statistics against R
         Assert.assertEquals(0.995479004577296, model.calculateRSquared(), 1E-12);
         Assert.assertEquals(0.992465007628826, model.calculateAdjustedRSquared(), 1E-12);
-        
+
         checkVarianceConsistency(model);
-        
+
         // Estimate model without intercept
         model.setNoIntercept(true);
         model.newSampleData(design, nobs, nvars);
-        
+
         // Check expected beta values from R
         betaHat = model.estimateRegressionParameters();
         TestUtils.assertEquals(betaHat,
           new double[]{-52.99357013868291, 0.07107319907358,
                 -0.42346585566399,-0.57256866841929,
-                -0.41420358884978, 48.41786562001326}, 1E-11); 
-        
+                -0.41420358884978, 48.41786562001326}, 1E-11);
+
         // Check standard errors from R
         errors = model.estimateRegressionParametersStandardErrors();
         TestUtils.assertEquals(new double[] {129.54486693117232, 0.03016640003786,
                 0.41773654056612, 0.27899087467676, 0.32128496193363,
                 17.68948737819961}, errors, 1E-11);
-        
+
         // Check expected residuals from R
         residuals = model.estimateResiduals();
         TestUtils.assertEquals(residuals, new double[]{
@@ -207,14 +208,14 @@ public class OLSMultipleLinearRegressionTest extends MultipleLinearRegressionAbs
                 73.09368242049943, 913.21694494481869, 424.82484953610174, -8.56475876776709,
                 -361.32974610842876, 27.34560497213464, 151.28955976355002, -492.49937355336846},
                       1E-10);
-        
+
         // Check regression standard error against R
         Assert.assertEquals(475.1655079819517, model.estimateRegressionStandardError(), 1E-10);
-        
+
         // Check R-Square statistics against R
         Assert.assertEquals(0.9999670130706, model.calculateRSquared(), 1E-12);
         Assert.assertEquals(0.999947220913, model.calculateAdjustedRSquared(), 1E-12);
-         
+
     }
 
     /**
@@ -272,7 +273,7 @@ public class OLSMultipleLinearRegressionTest extends MultipleLinearRegressionAbs
             44.7,46.6,16,29,50.43,
             42.8,27.7,22,29,58.33
         };
-        
+
         final int nobs = 47;
         final int nvars = 4;
 
@@ -317,16 +318,16 @@ public class OLSMultipleLinearRegressionTest extends MultipleLinearRegressionAbs
                 0.27410957467466,
                 0.19454551679325,
                 0.03726654773803}, errors, 1E-10);
-        
+
         // Check regression standard error against R
         Assert.assertEquals(7.73642194433223, model.estimateRegressionStandardError(), 1E-12);
-        
+
         // Check R-Square statistics against R
         Assert.assertEquals(0.649789742860228, model.calculateRSquared(), 1E-12);
         Assert.assertEquals(0.6164363850373927, model.calculateAdjustedRSquared(), 1E-12);
-        
+
         checkVarianceConsistency(model);
-        
+
         // Estimate the model with no intercept
         model = new OLSMultipleLinearRegression();
         model.setNoIntercept(true);
@@ -337,15 +338,15 @@ public class OLSMultipleLinearRegressionTest extends MultipleLinearRegressionAbs
         TestUtils.assertEquals(betaHat,
                 new double[]{0.52191832900513,
                   2.36588087917963,
-                  -0.94770353802795, 
+                  -0.94770353802795,
                   0.30851985863609}, 1E-12);
 
         // Check expected residuals from R
         residuals = model.estimateResiduals();
         TestUtils.assertEquals(residuals, new double[]{
-                44.138759883538249, 27.720705122356215, 35.873200836126799, 
+                44.138759883538249, 27.720705122356215, 35.873200836126799,
                 34.574619581211977, 26.600168342080213, 15.074636243026923, -12.704904871199814,
-                1.497443824078134, 2.691972687079431, 5.582798774291231, -4.422986561283165, 
+                1.497443824078134, 2.691972687079431, 5.582798774291231, -4.422986561283165,
                 -9.198581600334345, 4.481765170730647, 2.273520207553216, -22.649827853221336,
                 -17.747900013943308, 20.298314638496436, 6.861405135329779, -8.684712790954924,
                 -10.298639278062371, -9.896618896845819, 4.568568616351242, -15.313570491727944,
@@ -361,10 +362,10 @@ public class OLSMultipleLinearRegressionTest extends MultipleLinearRegressionAbs
         errors = model.estimateRegressionParametersStandardErrors();
         TestUtils.assertEquals(new double[] {0.10470063765677, 0.41684100584290,
                 0.43370143099691, 0.07694953606522}, errors, 1E-10);
-        
+
         // Check regression standard error against R
         Assert.assertEquals(17.24710630547, model.estimateRegressionStandardError(), 1E-10);
-        
+
         // Check R-Square statistics against R
         Assert.assertEquals(0.946350722085, model.calculateRSquared(), 1E-12);
         Assert.assertEquals(0.9413600915813, model.calculateAdjustedRSquared(), 1E-12);
@@ -451,7 +452,7 @@ public class OLSMultipleLinearRegressionTest extends MultipleLinearRegressionAbs
         model.newSampleData(y, x);
         TestUtils.assertEquals(model.calculateYVariance(), 3.5, 0);
     }
-    
+
     /**
      * Verifies that calculateYVariance and calculateResidualVariance return consistent
      * values with direct variance computation from Y, residuals, respectively.
@@ -459,27 +460,27 @@ public class OLSMultipleLinearRegressionTest extends MultipleLinearRegressionAbs
     protected void checkVarianceConsistency(OLSMultipleLinearRegression model) {
         // Check Y variance consistency
         TestUtils.assertEquals(StatUtils.variance(model.getY().toArray()), model.calculateYVariance(), 0);
-        
+
         // Check residual variance consistency
         double[] residuals = model.calculateResiduals().toArray();
         RealMatrix X = model.getX();
         TestUtils.assertEquals(
                 StatUtils.variance(model.calculateResiduals().toArray()) * (residuals.length - 1),
                 model.calculateErrorVariance() * (X.getRowDimension() - X.getColumnDimension()), 1E-20);
-        
+
     }
-    
+
     /**
      * Verifies that setting X and Y separately has the same effect as newSample(X,Y).
      */
     @Test
     public void testNewSample2() {
-        double[] y = new double[] {1, 2, 3, 4}; 
+        double[] y = new double[] {1, 2, 3, 4};
         double[][] x = new double[][] {
           {19, 22, 33},
           {20, 30, 40},
           {25, 35, 45},
-          {27, 37, 47}   
+          {27, 37, 47}
         };
         OLSMultipleLinearRegression regression = new OLSMultipleLinearRegression();
         regression.newSampleData(y, x);
@@ -489,7 +490,7 @@ public class OLSMultipleLinearRegressionTest extends MultipleLinearRegressionAbs
         regression.newYSampleData(y);
         Assert.assertEquals(combinedX, regression.getX());
         Assert.assertEquals(combinedY, regression.getY());
-        
+
         // No intercept
         regression.setNoIntercept(true);
         regression.newSampleData(y, x);
@@ -500,17 +501,17 @@ public class OLSMultipleLinearRegressionTest extends MultipleLinearRegressionAbs
         Assert.assertEquals(combinedX, regression.getX());
         Assert.assertEquals(combinedY, regression.getY());
     }
-    
+
     @Test(expected=NullArgumentException.class)
     public void testNewSampleDataYNull() {
         createRegression().newSampleData(null, new double[][] {});
     }
-    
+
     @Test(expected=NullArgumentException.class)
     public void testNewSampleDataXNull() {
         createRegression().newSampleData(new double[] {}, null);
     }
-    
+
      /*
      * This is a test based on the Wampler1 data set
      * http://www.itl.nist.gov/div898/strd/lls/data/Wampler1.shtml
@@ -570,7 +571,7 @@ public class OLSMultipleLinearRegressionTest extends MultipleLinearRegressionAbs
                 new double[]{0.0,
                     0.0, 0.0,
                     0.0, 0.0,
-                    0.0}, 1E-8); 
+                    0.0}, 1E-8);
 
         TestUtils.assertEquals(1.0, model.calculateRSquared(), 1.0e-10);
         TestUtils.assertEquals(0, model.estimateErrorVariance(), 1.0e-7);
@@ -578,7 +579,7 @@ public class OLSMultipleLinearRegressionTest extends MultipleLinearRegressionAbs
 
         return;
     }
-    
+
     /*
      * This is a test based on the Wampler2 data set
      * http://www.itl.nist.gov/div898/strd/lls/data/Wampler2.shtml
@@ -640,13 +641,13 @@ public class OLSMultipleLinearRegressionTest extends MultipleLinearRegressionAbs
                 new double[]{0.0,
                     0.0, 0.0,
                     0.0, 0.0,
-                    0.0}, 1E-8); 
+                    0.0}, 1E-8);
         TestUtils.assertEquals(1.0, model.calculateRSquared(), 1.0e-10);
         TestUtils.assertEquals(0, model.estimateErrorVariance(), 1.0e-7);
         TestUtils.assertEquals(0.00, model.calculateResidualSumOfSquares(), 1.0e-6);
         return;
     }
-    
+
     /*
      * This is a test based on the Wampler3 data set
      * http://www.itl.nist.gov/div898/strd/lls/data/Wampler3.shtml
@@ -701,7 +702,7 @@ public class OLSMultipleLinearRegressionTest extends MultipleLinearRegressionAbs
                     1.0,
                     1.0,
                     1.0,
-                    1.0}, 1E-8); 
+                    1.0}, 1E-8);
 
         double[] se = model.estimateRegressionParametersStandardErrors();
         TestUtils.assertEquals(se,
@@ -770,21 +771,21 @@ public class OLSMultipleLinearRegressionTest extends MultipleLinearRegressionAbs
                     1.0,
                     1.0,
                     1.0,
-                    1.0}, 1E-6); 
+                    1.0}, 1E-6);
 
         double[] se = model.estimateRegressionParametersStandardErrors();
         TestUtils.assertEquals(se,
                 new double[]{215232.624678170,
                     236355.173469681, 77934.3524331583,
                     10147.5507550350, 564.566512170752,
-                    11.2324854679312}, 1E-8); 
+                    11.2324854679312}, 1E-8);
 
         TestUtils.assertEquals(.957478440825662, model.calculateRSquared(), 1.0e-10);
         TestUtils.assertEquals(55702845333.3333, model.estimateErrorVariance(), 1.0e-4);
         TestUtils.assertEquals(835542680000.000, model.calculateResidualSumOfSquares(), 1.0e-3);
         return;
     }
-    
+
     /**
      * Anything requiring beta calculation should advertise SME.
      */
@@ -794,26 +795,26 @@ public class OLSMultipleLinearRegressionTest extends MultipleLinearRegressionAbs
         model.newSampleData(new double[] {1,  2,  3, 1, 2, 3, 1, 2, 3}, 3, 2);
         model.calculateBeta();
     }
-    
+
     @Test
     public void testNoSSTOCalculateRsquare() {
         OLSMultipleLinearRegression model = new OLSMultipleLinearRegression();
         model.newSampleData(new double[] {1,  2,  3, 1, 7, 8, 1, 10, 12}, 3, 2);
         Assert.assertTrue(Double.isNaN(model.calculateRSquared()));
     }
-    
+
     @Test(expected=NullPointerException.class)
     public void testNoDataNPECalculateBeta() {
         OLSMultipleLinearRegression model = new OLSMultipleLinearRegression();
         model.calculateBeta();
     }
-    
+
     @Test(expected=NullPointerException.class)
     public void testNoDataNPECalculateHat() {
         OLSMultipleLinearRegression model = new OLSMultipleLinearRegression();
         model.calculateHat();
     }
-    
+
     @Test(expected=NullPointerException.class)
     public void testNoDataNPESSTO() {
         OLSMultipleLinearRegression model = new OLSMultipleLinearRegression();

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/transform/FastCosineTransformerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/transform/FastCosineTransformerTest.java b/src/test/java/org/apache/commons/math4/transform/FastCosineTransformerTest.java
index 44a351a..0769706 100644
--- a/src/test/java/org/apache/commons/math4/transform/FastCosineTransformerTest.java
+++ b/src/test/java/org/apache/commons/math4/transform/FastCosineTransformerTest.java
@@ -22,6 +22,7 @@ import java.util.Collection;
 import org.apache.commons.math4.analysis.UnivariateFunction;
 import org.apache.commons.math4.analysis.function.Sin;
 import org.apache.commons.math4.analysis.function.Sinc;
+import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.apache.commons.math4.exception.MathIllegalStateException;
 import org.apache.commons.math4.transform.DctNormalization;
 import org.apache.commons.math4.transform.FastCosineTransformer;
@@ -46,7 +47,7 @@ import org.junit.runners.Parameterized.Parameters;
 public final class FastCosineTransformerTest
     extends RealTransformerAbstractTest {
 
-    private DctNormalization normalization;
+    private final DctNormalization normalization;
 
     private final int[] invalidDataSize;
 
@@ -229,24 +230,22 @@ public final class FastCosineTransformerTest
         try {
             // bad interval
             transformer.transform(f, 1, -1, 65, TransformType.FORWARD);
-            Assert.fail("Expecting IllegalArgumentException - bad interval");
-        } catch (IllegalArgumentException ex) {
+            Assert.fail("Expecting MathIllegalArgumentException - bad interval");
+        } catch (MathIllegalArgumentException ex) {
             // expected
         }
         try {
             // bad samples number
             transformer.transform(f, -1, 1, 1, TransformType.FORWARD);
-            Assert
-                .fail("Expecting IllegalArgumentException - bad samples number");
-        } catch (IllegalArgumentException ex) {
+            Assert.fail("Expecting MathIllegalArgumentException - bad samples number");
+        } catch (MathIllegalArgumentException ex) {
             // expected
         }
         try {
             // bad samples number
             transformer.transform(f, -1, 1, 64, TransformType.FORWARD);
-            Assert
-                .fail("Expecting IllegalArgumentException - bad samples number");
-        } catch (IllegalArgumentException ex) {
+            Assert.fail("Expecting MathIllegalArgumentException - bad samples number");
+        } catch (MathIllegalArgumentException ex) {
             // expected
         }
     }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/transform/FastHadamardTransformerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/transform/FastHadamardTransformerTest.java b/src/test/java/org/apache/commons/math4/transform/FastHadamardTransformerTest.java
index 89eeed4..8fe0173 100644
--- a/src/test/java/org/apache/commons/math4/transform/FastHadamardTransformerTest.java
+++ b/src/test/java/org/apache/commons/math4/transform/FastHadamardTransformerTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.commons.math4.transform;
 
+import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.apache.commons.math4.transform.FastHadamardTransformer;
 import org.apache.commons.math4.transform.TransformType;
 import org.apache.commons.math4.util.Precision;
@@ -68,7 +69,7 @@ public final class FastHadamardTransformerTest {
         try {
             new FastHadamardTransformer().transform(new double[3], TransformType.FORWARD);
             Assert.fail("an exception should have been thrown");
-        } catch (IllegalArgumentException iae) {
+        } catch (MathIllegalArgumentException iae) {
             // expected
         }
     }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/transform/FastSineTransformerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/transform/FastSineTransformerTest.java b/src/test/java/org/apache/commons/math4/transform/FastSineTransformerTest.java
index 64b8e8d..9a1dfcd 100644
--- a/src/test/java/org/apache/commons/math4/transform/FastSineTransformerTest.java
+++ b/src/test/java/org/apache/commons/math4/transform/FastSineTransformerTest.java
@@ -283,22 +283,22 @@ public final class FastSineTransformerTest extends RealTransformerAbstractTest {
         try {
             // bad interval
             transformer.transform(f, 1, -1, 64, TransformType.FORWARD);
-            Assert.fail("Expecting IllegalArgumentException - bad interval");
-        } catch (IllegalArgumentException ex) {
+            Assert.fail("Expecting MathIllegalArgumentException - bad interval");
+        } catch (MathIllegalArgumentException ex) {
             // expected
         }
         try {
             // bad samples number
             transformer.transform(f, -1, 1, 0, TransformType.FORWARD);
-            Assert.fail("Expecting IllegalArgumentException - bad samples number");
-        } catch (IllegalArgumentException ex) {
+            Assert.fail("Expecting MathIllegalArgumentException - bad samples number");
+        } catch (MathIllegalArgumentException ex) {
             // expected
         }
         try {
             // bad samples number
             transformer.transform(f, -1, 1, 100, TransformType.FORWARD);
-            Assert.fail("Expecting IllegalArgumentException - bad samples number");
-        } catch (IllegalArgumentException ex) {
+            Assert.fail("Expecting MathIllegalArgumentException - bad samples number");
+        } catch (MathIllegalArgumentException ex) {
             // expected
         }
     }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/util/ResizableDoubleArrayTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/util/ResizableDoubleArrayTest.java b/src/test/java/org/apache/commons/math4/util/ResizableDoubleArrayTest.java
index 1f31c0c..c7be6ea 100644
--- a/src/test/java/org/apache/commons/math4/util/ResizableDoubleArrayTest.java
+++ b/src/test/java/org/apache/commons/math4/util/ResizableDoubleArrayTest.java
@@ -18,6 +18,7 @@ package org.apache.commons.math4.util;
 
 import org.apache.commons.math4.distribution.IntegerDistribution;
 import org.apache.commons.math4.distribution.UniformIntegerDistribution;
+import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.apache.commons.math4.exception.NullArgumentException;
 import org.apache.commons.math4.util.ResizableDoubleArray.ExpansionMode;
 import org.junit.After;
@@ -57,15 +58,15 @@ public class ResizableDoubleArrayTest extends DoubleArrayAbstractTest {
         Assert.assertEquals(defaultMode, testDa.getExpansionMode());
         try {
             da = new ResizableDoubleArray(-1);
-            Assert.fail("Expecting IllegalArgumentException");
-        } catch (IllegalArgumentException ex) {
+            Assert.fail("Expecting MathIllegalArgumentException");
+        } catch (MathIllegalArgumentException ex) {
             // expected
         }
 
         testDa = new ResizableDoubleArray((double[]) null);
         Assert.assertEquals(0, testDa.getNumElements());
 
-        double[] initialArray = new double[] { 0, 1, 2 };        
+        double[] initialArray = new double[] { 0, 1, 2 };
         testDa = new ResizableDoubleArray(initialArray);
         Assert.assertEquals(3, testDa.getNumElements());
 
@@ -78,8 +79,8 @@ public class ResizableDoubleArrayTest extends DoubleArrayAbstractTest {
 
         try {
             da = new ResizableDoubleArray(2, 0.5);
-            Assert.fail("Expecting IllegalArgumentException");
-        } catch (IllegalArgumentException ex) {
+            Assert.fail("Expecting MathIllegalArgumentException");
+        } catch (MathIllegalArgumentException ex) {
             // expected
         }
 
@@ -96,8 +97,8 @@ public class ResizableDoubleArrayTest extends DoubleArrayAbstractTest {
 
         try {
             da = new ResizableDoubleArray(2, 2.0, 1.5);
-            Assert.fail("Expecting IllegalArgumentException");
-        } catch (IllegalArgumentException ex) {
+            Assert.fail("Expecting MathIllegalArgumentException");
+        } catch (MathIllegalArgumentException ex) {
             // expected
         }
 
@@ -194,24 +195,24 @@ public class ResizableDoubleArrayTest extends DoubleArrayAbstractTest {
                 "16 and an expansion factor of 2.0",
                 1024, ((ResizableDoubleArray) da).getCapacity());
     }
-    
+
     @Test
     public void testAddElements() {
         ResizableDoubleArray testDa = new ResizableDoubleArray();
-        
+
         // MULTIPLICATIVE_MODE
         testDa.addElements(new double[] {4, 5, 6});
         Assert.assertEquals(3, testDa.getNumElements(), 0);
         Assert.assertEquals(4, testDa.getElement(0), 0);
         Assert.assertEquals(5, testDa.getElement(1), 0);
         Assert.assertEquals(6, testDa.getElement(2), 0);
-        
+
         testDa.addElements(new double[] {4, 5, 6});
         Assert.assertEquals(6, testDa.getNumElements());
 
         // ADDITIVE_MODE  (x's are occupied storage locations, 0's are open)
         testDa = new ResizableDoubleArray(2, 2.0, 2.5,
-                                          ResizableDoubleArray.ExpansionMode.ADDITIVE);        
+                                          ResizableDoubleArray.ExpansionMode.ADDITIVE);
         Assert.assertEquals(2, testDa.getCapacity());
         testDa.addElements(new double[] { 1d }); // x,0
         testDa.addElements(new double[] { 2d }); // x,x
@@ -298,7 +299,7 @@ public class ResizableDoubleArrayTest extends DoubleArrayAbstractTest {
         try {
             ((ResizableDoubleArray) da).setNumElements( -3 );
             Assert.fail( "Setting number of elements to negative should've thrown an exception");
-        } catch( IllegalArgumentException iae ) {
+        } catch(MathIllegalArgumentException iae) {
         }
 
         ((ResizableDoubleArray) da).setNumElements(1024);


[2/2] [math] [MATH-853] MathRuntimeException becomes the commons base class for all other exceptions.

Posted by tn...@apache.org.
[MATH-853] MathRuntimeException becomes the commons base class for all other exceptions.


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/afcfbf57
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/afcfbf57
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/afcfbf57

Branch: refs/heads/master
Commit: afcfbf57b993aa96a3697e3869679894e8f460bd
Parents: 2f461bd
Author: Thomas Neidhart <th...@gmail.com>
Authored: Sun Apr 26 22:11:48 2015 +0200
Committer: Thomas Neidhart <th...@gmail.com>
Committed: Sun Apr 26 22:11:48 2015 +0200

----------------------------------------------------------------------
 src/changes/changes.xml                         |  5 ++
 .../math4/exception/ConvergenceException.java   |  3 +-
 .../exception/MathArithmeticException.java      | 33 +------
 .../exception/MathIllegalArgumentException.java | 30 +------
 .../exception/MathIllegalStateException.java    | 34 +-------
 .../math4/exception/MathParseException.java     | 11 +--
 .../math4/exception/MathRuntimeException.java   | 14 +++
 .../MathUnsupportedOperationException.java      | 30 +------
 .../regression/ModelSpecificationException.java |  3 +-
 .../FieldHermiteInterpolatorTest.java           |  3 +-
 .../interpolation/HermiteInterpolatorTest.java  |  3 +-
 .../commons/math4/complex/ComplexUtilsTest.java | 21 ++---
 .../commons/math4/fraction/BigFractionTest.java |  9 +-
 .../math4/genetics/BinaryChromosomeTest.java    |  3 +-
 .../commons/math4/genetics/RandomKeyTest.java   | 15 ++--
 .../math4/linear/Array2DRowRealMatrixTest.java  | 12 +--
 .../math4/linear/FieldMatrixImplTest.java       | 10 +--
 .../math4/linear/RealVectorAbstractTest.java    | 45 +++++++++-
 .../math4/ode/ContinuousOutputModelTest.java    |  8 +-
 .../math4/random/EmpiricalDistributionTest.java | 64 +++++++-------
 .../commons/math4/random/ValueServerTest.java   | 18 ++--
 .../commons/math4/stat/FrequencyTest.java       | 52 +++++------
 .../math4/stat/correlation/CovarianceTest.java  |  5 +-
 .../correlation/PearsonsCorrelationTest.java    |  9 +-
 .../SpearmansRankCorrelationTest.java           | 10 +--
 .../descriptive/DescriptiveStatisticsTest.java  |  7 +-
 .../MultivariateSummaryStatisticsTest.java      |  9 +-
 .../stat/descriptive/SummaryStatisticsTest.java | 53 ++++++------
 .../GLSMultipleLinearRegressionTest.java        | 57 ++++++------
 .../MillerUpdatingRegressionTest.java           | 75 ++++++++--------
 .../MultipleLinearRegressionAbstractTest.java   | 25 +++---
 .../OLSMultipleLinearRegressionTest.java        | 91 ++++++++++----------
 .../transform/FastCosineTransformerTest.java    | 17 ++--
 .../transform/FastHadamardTransformerTest.java  |  3 +-
 .../transform/FastSineTransformerTest.java      | 12 +--
 .../math4/util/ResizableDoubleArrayTest.java    | 25 +++---
 36 files changed, 397 insertions(+), 427 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index cdd6e9a..cc38aa8 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -54,6 +54,11 @@ If the output is not quite correct, check for invisible trailing spaces!
     </release>
 
     <release version="4.0" date="XXXX-XX-XX" description="">
+      <action dev="tn" type="update" issue="MATH-853">
+        "MathRuntimeException" is now the base class for all commons-math
+        exceptions (except for "NullArgumentException" which extends
+        "NullPointerException").
+      </action>    
       <action dev="tn" type="fix" issue="MATH-1197">
         Computation of 2-sample Kolmogorov-Smirnov statistic in case of ties
         was not correct.

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/main/java/org/apache/commons/math4/exception/ConvergenceException.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/exception/ConvergenceException.java b/src/main/java/org/apache/commons/math4/exception/ConvergenceException.java
index f9b6207..6e63615 100644
--- a/src/main/java/org/apache/commons/math4/exception/ConvergenceException.java
+++ b/src/main/java/org/apache/commons/math4/exception/ConvergenceException.java
@@ -43,8 +43,7 @@ public class ConvergenceException extends MathIllegalStateException {
      * the error.
      * @param args Arguments.
      */
-    public ConvergenceException(Localizable pattern,
-                                Object ... args) {
+    public ConvergenceException(Localizable pattern, Object ... args) {
         getContext().addMessage(pattern, args);
     }
 }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/main/java/org/apache/commons/math4/exception/MathArithmeticException.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/exception/MathArithmeticException.java b/src/main/java/org/apache/commons/math4/exception/MathArithmeticException.java
index 7425bc5..a14a033 100644
--- a/src/main/java/org/apache/commons/math4/exception/MathArithmeticException.java
+++ b/src/main/java/org/apache/commons/math4/exception/MathArithmeticException.java
@@ -16,8 +16,6 @@
  */
 package org.apache.commons.math4.exception;
 
-import org.apache.commons.math4.exception.util.ExceptionContext;
-import org.apache.commons.math4.exception.util.ExceptionContextProvider;
 import org.apache.commons.math4.exception.util.Localizable;
 import org.apache.commons.math4.exception.util.LocalizedFormats;
 
@@ -29,19 +27,15 @@ import org.apache.commons.math4.exception.util.LocalizedFormats;
  *
  * @since 3.0
  */
-public class MathArithmeticException extends ArithmeticException
-    implements ExceptionContextProvider {
+public class MathArithmeticException extends MathRuntimeException {
     /** Serializable version Id. */
     private static final long serialVersionUID = -6024911025449780478L;
-    /** Context. */
-    private final ExceptionContext context;
 
     /**
      * Default constructor.
      */
     public MathArithmeticException() {
-        context = new ExceptionContext(this);
-        context.addMessage(LocalizedFormats.ARITHMETIC_EXCEPTION);
+        this(LocalizedFormats.ARITHMETIC_EXCEPTION);
     }
 
     /**
@@ -51,27 +45,8 @@ public class MathArithmeticException extends ArithmeticException
      * the error.
      * @param args Arguments.
      */
-    public MathArithmeticException(Localizable pattern,
-                                   Object ... args) {
-        context = new ExceptionContext(this);
-        context.addMessage(pattern, args);
+    public MathArithmeticException(Localizable pattern, Object ... args) {
+        super(pattern, args);
     }
 
-    /** {@inheritDoc} */
-    @Override
-    public ExceptionContext getContext() {
-        return context;
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public String getMessage() {
-        return context.getMessage();
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public String getLocalizedMessage() {
-        return context.getLocalizedMessage();
-    }
 }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/main/java/org/apache/commons/math4/exception/MathIllegalArgumentException.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/exception/MathIllegalArgumentException.java b/src/main/java/org/apache/commons/math4/exception/MathIllegalArgumentException.java
index efb7482..ea14f42 100644
--- a/src/main/java/org/apache/commons/math4/exception/MathIllegalArgumentException.java
+++ b/src/main/java/org/apache/commons/math4/exception/MathIllegalArgumentException.java
@@ -16,8 +16,6 @@
  */
 package org.apache.commons.math4.exception;
 
-import org.apache.commons.math4.exception.util.ExceptionContext;
-import org.apache.commons.math4.exception.util.ExceptionContextProvider;
 import org.apache.commons.math4.exception.util.Localizable;
 
 /**
@@ -28,38 +26,16 @@ import org.apache.commons.math4.exception.util.Localizable;
  *
  * @since 2.2
  */
-public class MathIllegalArgumentException extends IllegalArgumentException
-    implements ExceptionContextProvider {
+public class MathIllegalArgumentException extends MathRuntimeException {
     /** Serializable version Id. */
     private static final long serialVersionUID = -6024911025449780478L;
-    /** Context. */
-    private final ExceptionContext context;
 
     /**
      * @param pattern Message pattern explaining the cause of the error.
      * @param args Arguments.
      */
-    public MathIllegalArgumentException(Localizable pattern,
-                                        Object ... args) {
-        context = new ExceptionContext(this);
-        context.addMessage(pattern, args);
+    public MathIllegalArgumentException(Localizable pattern, Object ... args) {
+        super(pattern, args);
     }
 
-    /** {@inheritDoc} */
-    @Override
-    public ExceptionContext getContext() {
-        return context;
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public String getMessage() {
-        return context.getMessage();
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public String getLocalizedMessage() {
-        return context.getLocalizedMessage();
-    }
 }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/main/java/org/apache/commons/math4/exception/MathIllegalStateException.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/exception/MathIllegalStateException.java b/src/main/java/org/apache/commons/math4/exception/MathIllegalStateException.java
index 76bb280..b5acb9e 100644
--- a/src/main/java/org/apache/commons/math4/exception/MathIllegalStateException.java
+++ b/src/main/java/org/apache/commons/math4/exception/MathIllegalStateException.java
@@ -16,8 +16,6 @@
  */
 package org.apache.commons.math4.exception;
 
-import org.apache.commons.math4.exception.util.ExceptionContext;
-import org.apache.commons.math4.exception.util.ExceptionContextProvider;
 import org.apache.commons.math4.exception.util.Localizable;
 import org.apache.commons.math4.exception.util.LocalizedFormats;
 
@@ -28,12 +26,9 @@ import org.apache.commons.math4.exception.util.LocalizedFormats;
  *
  * @since 2.2
  */
-public class MathIllegalStateException extends IllegalStateException
-    implements ExceptionContextProvider {
+public class MathIllegalStateException extends MathRuntimeException {
     /** Serializable version Id. */
     private static final long serialVersionUID = -6024911025449780478L;
-    /** Context. */
-    private final ExceptionContext context;
 
     /**
      * Simple constructor.
@@ -41,10 +36,8 @@ public class MathIllegalStateException extends IllegalStateException
      * @param pattern Message pattern explaining the cause of the error.
      * @param args Arguments.
      */
-    public MathIllegalStateException(Localizable pattern,
-                                     Object ... args) {
-        context = new ExceptionContext(this);
-        context.addMessage(pattern, args);
+    public MathIllegalStateException(Localizable pattern, Object ... args) {
+        super(pattern, args);
     }
 
     /**
@@ -57,9 +50,7 @@ public class MathIllegalStateException extends IllegalStateException
     public MathIllegalStateException(Throwable cause,
                                      Localizable pattern,
                                      Object ... args) {
-        super(cause);
-        context = new ExceptionContext(this);
-        context.addMessage(pattern, args);
+        super(cause, pattern, args);
     }
 
     /**
@@ -69,21 +60,4 @@ public class MathIllegalStateException extends IllegalStateException
         this(LocalizedFormats.ILLEGAL_STATE);
     }
 
-    /** {@inheritDoc} */
-    @Override
-    public ExceptionContext getContext() {
-        return context;
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public String getMessage() {
-        return context.getMessage();
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public String getLocalizedMessage() {
-        return context.getLocalizedMessage();
-    }
 }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/main/java/org/apache/commons/math4/exception/MathParseException.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/exception/MathParseException.java b/src/main/java/org/apache/commons/math4/exception/MathParseException.java
index 0ef6a54..ac4819e 100644
--- a/src/main/java/org/apache/commons/math4/exception/MathParseException.java
+++ b/src/main/java/org/apache/commons/math4/exception/MathParseException.java
@@ -16,7 +16,6 @@
  */
 package org.apache.commons.math4.exception;
 
-import org.apache.commons.math4.exception.util.ExceptionContextProvider;
 import org.apache.commons.math4.exception.util.LocalizedFormats;
 
 /**
@@ -24,8 +23,7 @@ import org.apache.commons.math4.exception.util.LocalizedFormats;
  *
  * @since 2.2
  */
-public class MathParseException extends MathIllegalStateException
-    implements ExceptionContextProvider {
+public class MathParseException extends MathIllegalStateException {
     /** Serializable version Id. */
     private static final long serialVersionUID = -6024911025449780478L;
 
@@ -36,9 +34,7 @@ public class MathParseException extends MathIllegalStateException
      * @param type Class of the object supposedly represented by the
      * {@code wrong} string.
      */
-    public MathParseException(String wrong,
-                              int position,
-                              Class<?> type) {
+    public MathParseException(String wrong, int position, Class<?> type) {
         getContext().addMessage(LocalizedFormats.CANNOT_PARSE_AS_TYPE,
                                 wrong, Integer.valueOf(position), type.getName());
     }
@@ -48,8 +44,7 @@ public class MathParseException extends MathIllegalStateException
      * @param position Index, in the {@code wrong} string, that caused the
      * parsing to fail.
      */
-    public MathParseException(String wrong,
-                              int position) {
+    public MathParseException(String wrong, int position) {
         getContext().addMessage(LocalizedFormats.CANNOT_PARSE,
                                 wrong, Integer.valueOf(position));
     }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/main/java/org/apache/commons/math4/exception/MathRuntimeException.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/exception/MathRuntimeException.java b/src/main/java/org/apache/commons/math4/exception/MathRuntimeException.java
index 56fff8e..382af05 100644
--- a/src/main/java/org/apache/commons/math4/exception/MathRuntimeException.java
+++ b/src/main/java/org/apache/commons/math4/exception/MathRuntimeException.java
@@ -46,6 +46,20 @@ public class MathRuntimeException extends RuntimeException
         context.addMessage(pattern, args);
     }
 
+    /**
+     * @param cause Root cause.
+     * @param pattern Message pattern explaining the cause of the error.
+     * @param args Arguments.
+     * @since 4.0
+     */
+    public MathRuntimeException(Throwable cause,
+                                Localizable pattern,
+                                Object ... args) {
+        super(cause);
+        context = new ExceptionContext(this);
+        context.addMessage(pattern, args);
+    }
+
     /** {@inheritDoc} */
     @Override
     public ExceptionContext getContext() {

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/main/java/org/apache/commons/math4/exception/MathUnsupportedOperationException.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/exception/MathUnsupportedOperationException.java b/src/main/java/org/apache/commons/math4/exception/MathUnsupportedOperationException.java
index ad45b60..ede4a8f 100644
--- a/src/main/java/org/apache/commons/math4/exception/MathUnsupportedOperationException.java
+++ b/src/main/java/org/apache/commons/math4/exception/MathUnsupportedOperationException.java
@@ -16,8 +16,6 @@
  */
 package org.apache.commons.math4.exception;
 
-import org.apache.commons.math4.exception.util.ExceptionContext;
-import org.apache.commons.math4.exception.util.ExceptionContextProvider;
 import org.apache.commons.math4.exception.util.Localizable;
 import org.apache.commons.math4.exception.util.LocalizedFormats;
 
@@ -29,12 +27,9 @@ import org.apache.commons.math4.exception.util.LocalizedFormats;
  *
  * @since 2.2
  */
-public class MathUnsupportedOperationException extends UnsupportedOperationException
-    implements ExceptionContextProvider {
+public class MathUnsupportedOperationException extends MathRuntimeException {
     /** Serializable version Id. */
     private static final long serialVersionUID = -6024911025449780478L;
-    /** Context. */
-    private final ExceptionContext context;
 
     /**
      * Default constructor.
@@ -47,27 +42,8 @@ public class MathUnsupportedOperationException extends UnsupportedOperationExcep
      * the error.
      * @param args Arguments.
      */
-    public MathUnsupportedOperationException(Localizable pattern,
-                                             Object ... args) {
-        context = new ExceptionContext(this);
-        context.addMessage(pattern, args);
+    public MathUnsupportedOperationException(Localizable pattern, Object ... args) {
+        super(pattern, args);
     }
 
-    /** {@inheritDoc} */
-    @Override
-    public ExceptionContext getContext() {
-        return context;
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public String getMessage() {
-        return context.getMessage();
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public String getLocalizedMessage() {
-        return context.getLocalizedMessage();
-    }
 }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/main/java/org/apache/commons/math4/stat/regression/ModelSpecificationException.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/stat/regression/ModelSpecificationException.java b/src/main/java/org/apache/commons/math4/stat/regression/ModelSpecificationException.java
index 248234d..2607a5f 100644
--- a/src/main/java/org/apache/commons/math4/stat/regression/ModelSpecificationException.java
+++ b/src/main/java/org/apache/commons/math4/stat/regression/ModelSpecificationException.java
@@ -33,8 +33,7 @@ public class ModelSpecificationException extends MathIllegalArgumentException {
      *
      * @param args arguments.
      */
-    public ModelSpecificationException(Localizable pattern,
-                                        Object ... args) {
+    public ModelSpecificationException(Localizable pattern, Object ... args) {
         super(pattern, args);
     }
 }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/analysis/interpolation/FieldHermiteInterpolatorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/analysis/interpolation/FieldHermiteInterpolatorTest.java b/src/test/java/org/apache/commons/math4/analysis/interpolation/FieldHermiteInterpolatorTest.java
index 0c3b27b..1e5b031 100644
--- a/src/test/java/org/apache/commons/math4/analysis/interpolation/FieldHermiteInterpolatorTest.java
+++ b/src/test/java/org/apache/commons/math4/analysis/interpolation/FieldHermiteInterpolatorTest.java
@@ -22,6 +22,7 @@ import org.apache.commons.math4.analysis.interpolation.FieldHermiteInterpolator;
 import org.apache.commons.math4.analysis.polynomials.PolynomialFunction;
 import org.apache.commons.math4.dfp.Dfp;
 import org.apache.commons.math4.dfp.DfpField;
+import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.apache.commons.math4.exception.NoDataException;
 import org.apache.commons.math4.fraction.BigFraction;
 import org.apache.commons.math4.util.FastMath;
@@ -265,7 +266,7 @@ public class FieldHermiteInterpolatorTest {
         new FieldHermiteInterpolator<BigFraction>().derivatives(BigFraction.ZERO, 1);
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected=MathIllegalArgumentException.class)
     public void testDuplicatedAbscissa() {
         FieldHermiteInterpolator<BigFraction> interpolator = new FieldHermiteInterpolator<BigFraction>();
         interpolator.addSamplePoint(new BigFraction(1), new BigFraction[] { new BigFraction(0) });

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/analysis/interpolation/HermiteInterpolatorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/analysis/interpolation/HermiteInterpolatorTest.java b/src/test/java/org/apache/commons/math4/analysis/interpolation/HermiteInterpolatorTest.java
index 8dbb6ac..f07fa36 100644
--- a/src/test/java/org/apache/commons/math4/analysis/interpolation/HermiteInterpolatorTest.java
+++ b/src/test/java/org/apache/commons/math4/analysis/interpolation/HermiteInterpolatorTest.java
@@ -21,6 +21,7 @@ import java.util.Random;
 import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
 import org.apache.commons.math4.analysis.interpolation.HermiteInterpolator;
 import org.apache.commons.math4.analysis.polynomials.PolynomialFunction;
+import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.apache.commons.math4.exception.NoDataException;
 import org.apache.commons.math4.util.FastMath;
 import org.junit.Assert;
@@ -234,7 +235,7 @@ public class HermiteInterpolatorTest {
         new HermiteInterpolator().value(0.0);
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected=MathIllegalArgumentException.class)
     public void testDuplicatedAbscissa() {
         HermiteInterpolator interpolator = new HermiteInterpolator();
         interpolator.addSamplePoint(1.0, new double[] { 0.0 });

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/complex/ComplexUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/complex/ComplexUtilsTest.java b/src/test/java/org/apache/commons/math4/complex/ComplexUtilsTest.java
index 77c0d43..a0e9c6f 100644
--- a/src/test/java/org/apache/commons/math4/complex/ComplexUtilsTest.java
+++ b/src/test/java/org/apache/commons/math4/complex/ComplexUtilsTest.java
@@ -20,6 +20,7 @@ package org.apache.commons.math4.complex;
 import org.apache.commons.math4.TestUtils;
 import org.apache.commons.math4.complex.Complex;
 import org.apache.commons.math4.complex.ComplexUtils;
+import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.apache.commons.math4.util.FastMath;
 import org.junit.Test;
 import org.junit.Assert;
@@ -28,16 +29,16 @@ import org.junit.Assert;
  */
 public class ComplexUtilsTest {
 
-    private double inf = Double.POSITIVE_INFINITY;
-    private double negInf = Double.NEGATIVE_INFINITY;
-    private double nan = Double.NaN;
-    private double pi = FastMath.PI;
+    private final double inf = Double.POSITIVE_INFINITY;
+    private final double negInf = Double.NEGATIVE_INFINITY;
+    private final double nan = Double.NaN;
+    private final double pi = FastMath.PI;
 
-    private Complex negInfInf = new Complex(negInf, inf);
-    private Complex infNegInf = new Complex(inf, negInf);
-    private Complex infInf = new Complex(inf, inf);
-    private Complex negInfNegInf = new Complex(negInf, negInf);
-    private Complex infNaN = new Complex(inf, nan);
+    private final Complex negInfInf = new Complex(negInf, inf);
+    private final Complex infNegInf = new Complex(inf, negInf);
+    private final Complex infInf = new Complex(inf, inf);
+    private final Complex negInfNegInf = new Complex(negInf, negInf);
+    private final Complex infNaN = new Complex(inf, nan);
 
     @Test
     public void testPolar2Complex() {
@@ -73,7 +74,7 @@ public class ComplexUtilsTest {
         return Complex.I.multiply(new Complex(theta, 0)).exp().multiply(new Complex(r, 0));
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected=MathIllegalArgumentException.class)
     public void testPolar2ComplexIllegalModulus() {
         ComplexUtils.polar2Complex(-1, 0);
     }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/fraction/BigFractionTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/fraction/BigFractionTest.java b/src/test/java/org/apache/commons/math4/fraction/BigFractionTest.java
index d921026..bba0cd4 100644
--- a/src/test/java/org/apache/commons/math4/fraction/BigFractionTest.java
+++ b/src/test/java/org/apache/commons/math4/fraction/BigFractionTest.java
@@ -22,6 +22,7 @@ import java.math.BigInteger;
 import org.apache.commons.math4.TestUtils;
 import org.apache.commons.math4.exception.ConvergenceException;
 import org.apache.commons.math4.exception.MathArithmeticException;
+import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.apache.commons.math4.exception.NullArgumentException;
 import org.apache.commons.math4.exception.ZeroException;
 import org.apache.commons.math4.fraction.BigFraction;
@@ -156,9 +157,9 @@ public class BigFractionTest {
         assertFraction(8, 13, new BigFraction(0.6152, 99));
         assertFraction(510, 829, new BigFraction(0.6152, 999));
         assertFraction(769, 1250, new BigFraction(0.6152, 9999));
-        
+
         // MATH-996
-        assertFraction(1, 2, new BigFraction(0.5000000001, 10));        
+        assertFraction(1, 2, new BigFraction(0.5000000001, 10));
     }
 
     // MATH-1029
@@ -280,8 +281,8 @@ public class BigFractionTest {
         for (double v : new double[] { Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY}) {
             try {
                 new BigFraction(v);
-                Assert.fail("Expecting IllegalArgumentException");
-            } catch (IllegalArgumentException iae) {
+                Assert.fail("Expecting MathIllegalArgumentException");
+            } catch (MathIllegalArgumentException iae) {
                 // expected
             }
         }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/genetics/BinaryChromosomeTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/genetics/BinaryChromosomeTest.java b/src/test/java/org/apache/commons/math4/genetics/BinaryChromosomeTest.java
index b846fde..4525fb4 100644
--- a/src/test/java/org/apache/commons/math4/genetics/BinaryChromosomeTest.java
+++ b/src/test/java/org/apache/commons/math4/genetics/BinaryChromosomeTest.java
@@ -17,6 +17,7 @@
 package org.apache.commons.math4.genetics;
 
 
+import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.apache.commons.math4.genetics.BinaryChromosome;
 import org.apache.commons.math4.genetics.Chromosome;
 import org.junit.Assert;
@@ -35,7 +36,7 @@ public class BinaryChromosomeTest {
             try {
                 new DummyBinaryChromosome(repr);
                 Assert.fail("Exception not caught");
-            } catch (IllegalArgumentException e) {
+            } catch (MathIllegalArgumentException e) {
                 // Expected
             }
         }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/genetics/RandomKeyTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/genetics/RandomKeyTest.java b/src/test/java/org/apache/commons/math4/genetics/RandomKeyTest.java
index 040edc9..e8ef32b 100644
--- a/src/test/java/org/apache/commons/math4/genetics/RandomKeyTest.java
+++ b/src/test/java/org/apache/commons/math4/genetics/RandomKeyTest.java
@@ -21,6 +21,7 @@ import java.util.Arrays;
 import java.util.Comparator;
 import java.util.List;
 
+import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.apache.commons.math4.genetics.RandomKey;
 import org.junit.Assert;
 import org.junit.Test;
@@ -28,12 +29,12 @@ import org.junit.Test;
 @SuppressWarnings("boxing")
 public class RandomKeyTest {
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected=MathIllegalArgumentException.class)
     public void testConstructor1() {
         new DummyRandomKey(new Double[] {0.2, 0.3, 1.2});
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected=MathIllegalArgumentException.class)
     public void testConstructor2() {
         new DummyRandomKey(new Double[] {0.2, 0.3, -0.2});
     }
@@ -63,8 +64,8 @@ public class RandomKeyTest {
         Assert.assertEquals("c", decoded.get(3));
         Assert.assertEquals("d", decoded.get(4));
     }
-    
-    @Test(expected=IllegalArgumentException.class)
+
+    @Test(expected=MathIllegalArgumentException.class)
     public void testInvalidRepresentation() {
         new DummyRandomKey(new Double[] {0.1, 0.1, 2d, 0.8, 0.2});
     }
@@ -95,6 +96,7 @@ public class RandomKeyTest {
         List<String> data = Arrays.asList(new String[] {"x", "b", "c", "z", "b"});
 
         List<Double> permutation = RandomKey.comparatorPermutation(data, new Comparator<String>() {
+            @Override
             public int compare(String o1, String o2) {
                 return o1.compareTo(o2);
             }
@@ -110,6 +112,7 @@ public class RandomKeyTest {
         Assert.assertEquals("z", decodedData.get(4));
 
         permutation = RandomKey.comparatorPermutation(data, new Comparator<String>() {
+            @Override
             public int compare(String o1, String o2) {
                 return o2.compareTo(o1);
             }
@@ -145,7 +148,7 @@ public class RandomKeyTest {
                     Arrays.asList(new String[] {"a", "b", "c", "d"})
             );
             Assert.fail("Uncaught exception");
-        } catch (IllegalArgumentException e) {
+        } catch (MathIllegalArgumentException e) {
             // no-op
         }
         try {
@@ -154,7 +157,7 @@ public class RandomKeyTest {
                     Arrays.asList(new String[] {"a", "b", "c", "d", "f"})
             );
             Assert.fail("Uncaught exception");
-        } catch (IllegalArgumentException e) {
+        } catch (MathIllegalArgumentException e) {
             // no-op
         }
     }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/linear/Array2DRowRealMatrixTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/linear/Array2DRowRealMatrixTest.java b/src/test/java/org/apache/commons/math4/linear/Array2DRowRealMatrixTest.java
index 63300b4..147e80f 100644
--- a/src/test/java/org/apache/commons/math4/linear/Array2DRowRealMatrixTest.java
+++ b/src/test/java/org/apache/commons/math4/linear/Array2DRowRealMatrixTest.java
@@ -219,9 +219,9 @@ public final class Array2DRowRealMatrixTest {
 
     //Additional Test for Array2DRowRealMatrixTest.testMultiply
 
-    private double[][] d3 = new double[][] {{1,2,3,4},{5,6,7,8}};
-    private double[][] d4 = new double[][] {{1},{2},{3},{4}};
-    private double[][] d5 = new double[][] {{30},{70}};
+    private final double[][] d3 = new double[][] {{1,2,3,4},{5,6,7,8}};
+    private final double[][] d4 = new double[][] {{1},{2},{3},{4}};
+    private final double[][] d5 = new double[][] {{30},{70}};
 
     @Test
     public void testMultiply2() {
@@ -279,8 +279,8 @@ public final class Array2DRowRealMatrixTest {
 
         try {
             m.power(-1);
-            Assert.fail("Expecting IllegalArgumentException");
-        } catch (IllegalArgumentException ex) {
+            Assert.fail("Expecting MathIllegalArgumentException");
+        } catch (MathIllegalArgumentException ex) {
             // ignored
         }
     }
@@ -545,7 +545,7 @@ public final class Array2DRowRealMatrixTest {
         checkCopy(m, null,  1, 0, 2, 4, true);
         checkCopy(m, null, new int[] {},    new int[] { 0 }, true);
         checkCopy(m, null, new int[] { 0 }, new int[] { 4 }, true);
-        
+
         // rectangular check
         double[][] copy = new double[][] { { 0, 0, 0 }, { 0, 0 } };
         checkCopy(m, copy, 0, 1, 0, 2, true);

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/linear/FieldMatrixImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/linear/FieldMatrixImplTest.java b/src/test/java/org/apache/commons/math4/linear/FieldMatrixImplTest.java
index 76f79f8..4fb5bf4 100644
--- a/src/test/java/org/apache/commons/math4/linear/FieldMatrixImplTest.java
+++ b/src/test/java/org/apache/commons/math4/linear/FieldMatrixImplTest.java
@@ -193,9 +193,9 @@ public final class FieldMatrixImplTest {
 
     //Additional Test for Array2DRowFieldMatrix<Fraction>Test.testMultiply
 
-    private Fraction[][] d3 = new Fraction[][] {{new Fraction(1),new Fraction(2),new Fraction(3),new Fraction(4)},{new Fraction(5),new Fraction(6),new Fraction(7),new Fraction(8)}};
-    private Fraction[][] d4 = new Fraction[][] {{new Fraction(1)},{new Fraction(2)},{new Fraction(3)},{new Fraction(4)}};
-    private Fraction[][] d5 = new Fraction[][] {{new Fraction(30)},{new Fraction(70)}};
+    private final Fraction[][] d3 = new Fraction[][] {{new Fraction(1),new Fraction(2),new Fraction(3),new Fraction(4)},{new Fraction(5),new Fraction(6),new Fraction(7),new Fraction(8)}};
+    private final Fraction[][] d4 = new Fraction[][] {{new Fraction(1)},{new Fraction(2)},{new Fraction(3)},{new Fraction(4)}};
+    private final Fraction[][] d5 = new Fraction[][] {{new Fraction(30)},{new Fraction(70)}};
 
     @Test
     public void testMultiply2() {
@@ -245,8 +245,8 @@ public final class FieldMatrixImplTest {
 
         try {
             m.power(-1);
-            Assert.fail("Expecting IllegalArgumentException");
-        } catch (IllegalArgumentException ex) {
+            Assert.fail("Expecting MathIllegalArgumentException");
+        } catch (MathIllegalArgumentException ex) {
             // ignored
         }
     }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/linear/RealVectorAbstractTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/linear/RealVectorAbstractTest.java b/src/test/java/org/apache/commons/math4/linear/RealVectorAbstractTest.java
index b49301c..0324ffc 100644
--- a/src/test/java/org/apache/commons/math4/linear/RealVectorAbstractTest.java
+++ b/src/test/java/org/apache/commons/math4/linear/RealVectorAbstractTest.java
@@ -49,6 +49,7 @@ import org.apache.commons.math4.analysis.function.Tanh;
 import org.apache.commons.math4.analysis.function.Ulp;
 import org.apache.commons.math4.exception.DimensionMismatchException;
 import org.apache.commons.math4.exception.MathArithmeticException;
+import org.apache.commons.math4.exception.MathUnsupportedOperationException;
 import org.apache.commons.math4.exception.NotPositiveException;
 import org.apache.commons.math4.exception.NumberIsTooSmallException;
 import org.apache.commons.math4.exception.OutOfRangeException;
@@ -1061,12 +1062,12 @@ public abstract class RealVectorAbstractTest {
         }
     }
 
-    @Test(expected=ArithmeticException.class)
+    @Test(expected=MathArithmeticException.class)
     public void testUnitVectorNullVector() {
         doTestUnitVectorNullVector(false);
     }
 
-    @Test(expected=ArithmeticException.class)
+    @Test(expected=MathArithmeticException.class)
     public void testUnitizeNullVector() {
         doTestUnitVectorNullVector(true);
     }
@@ -1082,8 +1083,8 @@ public abstract class RealVectorAbstractTest {
             Assert.assertEquals("", values[i], e.getValue(), 0d);
             try {
                 it.remove();
-                Assert.fail("UnsupportedOperationException should have been thrown");
-            } catch (UnsupportedOperationException exc) {
+                Assert.fail("MathUnsupportedOperationException should have been thrown");
+            } catch (MathUnsupportedOperationException exc) {
                 // Expected behavior
             }
         }
@@ -1395,6 +1396,7 @@ public abstract class RealVectorAbstractTest {
 
             private int expectedIndex;
 
+            @Override
             public void visit(final int actualIndex, final double actualValue) {
                 Assert.assertEquals(expectedIndex, actualIndex);
                 Assert.assertEquals(Integer.toString(actualIndex),
@@ -1402,6 +1404,7 @@ public abstract class RealVectorAbstractTest {
                 ++expectedIndex;
             }
 
+            @Override
             public void start(final int actualSize, final int actualStart,
                               final int actualEnd) {
                 Assert.assertEquals(data.length, actualSize);
@@ -1410,6 +1413,7 @@ public abstract class RealVectorAbstractTest {
                 expectedIndex = 0;
             }
 
+            @Override
             public double end() {
                 return 0.0;
             }
@@ -1424,14 +1428,17 @@ public abstract class RealVectorAbstractTest {
         final RealVectorPreservingVisitor visitor;
         visitor = new RealVectorPreservingVisitor() {
 
+            @Override
             public void visit(int index, double value) {
                 // Do nothing
             }
 
+            @Override
             public void start(int dimension, int start, int end) {
                 // Do nothing
             }
 
+            @Override
             public double end() {
                 return 0.0;
             }
@@ -1482,6 +1489,7 @@ public abstract class RealVectorAbstractTest {
 
             private int expectedIndex;
 
+            @Override
             public void visit(final int actualIndex, final double actualValue) {
                 Assert.assertEquals(expectedIndex, actualIndex);
                 Assert.assertEquals(Integer.toString(actualIndex),
@@ -1489,6 +1497,7 @@ public abstract class RealVectorAbstractTest {
                 ++expectedIndex;
             }
 
+            @Override
             public void start(final int actualSize, final int actualStart,
                               final int actualEnd) {
                 Assert.assertEquals(data.length, actualSize);
@@ -1497,6 +1506,7 @@ public abstract class RealVectorAbstractTest {
                 expectedIndex = expectedStart;
             }
 
+            @Override
             public double end() {
                 return 0.0;
             }
@@ -1515,12 +1525,14 @@ public abstract class RealVectorAbstractTest {
         visitor = new RealVectorPreservingVisitor() {
             private final boolean[] visited = new boolean[data.length];
 
+            @Override
             public void visit(final int actualIndex, final double actualValue) {
                 visited[actualIndex] = true;
                 Assert.assertEquals(Integer.toString(actualIndex),
                                     data[actualIndex], actualValue, 0d);
             }
 
+            @Override
             public void start(final int actualSize, final int actualStart,
                               final int actualEnd) {
                 Assert.assertEquals(data.length, actualSize);
@@ -1529,6 +1541,7 @@ public abstract class RealVectorAbstractTest {
                 Arrays.fill(visited, false);
             }
 
+            @Override
             public double end() {
                 for (int i = 0; i < data.length; i++) {
                     Assert.assertTrue("entry " + i + "has not been visited",
@@ -1547,14 +1560,17 @@ public abstract class RealVectorAbstractTest {
         final RealVectorPreservingVisitor visitor;
         visitor = new RealVectorPreservingVisitor() {
 
+            @Override
             public void visit(int index, double value) {
                 // Do nothing
             }
 
+            @Override
             public void start(int dimension, int start, int end) {
                 // Do nothing
             }
 
+            @Override
             public double end() {
                 return 0.0;
             }
@@ -1604,12 +1620,14 @@ public abstract class RealVectorAbstractTest {
         visitor = new RealVectorPreservingVisitor() {
             private final boolean[] visited = new boolean[data.length];
 
+            @Override
             public void visit(final int actualIndex, final double actualValue) {
                 Assert.assertEquals(Integer.toString(actualIndex),
                                     data[actualIndex], actualValue, 0d);
                 visited[actualIndex] = true;
             }
 
+            @Override
             public void start(final int actualSize, final int actualStart,
                               final int actualEnd) {
                 Assert.assertEquals(data.length, actualSize);
@@ -1618,6 +1636,7 @@ public abstract class RealVectorAbstractTest {
                 Arrays.fill(visited, true);
             }
 
+            @Override
             public double end() {
                 for (int i = expectedStart; i <= expectedEnd; i++) {
                     Assert.assertTrue("entry " + i + "has not been visited",
@@ -1641,6 +1660,7 @@ public abstract class RealVectorAbstractTest {
 
             private int expectedIndex;
 
+            @Override
             public double visit(final int actualIndex, final double actualValue) {
                 Assert.assertEquals(expectedIndex, actualIndex);
                 Assert.assertEquals(Integer.toString(actualIndex),
@@ -1649,6 +1669,7 @@ public abstract class RealVectorAbstractTest {
                 return actualIndex + actualValue;
             }
 
+            @Override
             public void start(final int actualSize, final int actualStart,
                               final int actualEnd) {
                 Assert.assertEquals(data.length, actualSize);
@@ -1657,6 +1678,7 @@ public abstract class RealVectorAbstractTest {
                 expectedIndex = 0;
             }
 
+            @Override
             public double end() {
                 return 0.0;
             }
@@ -1674,14 +1696,17 @@ public abstract class RealVectorAbstractTest {
         final RealVectorChangingVisitor visitor;
         visitor = new RealVectorChangingVisitor() {
 
+            @Override
             public double visit(int index, double value) {
                 return 0.0;
             }
 
+            @Override
             public void start(int dimension, int start, int end) {
                 // Do nothing
             }
 
+            @Override
             public double end() {
                 return 0.0;
             }
@@ -1732,6 +1757,7 @@ public abstract class RealVectorAbstractTest {
 
             private int expectedIndex;
 
+            @Override
             public double visit(final int actualIndex, final double actualValue) {
                 Assert.assertEquals(expectedIndex, actualIndex);
                 Assert.assertEquals(Integer.toString(actualIndex),
@@ -1740,6 +1766,7 @@ public abstract class RealVectorAbstractTest {
                 return actualIndex + actualValue;
             }
 
+            @Override
             public void start(final int actualSize, final int actualStart,
                               final int actualEnd) {
                 Assert.assertEquals(data.length, actualSize);
@@ -1748,6 +1775,7 @@ public abstract class RealVectorAbstractTest {
                 expectedIndex = expectedStart;
             }
 
+            @Override
             public double end() {
                 return 0.0;
             }
@@ -1769,6 +1797,7 @@ public abstract class RealVectorAbstractTest {
         visitor = new RealVectorChangingVisitor() {
             private final boolean[] visited = new boolean[data.length];
 
+            @Override
             public double visit(final int actualIndex, final double actualValue) {
                 visited[actualIndex] = true;
                 Assert.assertEquals(Integer.toString(actualIndex),
@@ -1776,6 +1805,7 @@ public abstract class RealVectorAbstractTest {
                 return actualIndex + actualValue;
             }
 
+            @Override
             public void start(final int actualSize, final int actualStart,
                               final int actualEnd) {
                 Assert.assertEquals(data.length, actualSize);
@@ -1784,6 +1814,7 @@ public abstract class RealVectorAbstractTest {
                 Arrays.fill(visited, false);
             }
 
+            @Override
             public double end() {
                 for (int i = 0; i < data.length; i++) {
                     Assert.assertTrue("entry " + i + "has not been visited",
@@ -1805,14 +1836,17 @@ public abstract class RealVectorAbstractTest {
         final RealVectorChangingVisitor visitor;
         visitor = new RealVectorChangingVisitor() {
 
+            @Override
             public double visit(int index, double value) {
                 return 0.0;
             }
 
+            @Override
             public void start(int dimension, int start, int end) {
                 // Do nothing
             }
 
+            @Override
             public double end() {
                 return 0.0;
             }
@@ -1862,6 +1896,7 @@ public abstract class RealVectorAbstractTest {
         visitor = new RealVectorChangingVisitor() {
             private final boolean[] visited = new boolean[data.length];
 
+            @Override
             public double visit(final int actualIndex, final double actualValue) {
                 Assert.assertEquals(Integer.toString(actualIndex),
                                     data[actualIndex], actualValue, 0d);
@@ -1869,6 +1904,7 @@ public abstract class RealVectorAbstractTest {
                 return actualIndex + actualValue;
             }
 
+            @Override
             public void start(final int actualSize, final int actualStart,
                               final int actualEnd) {
                 Assert.assertEquals(data.length, actualSize);
@@ -1877,6 +1913,7 @@ public abstract class RealVectorAbstractTest {
                 Arrays.fill(visited, true);
             }
 
+            @Override
             public double end() {
                 for (int i = expectedStart; i <= expectedEnd; i++) {
                     Assert.assertTrue("entry " + i + "has not been visited",

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/ode/ContinuousOutputModelTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/ode/ContinuousOutputModelTest.java b/src/test/java/org/apache/commons/math4/ode/ContinuousOutputModelTest.java
index b08ef1f..d9d2cb4 100644
--- a/src/test/java/org/apache/commons/math4/ode/ContinuousOutputModelTest.java
+++ b/src/test/java/org/apache/commons/math4/ode/ContinuousOutputModelTest.java
@@ -98,11 +98,13 @@ public class ContinuousOutputModelTest {
       // theoretical solution: y[0] = cos(t), y[1] = sin(t)
       FirstOrderDifferentialEquations problem =
           new FirstOrderDifferentialEquations() {
-              public void computeDerivatives(double t, double[] y, double[] dot) {
+              @Override
+            public void computeDerivatives(double t, double[] y, double[] dot) {
                   dot[0] = -y[1];
                   dot[1] =  y[0];
               }
-              public int getDimension() {
+              @Override
+            public int getDimension() {
                   return 2;
               }
           };
@@ -169,7 +171,7 @@ public class ContinuousOutputModelTest {
           ContinuousOutputModel otherCm = new ContinuousOutputModel();
           otherCm.handleStep(buildInterpolator(t0, y0, t1), true);
           cm.append(otherCm);
-      } catch(IllegalArgumentException iae) {
+      } catch(MathIllegalArgumentException iae) {
           return true; // there was an allowable error
       }
       return false; // no allowable error

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/random/EmpiricalDistributionTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/random/EmpiricalDistributionTest.java b/src/test/java/org/apache/commons/math4/random/EmpiricalDistributionTest.java
index 6f38711..9633ff7 100644
--- a/src/test/java/org/apache/commons/math4/random/EmpiricalDistributionTest.java
+++ b/src/test/java/org/apache/commons/math4/random/EmpiricalDistributionTest.java
@@ -33,6 +33,7 @@ import org.apache.commons.math4.distribution.NormalDistribution;
 import org.apache.commons.math4.distribution.RealDistribution;
 import org.apache.commons.math4.distribution.RealDistributionAbstractTest;
 import org.apache.commons.math4.distribution.UniformRealDistribution;
+import org.apache.commons.math4.exception.MathIllegalStateException;
 import org.apache.commons.math4.exception.NullArgumentException;
 import org.apache.commons.math4.random.EmpiricalDistribution;
 import org.apache.commons.math4.random.RandomGenerator;
@@ -94,13 +95,13 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
         // Load from a URL
         empiricalDistribution.load(url);
         checkDistribution();
-        
+
         // Load again from a file (also verifies idempotency of load)
         File file = new File(url.toURI());
         empiricalDistribution.load(file);
         checkDistribution();
     }
-    
+
     private void checkDistribution() {
         // testData File has 10000 values, with mean ~ 5.0, std dev ~ 1
         // Make sure that loaded distribution matches this
@@ -156,8 +157,8 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
         try {
             empiricalDistribution.getNextValue();
             empiricalDistribution2.getNextValue();
-            Assert.fail("Expecting IllegalStateException");
-        } catch (IllegalStateException ex) {
+            Assert.fail("Expecting MathIllegalStateException");
+        } catch (MathIllegalStateException ex) {
             // expected
         }
     }
@@ -236,24 +237,24 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
         TestUtils.assertEquals(expectedBinUpperBounds, dist.getUpperBounds(), tol);
         TestUtils.assertEquals(expectedGeneratorUpperBounds, dist.getGeneratorUpperBounds(), tol);
     }
-    
+
     @Test
     public void testGeneratorConfig() {
         double[] testData = {0, 1, 2, 3, 4};
         RandomGenerator generator = new RandomAdaptorTest.ConstantGenerator(0.5);
-        
+
         EmpiricalDistribution dist = new EmpiricalDistribution(5, generator);
         dist.load(testData);
         for (int i = 0; i < 5; i++) {
             Assert.assertEquals(2.0, dist.getNextValue(), 0d);
         }
-        
+
         // Verify no NPE with null generator argument
         dist = new EmpiricalDistribution(5, (RandomGenerator) null);
         dist.load(testData);
         dist.getNextValue();
     }
-    
+
     @Test
     public void testReSeed() throws Exception {
         empiricalDistribution.load(url);
@@ -301,9 +302,9 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
         Assert.assertEquals("mean", 5.069831575018909, stats.getMean(), tolerance);
         Assert.assertEquals("std dev", 1.0173699343977738, stats.getStandardDeviation(), tolerance);
     }
-   
+
     //  Setup for distribution tests
-    
+
     @Override
     public RealDistribution makeDistribution() {
         // Create a uniform distribution on [0, 10,000]
@@ -315,10 +316,10 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
         dist.load(sourceData);
         return dist;
     }
-    
+
     /** Uniform bin mass = 10/10001 == mass of all but the first bin */
     private final double binMass = 10d / (n + 1);
-    
+
     /** Mass of first bin = 11/10001 */
     private final double firstBinMass = 11d / (n + 1);
 
@@ -327,11 +328,11 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
        final double[] testPoints = new double[] {9, 10, 15, 1000, 5004, 9999};
        return testPoints;
     }
-    
+
 
     @Override
     public double[] makeCumulativeTestValues() {
-        /* 
+        /*
          * Bins should be [0, 10], (10, 20], ..., (9990, 10000]
          * Kernels should be N(4.5, 3.02765), N(14.5, 3.02765)...
          * Each bin should have mass 10/10000 = .001
@@ -370,12 +371,12 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
             final RealDistribution kernel = findKernel(lower, upper);
             final double withinBinKernelMass = kernel.probability(lower, upper);
             final double density = kernel.density(testPoints[i]);
-            densityValues[i] = density * (bin == 0 ? firstBinMass : binMass) / withinBinKernelMass;   
+            densityValues[i] = density * (bin == 0 ? firstBinMass : binMass) / withinBinKernelMass;
         }
         return densityValues;
     }
-    
-    /** 
+
+    /**
      * Modify test integration bounds from the default. Because the distribution
      * has discontinuities at bin boundaries, integrals spanning multiple bins
      * will face convergence problems.  Only test within-bin integrals and spans
@@ -389,6 +390,7 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
         final BaseAbstractUnivariateIntegrator integrator =
             new IterativeLegendreGaussIntegrator(5, 1.0e-12, 1.0e-10);
         final UnivariateFunction d = new UnivariateFunction() {
+            @Override
             public double value(double x) {
                 return distribution.density(x);
             }
@@ -397,15 +399,15 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
         final double[] upper = {5, 12, 1030, 5010, 10000};
         for (int i = 1; i < 5; i++) {
             Assert.assertEquals(
-                    distribution.probability( 
+                    distribution.probability(
                             lower[i], upper[i]),
                             integrator.integrate(
                                     1000000, // Triangle integrals are very slow to converge
                                     d, lower[i], upper[i]), tol);
         }
     }
-    
-    /** 
+
+    /**
      * MATH-984
      * Verify that sampled values do not go outside of the range of the data.
      */
@@ -429,7 +431,7 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
             Assert.assertTrue(dev > 0);
         }
     }
-    
+
     /**
      * MATH-1203, MATH-1208
      */
@@ -448,7 +450,7 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
         Assert.assertEquals(0.5, dist.cumulativeProbability(0.5), Double.MIN_VALUE);
         Assert.assertEquals(0.5, dist.cumulativeProbability(0.7), Double.MIN_VALUE);
     }
-    
+
     /**
      * Find the bin that x belongs (relative to {@link #makeDistribution()}).
      */
@@ -459,7 +461,7 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
         // If x falls on a bin boundary, it is in the lower bin
         return FastMath.floor(x / 10) == x / 10 ? bin - 1 : bin;
     }
-    
+
     /**
      * Find the within-bin kernel for the bin with lower bound lower
      * and upper bound upper. All bins other than the first contain 10 points
@@ -471,10 +473,10 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
         if (lower < 1) {
             return new NormalDistribution(5d, 3.3166247903554);
         } else {
-            return new NormalDistribution((upper + lower + 1) / 2d, 3.0276503540974917); 
+            return new NormalDistribution((upper + lower + 1) / 2d, 3.0276503540974917);
         }
     }
-    
+
     @Test
     public void testKernelOverrideConstant() {
         final EmpiricalDistribution dist = new ConstantKernelEmpiricalDistribution(5);
@@ -500,7 +502,7 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
         Assert.assertEquals(8.0, dist.inverseCumulativeProbability(0.5), tol);
         Assert.assertEquals(8.0, dist.inverseCumulativeProbability(0.6), tol);
     }
-    
+
     @Test
     public void testKernelOverrideUniform() {
         final EmpiricalDistribution dist = new UniformKernelEmpiricalDistribution(5);
@@ -508,14 +510,14 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
         dist.load(data);
         // Kernels are uniform distributions on [1,3], [4,6], [7,9], [10,12], [13,15]
         final double bounds[] = {3d, 6d, 9d, 12d};
-        final double tol = 10E-12; 
+        final double tol = 10E-12;
         for (int i = 0; i < 20; i++) {
             final double v = dist.sample();
             // Make sure v is not in the excluded range between bins - that is (bounds[i], bounds[i] + 1)
             for (int j = 0; j < bounds.length; j++) {
                 Assert.assertFalse(v > bounds[j] + tol && v < bounds[j] + 1 - tol);
             }
-        }   
+        }
         Assert.assertEquals(0.0, dist.cumulativeProbability(1), tol);
         Assert.assertEquals(0.1, dist.cumulativeProbability(2), tol);
         Assert.assertEquals(0.6, dist.cumulativeProbability(10), tol);
@@ -530,8 +532,8 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
         Assert.assertEquals(8.0, dist.inverseCumulativeProbability(0.5), tol);
         Assert.assertEquals(9.0, dist.inverseCumulativeProbability(0.6), tol);
     }
-    
-    
+
+
     /**
      * Empirical distribution using a constant smoothing kernel.
      */
@@ -546,7 +548,7 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
             return new ConstantRealDistribution(bStats.getMean());
         }
     }
-    
+
     /**
      * Empirical distribution using a uniform smoothing kernel.
      */

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/random/ValueServerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/random/ValueServerTest.java b/src/test/java/org/apache/commons/math4/random/ValueServerTest.java
index 43d3554..f9c63ef 100644
--- a/src/test/java/org/apache/commons/math4/random/ValueServerTest.java
+++ b/src/test/java/org/apache/commons/math4/random/ValueServerTest.java
@@ -38,7 +38,7 @@ import org.junit.runner.RunWith;
 @RunWith(RetryRunner.class)
 public final class ValueServerTest {
 
-    private ValueServer vs = new ValueServer(new Well19937c(100));
+    private final ValueServer vs = new ValueServer(new Well19937c(100));
 
     @Before
     public void setUp() {
@@ -78,12 +78,12 @@ public final class ValueServerTest {
         Assert.assertEquals("std dev", 1.0173699343977738, stats.getStandardDeviation(),
             tolerance);
     }
-    
+
     /**
      * Verify that when provided with fixed seeds, stochastic modes
      * generate fixed sequences.  Verifies the fix for MATH-654.
      */
-    @Test 
+    @Test
     public void testFixedSeed() throws Exception {
         ValueServer valueServer = new ValueServer();
         URL url = getClass().getResource("testData.txt");
@@ -94,7 +94,7 @@ public final class ValueServerTest {
         checkFixedSeed(valueServer, ValueServer.GAUSSIAN_MODE);
         checkFixedSeed(valueServer, ValueServer.UNIFORM_MODE);
     }
-    
+
     /**
      * Do the check for {@link #testFixedSeed()}
      * @param mode ValueServer mode
@@ -110,7 +110,7 @@ public final class ValueServerTest {
         for (int i = 0; i < 100; i++) {
             values[1][i] = valueServer.getNext();
         }
-        Assert.assertTrue(Arrays.equals(values[0], values[1])); 
+        Assert.assertTrue(Arrays.equals(values[0], values[1]));
     }
 
     /**
@@ -121,8 +121,8 @@ public final class ValueServerTest {
     public void testNextDigestFail() throws Exception {
         try {
             vs.getNext();
-            Assert.fail("Expecting IllegalStateException");
-        } catch (IllegalStateException ex) {}
+            Assert.fail("Expecting MathIllegalStateException");
+        } catch (MathIllegalStateException ex) {}
     }
 
     @Test
@@ -203,8 +203,8 @@ public final class ValueServerTest {
         try {
             vs.setMode(1000);
             vs.getNext();
-            Assert.fail("bad mode, expecting IllegalStateException");
-        } catch (IllegalStateException ex) {
+            Assert.fail("bad mode, expecting MathIllegalStateException");
+        } catch (MathIllegalStateException ex) {
             // ignored
         }
     }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/stat/FrequencyTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/FrequencyTest.java b/src/test/java/org/apache/commons/math4/stat/FrequencyTest.java
index ae1a4d9..444c57a 100644
--- a/src/test/java/org/apache/commons/math4/stat/FrequencyTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/FrequencyTest.java
@@ -159,14 +159,14 @@ public final class FrequencyTest {
         f.addValue(bChar);
         try {
             f.addValue(aString);
-            Assert.fail("Expecting IllegalArgumentException");
-        } catch (IllegalArgumentException ex) {
+            Assert.fail("Expecting MathIllegalArgumentException");
+        } catch (MathIllegalArgumentException ex) {
             // expected
         }
         try {
             f.addValue(2);
-            Assert.fail("Expecting IllegalArgumentException");
-        } catch (IllegalArgumentException ex) {
+            Assert.fail("Expecting MathIllegalArgumentException");
+        } catch (MathIllegalArgumentException ex) {
             // expected
         }
         Assert.assertEquals("a pct",0.5,f.getPct(aChar),TOLERANCE);
@@ -254,7 +254,7 @@ public final class FrequencyTest {
         Assert.assertEquals("Integer 1 cumPct", 0.5, f.getCumPct(1), TOLERANCE);
         Assert.assertEquals("Integer 1 cumPct", 0.5, f.getCumPct(Long.valueOf(1)), TOLERANCE);
         Assert.assertEquals("Integer 1 cumPct", 0.5, f.getCumPct(Integer.valueOf(1)), TOLERANCE);
-        
+
         f.incrementValue(ONE, -2);
         f.incrementValue(THREE, 5);
 
@@ -264,7 +264,7 @@ public final class FrequencyTest {
         Iterator<?> it = f.valuesIterator();
         while (it.hasNext()) {
             Assert.assertTrue(it.next() instanceof Long);
-        }        
+        }
     }
 
     @Test
@@ -275,7 +275,7 @@ public final class FrequencyTest {
         f.addValue(TWO);
         Assert.assertEquals(f, TestUtils.serializeAndRecover(f));
     }
-    
+
     @Test
     public void testGetUniqueCount() {
         Assert.assertEquals(0, f.getUniqueCount());
@@ -286,7 +286,7 @@ public final class FrequencyTest {
         f.addValue(TWO);
         Assert.assertEquals(2, f.getUniqueCount());
     }
-    
+
     @Test
     public void testIncrement() {
         Assert.assertEquals(0, f.getUniqueCount());
@@ -295,34 +295,34 @@ public final class FrequencyTest {
 
         f.incrementValue(ONE_LONG, 4);
         Assert.assertEquals(5, f.getCount(ONE_LONG));
-        
+
         f.incrementValue(ONE_LONG, -5);
         Assert.assertEquals(0, f.getCount(ONE_LONG));
-        
+
         try {
             f.incrementValue(CHAR_A, 1);
-            Assert.fail("Expecting IllegalArgumentException");
-        } catch (IllegalArgumentException ex) {
+            Assert.fail("Expecting MathIllegalArgumentException");
+        } catch (MathIllegalArgumentException ex) {
             // expected
         }
 
         f = new Frequency();
         f.incrementValue(CHAR_A, 2);
-        
+
         Assert.assertEquals(2, f.getCount(CHAR_A));
 
         try {
             f.incrementValue(ONE, 1);
-            Assert.fail("Expecting IllegalArgumentException");
-        } catch (IllegalArgumentException ex) {
+            Assert.fail("Expecting MathIllegalArgumentException");
+        } catch (MathIllegalArgumentException ex) {
             // expected
         }
-        
+
         f.incrementValue(CHAR_A, 3);
         Assert.assertEquals(5, f.getCount(CHAR_A));
 
     }
-    
+
     @Test
     public void testMerge() {
         Assert.assertEquals(0, f.getUniqueCount());
@@ -330,7 +330,7 @@ public final class FrequencyTest {
         f.addValue(TWO_LONG);
         f.addValue(ONE);
         f.addValue(TWO);
-        
+
         Assert.assertEquals(2, f.getUniqueCount());
         Assert.assertEquals(2, f.getCount(ONE));
         Assert.assertEquals(2, f.getCount(TWO));
@@ -345,18 +345,18 @@ public final class FrequencyTest {
         Assert.assertEquals(2, g.getCount(THREE));
 
         f.merge(g);
-        
+
         Assert.assertEquals(3, f.getUniqueCount());
         Assert.assertEquals(3, f.getCount(ONE));
         Assert.assertEquals(2, f.getCount(TWO));
-        Assert.assertEquals(2, f.getCount(THREE));        
+        Assert.assertEquals(2, f.getCount(THREE));
     }
-    
+
     @Test
     public void testMergeCollection() {
         Assert.assertEquals(0, f.getUniqueCount());
         f.addValue(ONE_LONG);
-        
+
         Assert.assertEquals(1, f.getUniqueCount());
         Assert.assertEquals(1, f.getCount(ONE));
         Assert.assertEquals(0, f.getCount(TWO));
@@ -366,18 +366,18 @@ public final class FrequencyTest {
 
         Frequency h = new Frequency();
         h.addValue(THREE_LONG);
-        
+
         List<Frequency> coll = new ArrayList<Frequency>();
         coll.add(g);
         coll.add(h);
         f.merge(coll);
-        
+
         Assert.assertEquals(3, f.getUniqueCount());
         Assert.assertEquals(1, f.getCount(ONE));
         Assert.assertEquals(1, f.getCount(TWO));
-        Assert.assertEquals(1, f.getCount(THREE));        
+        Assert.assertEquals(1, f.getCount(THREE));
     }
-    
+
     @Test
     public void testMode() {
         List<Comparable<?>> mode;

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/stat/correlation/CovarianceTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/correlation/CovarianceTest.java b/src/test/java/org/apache/commons/math4/stat/correlation/CovarianceTest.java
index f0c6fbe..de67cff 100644
--- a/src/test/java/org/apache/commons/math4/stat/correlation/CovarianceTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/correlation/CovarianceTest.java
@@ -17,6 +17,7 @@
 package org.apache.commons.math4.stat.correlation;
 
 import org.apache.commons.math4.TestUtils;
+import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.apache.commons.math4.exception.NotStrictlyPositiveException;
 import org.apache.commons.math4.linear.Array2DRowRealMatrix;
 import org.apache.commons.math4.linear.RealMatrix;
@@ -183,8 +184,8 @@ public class CovarianceTest {
         double[] two = new double[] {2};
         try {
             new Covariance().covariance(one, two, false);
-            Assert.fail("Expecting IllegalArgumentException");
-        } catch (IllegalArgumentException ex) {
+            Assert.fail("Expecting MathIllegalArgumentException");
+        } catch (MathIllegalArgumentException ex) {
             // Expected
         }
         try {

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/stat/correlation/PearsonsCorrelationTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/correlation/PearsonsCorrelationTest.java b/src/test/java/org/apache/commons/math4/stat/correlation/PearsonsCorrelationTest.java
index d36513b..c4c0211 100644
--- a/src/test/java/org/apache/commons/math4/stat/correlation/PearsonsCorrelationTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/correlation/PearsonsCorrelationTest.java
@@ -18,6 +18,7 @@ package org.apache.commons.math4.stat.correlation;
 
 import org.apache.commons.math4.TestUtils;
 import org.apache.commons.math4.distribution.TDistribution;
+import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.apache.commons.math4.linear.BlockRealMatrix;
 import org.apache.commons.math4.linear.RealMatrix;
 import org.apache.commons.math4.stat.correlation.Covariance;
@@ -210,15 +211,15 @@ public class PearsonsCorrelationTest {
         double[] two = new double[] {2};
         try {
             new PearsonsCorrelation().correlation(one, two);
-            Assert.fail("Expecting IllegalArgumentException");
-        } catch (IllegalArgumentException ex) {
+            Assert.fail("Expecting MathIllegalArgumentException");
+        } catch (MathIllegalArgumentException ex) {
             // Expected
         }
         RealMatrix matrix = new BlockRealMatrix(new double[][] {{0},{1}});
         try {
             new PearsonsCorrelation(matrix);
-            Assert.fail("Expecting IllegalArgumentException");
-        } catch (IllegalArgumentException ex) {
+            Assert.fail("Expecting MathIllegalArgumentException");
+        } catch (MathIllegalArgumentException ex) {
             // Expected
         }
     }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/stat/correlation/SpearmansRankCorrelationTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/correlation/SpearmansRankCorrelationTest.java b/src/test/java/org/apache/commons/math4/stat/correlation/SpearmansRankCorrelationTest.java
index fbccc29..20cacd9 100644
--- a/src/test/java/org/apache/commons/math4/stat/correlation/SpearmansRankCorrelationTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/correlation/SpearmansRankCorrelationTest.java
@@ -95,15 +95,15 @@ public class SpearmansRankCorrelationTest extends PearsonsCorrelationTest {
         double[] two = new double[] {2};
         try {
             new SpearmansCorrelation().correlation(one, two);
-            Assert.fail("Expecting IllegalArgumentException");
-        } catch (IllegalArgumentException ex) {
+            Assert.fail("Expecting MathIllegalArgumentException");
+        } catch (MathIllegalArgumentException ex) {
             // Expected
         }
         RealMatrix matrix = new BlockRealMatrix(new double[][] {{0},{1}});
         try {
             new SpearmansCorrelation(matrix);
-            Assert.fail("Expecting IllegalArgumentException");
-        } catch (IllegalArgumentException ex) {
+            Assert.fail("Expecting MathIllegalArgumentException");
+        } catch (MathIllegalArgumentException ex) {
             // Expected
         }
     }
@@ -149,7 +149,7 @@ public class SpearmansRankCorrelationTest extends PearsonsCorrelationTest {
         // compute correlation
         NaturalRanking ranking = new NaturalRanking(NaNStrategy.REMOVED);
         SpearmansCorrelation spearman = new SpearmansCorrelation(matrix, ranking);
-        
+
         Assert.assertEquals(0.5, spearman.getCorrelationMatrix().getEntry(0, 1), Double.MIN_VALUE);
     }
 

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/stat/descriptive/DescriptiveStatisticsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/DescriptiveStatisticsTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/DescriptiveStatisticsTest.java
index 5f25f88..e11e171 100644
--- a/src/test/java/org/apache/commons/math4/stat/descriptive/DescriptiveStatisticsTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/descriptive/DescriptiveStatisticsTest.java
@@ -16,6 +16,7 @@ package org.apache.commons.math4.stat.descriptive;
 import java.util.Locale;
 
 import org.apache.commons.math4.TestUtils;
+import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.apache.commons.math4.stat.descriptive.DescriptiveStatistics;
 import org.apache.commons.math4.stat.descriptive.SummaryStatistics;
 import org.apache.commons.math4.stat.descriptive.UnivariateStatistic;
@@ -77,7 +78,7 @@ public class DescriptiveStatisticsTest {
         try {
             stats.setWindowSize(-3);
             Assert.fail("an exception should have been thrown");
-        } catch (IllegalArgumentException iae) {
+        } catch (MathIllegalArgumentException iae) {
             // expected
         }
         Assert.assertEquals(300, stats.getWindowSize());
@@ -197,8 +198,8 @@ public class DescriptiveStatisticsTest {
         // Try to set bad impl
         try {
             stats.setPercentileImpl(new badPercentile());
-            Assert.fail("Expecting IllegalArgumentException");
-        } catch (IllegalArgumentException ex) {
+            Assert.fail("Expecting MathIllegalArgumentException");
+        } catch (MathIllegalArgumentException ex) {
             // expected
         }
     }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/stat/descriptive/MultivariateSummaryStatisticsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/MultivariateSummaryStatisticsTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/MultivariateSummaryStatisticsTest.java
index c9d8c37..d198644 100644
--- a/src/test/java/org/apache/commons/math4/stat/descriptive/MultivariateSummaryStatisticsTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/descriptive/MultivariateSummaryStatisticsTest.java
@@ -21,6 +21,7 @@ import java.util.Locale;
 
 import org.apache.commons.math4.TestUtils;
 import org.apache.commons.math4.exception.DimensionMismatchException;
+import org.apache.commons.math4.exception.MathIllegalStateException;
 import org.apache.commons.math4.stat.descriptive.MultivariateSummaryStatistics;
 import org.apache.commons.math4.stat.descriptive.StorelessUnivariateStatistic;
 import org.apache.commons.math4.stat.descriptive.moment.Mean;
@@ -71,11 +72,9 @@ public class MultivariateSummaryStatisticsTest {
         u.addValue(new double[] { 1, 2 });
         u.addValue(new double[] { 3, 4 });
         try {
-            u.setMeanImpl(new StorelessUnivariateStatistic[] {
-                            new sumMean(), new sumMean()
-                          });
-            Assert.fail("Expecting IllegalStateException");
-        } catch (IllegalStateException ex) {
+            u.setMeanImpl(new StorelessUnivariateStatistic[] { new sumMean(), new sumMean() });
+            Assert.fail("Expecting MathIllegalStateException");
+        } catch (MathIllegalStateException ex) {
             // expected
         }
     }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/afcfbf57/src/test/java/org/apache/commons/math4/stat/descriptive/SummaryStatisticsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/SummaryStatisticsTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/SummaryStatisticsTest.java
index d546ca3..bdf1f38 100644
--- a/src/test/java/org/apache/commons/math4/stat/descriptive/SummaryStatisticsTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/descriptive/SummaryStatisticsTest.java
@@ -18,6 +18,7 @@ package org.apache.commons.math4.stat.descriptive;
 
 
 import org.apache.commons.math4.TestUtils;
+import org.apache.commons.math4.exception.MathIllegalStateException;
 import org.apache.commons.math4.stat.descriptive.StatisticalSummary;
 import org.apache.commons.math4.stat.descriptive.SummaryStatistics;
 import org.apache.commons.math4.stat.descriptive.moment.GeometricMean;
@@ -32,20 +33,20 @@ import org.junit.Test;
  */
 public class SummaryStatisticsTest {
 
-    private double one = 1;
-    private float twoF = 2;
-    private long twoL = 2;
-    private int three = 3;
-    private double mean = 2;
-    private double sumSq = 18;
-    private double sum = 8;
-    private double var = 0.666666666666666666667;
-    private double popVar = 0.5;
-    private double std = FastMath.sqrt(var);
-    private double n = 4;
-    private double min = 1;
-    private double max = 3;
-    private double tolerance = 10E-15;
+    private final double one = 1;
+    private final float twoF = 2;
+    private final long twoL = 2;
+    private final int three = 3;
+    private final double mean = 2;
+    private final double sumSq = 18;
+    private final double sum = 8;
+    private final double var = 0.666666666666666666667;
+    private final double popVar = 0.5;
+    private final double std = FastMath.sqrt(var);
+    private final double n = 4;
+    private final double min = 1;
+    private final double max = 3;
+    private final double tolerance = 10E-15;
 
     protected SummaryStatistics createSummaryStatistics() {
         return new SummaryStatistics();
@@ -292,12 +293,12 @@ public class SummaryStatisticsTest {
         u.addValue(3);
         try {
             u.setMeanImpl(new Sum());
-            Assert.fail("Expecting IllegalStateException");
-        } catch (IllegalStateException ex) {
+            Assert.fail("Expecting MathIllegalStateException");
+        } catch (MathIllegalStateException ex) {
             // expected
         }
     }
-    
+
     @Test
     public void testQuadraticMean() {
         final double[] values = { 1.2, 3.4, 5.6, 7.89 };
@@ -315,7 +316,7 @@ public class SummaryStatisticsTest {
 
         Assert.assertEquals(expected, stats.getQuadraticMean(), Math.ulp(expected));
     }
-    
+
     /**
      * JIRA: MATH-691
      */
@@ -327,31 +328,31 @@ public class SummaryStatisticsTest {
         for(double i : scores) {
           stats.addValue(i);
         }
-        Assert.assertEquals((new Variance(false)).evaluate(scores),stats.getVariance(), 0); 
+        Assert.assertEquals((new Variance(false)).evaluate(scores),stats.getVariance(), 0);
     }
-    
+
     @Test
     public void testOverrideMeanWithMathClass() {
         double[] scores = {1, 2, 3, 4};
         SummaryStatistics stats = new SummaryStatistics();
-        stats.setMeanImpl(new Mean()); 
+        stats.setMeanImpl(new Mean());
         for(double i : scores) {
           stats.addValue(i);
         }
-        Assert.assertEquals((new Mean()).evaluate(scores),stats.getMean(), 0); 
+        Assert.assertEquals((new Mean()).evaluate(scores),stats.getMean(), 0);
     }
-    
+
     @Test
     public void testOverrideGeoMeanWithMathClass() {
         double[] scores = {1, 2, 3, 4};
         SummaryStatistics stats = new SummaryStatistics();
-        stats.setGeoMeanImpl(new GeometricMean()); 
+        stats.setGeoMeanImpl(new GeometricMean());
         for(double i : scores) {
           stats.addValue(i);
         }
-        Assert.assertEquals((new GeometricMean()).evaluate(scores),stats.getGeometricMean(), 0); 
+        Assert.assertEquals((new GeometricMean()).evaluate(scores),stats.getGeometricMean(), 0);
     }
-    
+
     @Test
     public void testToString() {
         SummaryStatistics u = createSummaryStatistics();