You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ps...@apache.org on 2012/09/08 19:27:48 UTC

svn commit: r1382332 [1/2] - in /commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat: ./ descriptive/ descriptive/moment/

Author: psteitz
Date: Sat Sep  8 17:27:47 2012
New Revision: 1382332

URL: http://svn.apache.org/viewvc?rev=1382332&view=rev
Log:
Added throws declarations, improved javadoc, made Kurtosis increment consistent with other moment statistics. JIRA: MATH-854.

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/Frequency.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/StatUtils.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/AbstractStorelessUnivariateStatistic.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/AbstractUnivariateStatistic.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/AggregateSummaryStatistics.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/DescriptiveStatistics.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/MultivariateSummaryStatistics.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/StorelessUnivariateStatistic.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/SummaryStatistics.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/SynchronizedDescriptiveStatistics.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/SynchronizedMultivariateSummaryStatistics.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/SynchronizedSummaryStatistics.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/UnivariateStatistic.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/WeightedEvaluation.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/FirstMoment.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/FourthMoment.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/GeometricMean.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/Kurtosis.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/Mean.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/SecondMoment.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/SemiVariance.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/Skewness.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/StandardDeviation.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/ThirdMoment.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/Variance.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/VectorialMean.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/Frequency.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/Frequency.java?rev=1382332&r1=1382331&r2=1382332&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/Frequency.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/Frequency.java Sat Sep  8 17:27:47 2012
@@ -105,9 +105,9 @@ public class Frequency implements Serial
      * </p>
      *
      * @param v the value to add.
-     * @throws IllegalArgumentException if <code>v</code> is not comparable with previous entries
+     * @throws MathIllegalArgumentException if <code>v</code> is not comparable with previous entries
      */
-    public void addValue(Comparable<?> v){
+    public void addValue(Comparable<?> v) throws MathIllegalArgumentException {
         Comparable<?> obj = v;
         if (v instanceof Integer) {
            obj = Long.valueOf(((Integer) v).longValue());

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/StatUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/StatUtils.java?rev=1382332&r1=1382331&r2=1382332&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/StatUtils.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/StatUtils.java Sat Sep  8 17:27:47 2012
@@ -16,6 +16,7 @@
  */
 package org.apache.commons.math3.stat;
 
+import org.apache.commons.math3.exception.MathIllegalArgumentException;
 import org.apache.commons.math3.exception.NumberIsTooSmallException;
 import org.apache.commons.math3.exception.DimensionMismatchException;
 import org.apache.commons.math3.exception.NoDataException;
@@ -87,9 +88,10 @@ public final class StatUtils {
      * @param values  array of values to sum
      * @return the sum of the values or <code>Double.NaN</code> if the array
      * is empty
-     * @throws IllegalArgumentException if the array is null
+     * @throws MathIllegalArgumentException if the array is null
      */
-    public static double sum(final double[] values) {
+    public static double sum(final double[] values)
+    throws MathIllegalArgumentException {
         return SUM.evaluate(values);
     }
 
@@ -104,11 +106,11 @@ public final class StatUtils {
      * @param begin index of the first array element to include
      * @param length the number of elements to include
      * @return the sum of the values or Double.NaN if length = 0
-     * @throws IllegalArgumentException if the array is null or the array index
+     * @throws MathIllegalArgumentException if the array is null or the array index
      *  parameters are not valid
      */
     public static double sum(final double[] values, final int begin,
-            final int length) {
+            final int length) throws MathIllegalArgumentException {
         return SUM.evaluate(values, begin, length);
     }
 
@@ -121,9 +123,9 @@ public final class StatUtils {
      * @param values  input array
      * @return the sum of the squared values or <code>Double.NaN</code> if the
      * array is empty
-     * @throws IllegalArgumentException if the array is null
+     * @throws MathIllegalArgumentException if the array is null
      */
-    public static double sumSq(final double[] values) {
+    public static double sumSq(final double[] values) throws MathIllegalArgumentException {
         return SUM_OF_SQUARES.evaluate(values);
     }
 
@@ -138,11 +140,11 @@ public final class StatUtils {
      * @param begin index of the first array element to include
      * @param length the number of elements to include
      * @return the sum of the squares of the values or Double.NaN if length = 0
-     * @throws IllegalArgumentException if the array is null or the array index
+     * @throws MathIllegalArgumentException if the array is null or the array index
      * parameters are not valid
      */
     public static double sumSq(final double[] values, final int begin,
-            final int length) {
+            final int length) throws MathIllegalArgumentException {
         return SUM_OF_SQUARES.evaluate(values, begin, length);
     }
 
@@ -154,9 +156,10 @@ public final class StatUtils {
      *
      * @param values the input array
      * @return the product of the values or Double.NaN if the array is empty
-     * @throws IllegalArgumentException if the array is null
+     * @throws MathIllegalArgumentException if the array is null
      */
-    public static double product(final double[] values) {
+    public static double product(final double[] values)
+    throws MathIllegalArgumentException {
         return PRODUCT.evaluate(values);
     }
 
@@ -171,11 +174,11 @@ public final class StatUtils {
      * @param begin index of the first array element to include
      * @param length the number of elements to include
      * @return the product of the values or Double.NaN if length = 0
-     * @throws IllegalArgumentException if the array is null or the array index
+     * @throws MathIllegalArgumentException if the array is null or the array index
      * parameters are not valid
      */
     public static double product(final double[] values, final int begin,
-            final int length) {
+            final int length) throws MathIllegalArgumentException {
         return PRODUCT.evaluate(values, begin, length);
     }
 
@@ -191,9 +194,10 @@ public final class StatUtils {
      * @param values the input array
      * @return the sum of the natural logs of the values or Double.NaN if
      * the array is empty
-     * @throws IllegalArgumentException if the array is null
+     * @throws MathIllegalArgumentException if the array is null
      */
-    public static double sumLog(final double[] values) {
+    public static double sumLog(final double[] values)
+    throws MathIllegalArgumentException {
         return SUM_OF_LOGS.evaluate(values);
     }
 
@@ -212,11 +216,11 @@ public final class StatUtils {
      * @param length the number of elements to include
      * @return the sum of the natural logs of the values or Double.NaN if
      * length = 0
-     * @throws IllegalArgumentException if the array is null or the array index
+     * @throws MathIllegalArgumentException if the array is null or the array index
      * parameters are not valid
      */
     public static double sumLog(final double[] values, final int begin,
-            final int length) {
+            final int length) throws MathIllegalArgumentException {
         return SUM_OF_LOGS.evaluate(values, begin, length);
     }
 
@@ -231,9 +235,10 @@ public final class StatUtils {
      *
      * @param values the input array
      * @return the mean of the values or Double.NaN if the array is empty
-     * @throws IllegalArgumentException if the array is null
+     * @throws MathIllegalArgumentException if the array is null
      */
-    public static double mean(final double[] values) {
+    public static double mean(final double[] values)
+    throws MathIllegalArgumentException {
         return MEAN.evaluate(values);
     }
 
@@ -251,11 +256,11 @@ public final class StatUtils {
      * @param begin index of the first array element to include
      * @param length the number of elements to include
      * @return the mean of the values or Double.NaN if length = 0
-     * @throws IllegalArgumentException if the array is null or the array index
+     * @throws MathIllegalArgumentException if the array is null or the array index
      * parameters are not valid
      */
     public static double mean(final double[] values, final int begin,
-            final int length) {
+            final int length) throws MathIllegalArgumentException {
         return MEAN.evaluate(values, begin, length);
     }
 
@@ -270,9 +275,10 @@ public final class StatUtils {
      *
      * @param values the input array
      * @return the geometric mean of the values or Double.NaN if the array is empty
-     * @throws IllegalArgumentException if the array is null
+     * @throws MathIllegalArgumentException if the array is null
      */
-    public static double geometricMean(final double[] values) {
+    public static double geometricMean(final double[] values)
+    throws MathIllegalArgumentException {
         return GEOMETRIC_MEAN.evaluate(values);
     }
 
@@ -290,11 +296,11 @@ public final class StatUtils {
      * @param begin index of the first array element to include
      * @param length the number of elements to include
      * @return the geometric mean of the values or Double.NaN if length = 0
-     * @throws IllegalArgumentException if the array is null or the array index
+     * @throws MathIllegalArgumentException if the array is null or the array index
      * parameters are not valid
      */
     public static double geometricMean(final double[] values, final int begin,
-            final int length) {
+            final int length) throws MathIllegalArgumentException {
         return GEOMETRIC_MEAN.evaluate(values, begin, length);
     }
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/AbstractStorelessUnivariateStatistic.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/AbstractStorelessUnivariateStatistic.java?rev=1382332&r1=1382331&r2=1382332&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/AbstractStorelessUnivariateStatistic.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/AbstractStorelessUnivariateStatistic.java Sat Sep  8 17:27:47 2012
@@ -17,6 +17,7 @@
 package org.apache.commons.math3.stat.descriptive;
 
 import org.apache.commons.math3.exception.util.LocalizedFormats;
+import org.apache.commons.math3.exception.MathIllegalArgumentException;
 import org.apache.commons.math3.exception.NullArgumentException;
 import org.apache.commons.math3.util.MathUtils;
 import org.apache.commons.math3.util.Precision;
@@ -49,13 +50,14 @@ public abstract class AbstractStorelessU
      * possibly more accurate implementation that works directly with the
      * input array.</p>
      * <p>
-     * If the array is null, an IllegalArgumentException is thrown.</p>
+     * If the array is null, a MathIllegalArgumentException is thrown.</p>
      * @param values input array
      * @return the value of the statistic applied to the input array
+     * @throws MathIllegalArgumentException if values is null
      * @see org.apache.commons.math3.stat.descriptive.UnivariateStatistic#evaluate(double[])
      */
     @Override
-    public double evaluate(final double[] values) {
+    public double evaluate(final double[] values) throws MathIllegalArgumentException {
         if (values == null) {
             throw new NullArgumentException(LocalizedFormats.INPUT_ARRAY);
         }
@@ -76,15 +78,17 @@ public abstract class AbstractStorelessU
      * input array.</p>
      * <p>
      * If the array is null or the index parameters are not valid, an
-     * IllegalArgumentException is thrown.</p>
+     * MathIllegalArgumentException is thrown.</p>
      * @param values the input array
      * @param begin the index of the first element to include
      * @param length the number of elements to include
      * @return the value of the statistic applied to the included array entries
+     * @throws MathIllegalArgumentException if the array is null or the indices are not valid
      * @see org.apache.commons.math3.stat.descriptive.UnivariateStatistic#evaluate(double[], int, int)
      */
     @Override
-    public double evaluate(final double[] values, final int begin, final int length) {
+    public double evaluate(final double[] values, final int begin,
+            final int length) throws MathIllegalArgumentException {
         if (test(values, begin, length)) {
             clear();
             incrementAll(values, begin, length);
@@ -120,10 +124,10 @@ public abstract class AbstractStorelessU
      * Throws IllegalArgumentException if the input values array is null.</p>
      *
      * @param values values to add
-     * @throws IllegalArgumentException if values is null
+     * @throws MathIllegalArgumentException if values is null
      * @see org.apache.commons.math3.stat.descriptive.StorelessUnivariateStatistic#incrementAll(double[])
      */
-    public void incrementAll(double[] values) {
+    public void incrementAll(double[] values) throws MathIllegalArgumentException {
         if (values == null) {
             throw new NullArgumentException(LocalizedFormats.INPUT_ARRAY);
         }
@@ -139,10 +143,10 @@ public abstract class AbstractStorelessU
      * @param values  array holding values to add
      * @param begin   index of the first array element to add
      * @param length  number of array elements to add
-     * @throws IllegalArgumentException if values is null
+     * @throws MathIllegalArgumentException if values is null
      * @see org.apache.commons.math3.stat.descriptive.StorelessUnivariateStatistic#incrementAll(double[], int, int)
      */
-    public void incrementAll(double[] values, int begin, int length) {
+    public void incrementAll(double[] values, int begin, int length) throws MathIllegalArgumentException {
         if (test(values, begin, length)) {
             int k = begin + length;
             for (int i = begin; i < k; i++) {

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/AbstractUnivariateStatistic.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/AbstractUnivariateStatistic.java?rev=1382332&r1=1382331&r2=1382332&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/AbstractUnivariateStatistic.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/AbstractUnivariateStatistic.java Sat Sep  8 17:27:47 2012
@@ -45,7 +45,7 @@ public abstract class AbstractUnivariate
     /**
      * Set the data array.
      * <p>
-     * The stored value is a copy of the parameter array, not the array itself
+     * The stored value is a copy of the parameter array, not the array itself.
      * </p>
      * @param values data array to store (may be null to remove stored data)
      * @see #evaluate()
@@ -71,13 +71,33 @@ public abstract class AbstractUnivariate
     }
 
     /**
-     * Set the data array.
+     * Set the data array.  The input array is copied, not referenced.
+     *
      * @param values data array to store
      * @param begin the index of the first element to include
      * @param length the number of elements to include
+     * @throws MathIllegalArgumentException if values is null or the indices
+     * are not valid
      * @see #evaluate()
      */
-    public void setData(final double[] values, final int begin, final int length) {
+    public void setData(final double[] values, final int begin, final int length)
+    throws MathIllegalArgumentException {
+        if (values == null) {
+            throw new NullArgumentException(LocalizedFormats.INPUT_ARRAY);
+        }
+
+        if (begin < 0) {
+            throw new NotPositiveException(LocalizedFormats.START_POSITION, begin);
+        }
+
+        if (length < 0) {
+            throw new NotPositiveException(LocalizedFormats.LENGTH, length);
+        }
+
+        if (begin + length > values.length) {
+            throw new NumberIsTooLargeException(LocalizedFormats.SUBARRAY_ENDS_AFTER_ARRAY_END,
+                                                begin + length, values.length, true);
+        }
         storedData = new double[length];
         System.arraycopy(values, begin, storedData, 0, length);
     }
@@ -85,18 +105,19 @@ public abstract class AbstractUnivariate
     /**
      * Returns the result of evaluating the statistic over the stored data.
      * <p>
-     * The stored array is the one which was set by previous calls to
+     * The stored array is the one which was set by previous calls to {@link #setData(double[])}.
      * </p>
      * @return the value of the statistic applied to the stored data
+     * @throws MathIllegalArgumentException if the stored data array is null
      */
-    public double evaluate() {
+    public double evaluate() throws MathIllegalArgumentException {
         return evaluate(storedData);
     }
 
     /**
      * {@inheritDoc}
      */
-    public double evaluate(final double[] values) {
+    public double evaluate(final double[] values) throws MathIllegalArgumentException {
         test(values, 0, 0);
         return evaluate(values, 0, values.length);
     }
@@ -104,7 +125,8 @@ public abstract class AbstractUnivariate
     /**
      * {@inheritDoc}
      */
-    public abstract double evaluate(final double[] values, final int begin, final int length);
+    public abstract double evaluate(final double[] values, final int begin, final int length)
+    throws MathIllegalArgumentException;
 
     /**
      * {@inheritDoc}
@@ -118,7 +140,7 @@ public abstract class AbstractUnivariate
      * <ul>
      * <li>returns <code>true</code> iff the parameters designate a subarray of
      * positive length</li>
-     * <li>throws <code>IllegalArgumentException</code> if the array is null or
+     * <li>throws <code>MathIllegalArgumentException</code> if the array is null or
      * or the indices are invalid</li>
      * <li>returns <code>false</li> if the array is non-null, but
      * <code>length</code> is 0.
@@ -128,12 +150,12 @@ public abstract class AbstractUnivariate
      * @param begin index of the first array element to include
      * @param length the number of elements to include
      * @return true if the parameters are valid and designate a subarray of positive length
-     * @throws IllegalArgumentException if the indices are invalid or the array is null
+     * @throws MathIllegalArgumentException if the indices are invalid or the array is null
      */
     protected boolean test(
         final double[] values,
         final int begin,
-        final int length) {
+        final int length) throws MathIllegalArgumentException {
         return test(values, begin, length, false);
     }
 
@@ -155,10 +177,11 @@ public abstract class AbstractUnivariate
      * @param length the number of elements to include
      * @param allowEmpty if <code>true</code> then zero length arrays are allowed
      * @return true if the parameters are valid
-     * @throws IllegalArgumentException if the indices are invalid or the array is null
+     * @throws MathIllegalArgumentException if the indices are invalid or the array is null
      * @since 3.0
      */
-    protected boolean test(final double[] values, final int begin, final int length, final boolean allowEmpty){
+    protected boolean test(final double[] values, final int begin,
+            final int length, final boolean allowEmpty) throws MathIllegalArgumentException {
 
         if (values == null) {
             throw new NullArgumentException(LocalizedFormats.INPUT_ARRAY);
@@ -211,14 +234,14 @@ public abstract class AbstractUnivariate
      * @param begin index of the first array element to include
      * @param length the number of elements to include
      * @return true if the parameters are valid and designate a subarray of positive length
-     * @throws IllegalArgumentException if the indices are invalid or the array is null
+     * @throws MathIllegalArgumentException if the indices are invalid or the array is null
      * @since 2.1
      */
     protected boolean test(
         final double[] values,
         final double[] weights,
         final int begin,
-        final int length) {
+        final int length) throws MathIllegalArgumentException {
         return test(values, weights, begin, length, false);
     }
 
@@ -230,7 +253,7 @@ public abstract class AbstractUnivariate
      * <ul>
      * <li>returns <code>true</code> iff the parameters designate a subarray of
      * non-negative length and the weights array contains legitimate values.</li>
-     * <li>throws <code>IllegalArgumentException</code> if any of the following are true:
+     * <li>throws <code>MathIllegalArgumentException</code> if any of the following are true:
      * <ul><li>the values array is null</li>
      *     <li>the weights array is null</li>
      *     <li>the weights array does not have the same length as the values array</li>
@@ -249,13 +272,16 @@ public abstract class AbstractUnivariate
      * @param length the number of elements to include.
      * @param allowEmpty if {@code true} than allow zero length arrays to pass.
      * @return {@code true} if the parameters are valid.
-     * @throws IllegalArgumentException if the indices are invalid or the array
-     * is {@code null}.
+     * @throws NullArgumentException if either of the arrays are null
+     * @throws MathIllegalArgumentException if the array indices are not valid,
+     * the weights array contains NaN, infinite or negative elements, or there
+     * are no positive weights.
      * @since 3.0
      */
-    protected boolean test(final double[] values, final double[] weights, final int begin, final int length, final boolean allowEmpty){
+    protected boolean test(final double[] values, final double[] weights,
+            final int begin, final int length, final boolean allowEmpty) throws MathIllegalArgumentException {
 
-        if (weights == null) {
+        if (weights == null || values == null) {
             throw new NullArgumentException(LocalizedFormats.INPUT_ARRAY);
         }
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/AggregateSummaryStatistics.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/AggregateSummaryStatistics.java?rev=1382332&r1=1382331&r2=1382332&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/AggregateSummaryStatistics.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/AggregateSummaryStatistics.java Sat Sep  8 17:27:47 2012
@@ -21,6 +21,8 @@ import java.io.Serializable;
 import java.util.Collection;
 import java.util.Iterator;
 
+import org.apache.commons.math3.exception.NullArgumentException;
+
 /**
  * <p>
  * An aggregator for {@code SummaryStatistics} from several data sets or
@@ -73,6 +75,7 @@ public class AggregateSummaryStatistics 
      *
      */
     public AggregateSummaryStatistics() {
+        // No try-catch or throws NAE because arg is guaranteed non-null
         this(new SummaryStatistics());
     }
 
@@ -90,9 +93,10 @@ public class AggregateSummaryStatistics 
      *      If {@code null}, a new, default statistics object is used.  Any statistic
      *      values in the prototype are propagated to contributing statistics
      *      objects and (once) into these aggregate statistics.
+     * @throws NullArgumentException if prototypeStatistics is null
      * @see #createContributingStatistics()
      */
-    public AggregateSummaryStatistics(SummaryStatistics prototypeStatistics) {
+    public AggregateSummaryStatistics(SummaryStatistics prototypeStatistics) throws NullArgumentException {
         this(prototypeStatistics,
              prototypeStatistics == null ? null : new SummaryStatistics(prototypeStatistics));
     }
@@ -281,6 +285,7 @@ public class AggregateSummaryStatistics 
         SummaryStatistics contributingStatistics
                 = new AggregatingSummaryStatistics(statistics);
 
+        // No try - catch or advertising NAE because neither argument will ever be null
         SummaryStatistics.copy(statisticsPrototype, contributingStatistics);
 
         return contributingStatistics;

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/DescriptiveStatistics.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/DescriptiveStatistics.java?rev=1382332&r1=1382331&r2=1382332&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/DescriptiveStatistics.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/DescriptiveStatistics.java Sat Sep  8 17:27:47 2012
@@ -121,8 +121,10 @@ public class DescriptiveStatistics imple
      * Construct a DescriptiveStatistics instance with the specified window
      *
      * @param window the window size.
+     * @throws MathIllegalArgumentException if window size is less than 1 but
+     * not equal to {@link #INFINITE_WINDOW}
      */
-    public DescriptiveStatistics(int window) {
+    public DescriptiveStatistics(int window) throws MathIllegalArgumentException {
         setWindowSize(window);
     }
 
@@ -145,8 +147,9 @@ public class DescriptiveStatistics imple
      * is a copy of original.
      *
      * @param original DescriptiveStatistics instance to copy
+     * @throws NullArgumentException if original is null
      */
-    public DescriptiveStatistics(DescriptiveStatistics original) {
+    public DescriptiveStatistics(DescriptiveStatistics original) throws NullArgumentException {
         copy(original, this);
     }
 
@@ -329,15 +332,20 @@ public class DescriptiveStatistics imple
     }
 
     /**
-     * WindowSize controls the number of values which contribute
-     * to the reported statistics.  For example, if
-     * windowSize is set to 3 and the values {1,2,3,4,5}
-     * have been added <strong> in that order</strong>
-     * then the <i>available values</i> are {3,4,5} and all
-     * reported statistics will be based on these values
+     * WindowSize controls the number of values that contribute to the
+     * reported statistics.  For example, if windowSize is set to 3 and the
+     * values {1,2,3,4,5} have been added <strong> in that order</strong> then
+     * the <i>available values</i> are {3,4,5} and all reported statistics will
+     * be based on these values. If {@code windowSize} is decreased as a result
+     * of this call and there are more than the new value of elements in the
+     * current dataset, values from the front of the array are discarded to
+     * reduce the dataset to {@code windowSize} elements.
+     *
      * @param windowSize sets the size of the window.
+     * @throws MathIllegalArgumentException if window size is less than 1 but
+     * not equal to {@link #INFINITE_WINDOW}
      */
-    public void setWindowSize(int windowSize) {
+    public void setWindowSize(int windowSize) throws MathIllegalArgumentException {
         if (windowSize < 1) {
             if (windowSize != INFINITE_WINDOW) {
                 throw new MathIllegalArgumentException(
@@ -406,10 +414,10 @@ public class DescriptiveStatistics imple
      *
      * @param p the requested percentile (scaled from 0 - 100)
      * @return An estimate for the pth percentile of the stored data
-     * @throws IllegalStateException if percentile implementation has been
+     * @throws MathIllegalStateException if percentile implementation has been
      *  overridden and the supplied implementation does not support setQuantile
      */
-    public double getPercentile(double p) {
+    public double getPercentile(double p) throws MathIllegalStateException {
         if (percentileImpl instanceof Percentile) {
             ((Percentile) percentileImpl).setQuantile(p);
         } else {
@@ -450,7 +458,11 @@ public class DescriptiveStatistics imple
         outBuffer.append("mean: ").append(getMean()).append(endl);
         outBuffer.append("std dev: ").append(getStandardDeviation())
             .append(endl);
-        outBuffer.append("median: ").append(getPercentile(50)).append(endl);
+        try {
+            outBuffer.append("median: ").append(getPercentile(50)).append(endl);
+        } catch (MathIllegalStateException ex) {
+            outBuffer.append("median: unavailable").append(endl);
+        }
         outBuffer.append("skewness: ").append(getSkewness()).append(endl);
         outBuffer.append("kurtosis: ").append(getKurtosis()).append(endl);
         return outBuffer.toString();
@@ -462,6 +474,7 @@ public class DescriptiveStatistics imple
      * @return the computed value of the statistic.
      */
     public double apply(UnivariateStatistic stat) {
+        // No try-catch or advertised exception here because arguments are guaranteed valid
         return stat.evaluate(eDA.getInternalValues(), eDA.start(), eDA.getNumElements());
     }
 
@@ -590,12 +603,12 @@ public class DescriptiveStatistics imple
      * <code>IllegalArgumentException</code> is thrown.
      *
      * @param percentileImpl the percentileImpl to set
-     * @throws IllegalArgumentException if the supplied implementation does not
+     * @throws MathIllegalArgumentException if the supplied implementation does not
      *  provide a <code>setQuantile</code> method
      * @since 1.2
      */
-    public synchronized void setPercentileImpl(
-            UnivariateStatistic percentileImpl) {
+    public synchronized void setPercentileImpl(UnivariateStatistic percentileImpl)
+    throws MathIllegalArgumentException {
         try {
             percentileImpl.getClass().getMethod(SET_QUANTILE_METHOD_NAME,
                     new Class[] {Double.TYPE}).invoke(percentileImpl,
@@ -707,6 +720,7 @@ public class DescriptiveStatistics imple
      */
     public DescriptiveStatistics copy() {
         DescriptiveStatistics result = new DescriptiveStatistics();
+        // No try-catch or advertised exception because parms are guaranteed valid
         copy(this, result);
         return result;
     }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/MultivariateSummaryStatistics.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/MultivariateSummaryStatistics.java?rev=1382332&r1=1382331&r2=1382332&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/MultivariateSummaryStatistics.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/MultivariateSummaryStatistics.java Sat Sep  8 17:27:47 2012
@@ -145,7 +145,7 @@ public class MultivariateSummaryStatisti
      * @throws DimensionMismatchException if the length of the array
      * does not match the one used at construction
      */
-    public void addValue(double[] value) {
+    public void addValue(double[] value) throws DimensionMismatchException {
         checkDimension(value.length);
         for (int i = 0; i < k; ++i) {
             double v = value[i];
@@ -412,11 +412,12 @@ public class MultivariateSummaryStatisti
      * @param oldImpl old implementations for statistics
      * @throws DimensionMismatchException if the array dimension
      * does not match the one used at construction
-     * @throws IllegalStateException if data has already been added
-     *  (i.e if n > 0)
+     * @throws MathIllegalStateException if data has already been added
+     * (i.e. if n > 0)
      */
     private void setImpl(StorelessUnivariateStatistic[] newImpl,
-                         StorelessUnivariateStatistic[] oldImpl) {
+                         StorelessUnivariateStatistic[] oldImpl) throws MathIllegalStateException,
+                         DimensionMismatchException {
         checkEmpty();
         checkDimension(newImpl.length);
         System.arraycopy(newImpl, 0, oldImpl, 0, newImpl.length);
@@ -441,10 +442,11 @@ public class MultivariateSummaryStatisti
      * for computing the Sum
      * @throws DimensionMismatchException if the array dimension
      * does not match the one used at construction
-     * @throws IllegalStateException if data has already been added
+     * @throws MathIllegalStateException if data has already been added
      *  (i.e if n > 0)
      */
-    public void setSumImpl(StorelessUnivariateStatistic[] sumImpl) {
+    public void setSumImpl(StorelessUnivariateStatistic[] sumImpl)
+    throws MathIllegalStateException, DimensionMismatchException {
         setImpl(sumImpl, this.sumImpl);
     }
 
@@ -467,10 +469,11 @@ public class MultivariateSummaryStatisti
      * for computing the sum of squares
      * @throws DimensionMismatchException if the array dimension
      * does not match the one used at construction
-     * @throws IllegalStateException if data has already been added
+     * @throws MathIllegalStateException if data has already been added
      *  (i.e if n > 0)
      */
-    public void setSumsqImpl(StorelessUnivariateStatistic[] sumsqImpl) {
+    public void setSumsqImpl(StorelessUnivariateStatistic[] sumsqImpl)
+    throws MathIllegalStateException, DimensionMismatchException {
         setImpl(sumsqImpl, this.sumSqImpl);
     }
 
@@ -493,10 +496,11 @@ public class MultivariateSummaryStatisti
      * for computing the minimum
      * @throws DimensionMismatchException if the array dimension
      * does not match the one used at construction
-     * @throws IllegalStateException if data has already been added
+     * @throws MathIllegalStateException if data has already been added
      *  (i.e if n > 0)
      */
-    public void setMinImpl(StorelessUnivariateStatistic[] minImpl) {
+    public void setMinImpl(StorelessUnivariateStatistic[] minImpl)
+    throws MathIllegalStateException, DimensionMismatchException {
         setImpl(minImpl, this.minImpl);
     }
 
@@ -519,10 +523,11 @@ public class MultivariateSummaryStatisti
      * for computing the maximum
      * @throws DimensionMismatchException if the array dimension
      * does not match the one used at construction
-     * @throws IllegalStateException if data has already been added
+     * @throws MathIllegalStateException if data has already been added
      *  (i.e if n > 0)
      */
-    public void setMaxImpl(StorelessUnivariateStatistic[] maxImpl) {
+    public void setMaxImpl(StorelessUnivariateStatistic[] maxImpl)
+    throws MathIllegalStateException, DimensionMismatchException{
         setImpl(maxImpl, this.maxImpl);
     }
 
@@ -545,10 +550,11 @@ public class MultivariateSummaryStatisti
      * for computing the log sum
      * @throws DimensionMismatchException if the array dimension
      * does not match the one used at construction
-     * @throws IllegalStateException if data has already been added
+     * @throws MathIllegalStateException if data has already been added
      *  (i.e if n > 0)
      */
-    public void setSumLogImpl(StorelessUnivariateStatistic[] sumLogImpl) {
+    public void setSumLogImpl(StorelessUnivariateStatistic[] sumLogImpl)
+    throws MathIllegalStateException, DimensionMismatchException{
         setImpl(sumLogImpl, this.sumLogImpl);
     }
 
@@ -571,10 +577,11 @@ public class MultivariateSummaryStatisti
      * for computing the geometric mean
      * @throws DimensionMismatchException if the array dimension
      * does not match the one used at construction
-     * @throws IllegalStateException if data has already been added
+     * @throws MathIllegalStateException if data has already been added
      *  (i.e if n > 0)
      */
-    public void setGeoMeanImpl(StorelessUnivariateStatistic[] geoMeanImpl) {
+    public void setGeoMeanImpl(StorelessUnivariateStatistic[] geoMeanImpl)
+    throws MathIllegalStateException, DimensionMismatchException {
         setImpl(geoMeanImpl, this.geoMeanImpl);
     }
 
@@ -597,10 +604,11 @@ public class MultivariateSummaryStatisti
      * for computing the mean
      * @throws DimensionMismatchException if the array dimension
      * does not match the one used at construction
-     * @throws IllegalStateException if data has already been added
+     * @throws MathIllegalStateException if data has already been added
      *  (i.e if n > 0)
      */
-    public void setMeanImpl(StorelessUnivariateStatistic[] meanImpl) {
+    public void setMeanImpl(StorelessUnivariateStatistic[] meanImpl)
+    throws MathIllegalStateException, DimensionMismatchException{
         setImpl(meanImpl, this.meanImpl);
     }
 
@@ -608,7 +616,7 @@ public class MultivariateSummaryStatisti
      * Throws MathIllegalStateException if the statistic is not empty.
      * @throws MathIllegalStateException if n > 0.
      */
-    private void checkEmpty() {
+    private void checkEmpty() throws MathIllegalStateException {
         if (n > 0) {
             throw new MathIllegalStateException(
                     LocalizedFormats.VALUES_ADDED_BEFORE_CONFIGURING_STATISTIC, n);
@@ -620,7 +628,7 @@ public class MultivariateSummaryStatisti
      * @param dimension dimension to check
      * @throws DimensionMismatchException if dimension != k
      */
-    private void checkDimension(int dimension) {
+    private void checkDimension(int dimension) throws DimensionMismatchException {
         if (dimension != k) {
             throw new DimensionMismatchException(dimension, k);
         }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/StorelessUnivariateStatistic.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/StorelessUnivariateStatistic.java?rev=1382332&r1=1382331&r2=1382332&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/StorelessUnivariateStatistic.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/StorelessUnivariateStatistic.java Sat Sep  8 17:27:47 2012
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.math3.stat.descriptive;
 
+import org.apache.commons.math3.exception.MathIllegalArgumentException;
+
 /**
  * Extends the definition of {@link UnivariateStatistic} with
  * {@link #increment} and {@link #incrementAll(double[])} methods for adding
@@ -41,9 +43,9 @@ public interface StorelessUnivariateStat
      * i.e., the values are added <strong>incrementally</strong> to the dataset.
      *
      * @param values  array holding the new values to add
-     * @throws IllegalArgumentException if the array is null
+     * @throws MathIllegalArgumentException if the array is null
      */
-    void incrementAll(double[] values);
+    void incrementAll(double[] values) throws MathIllegalArgumentException;
 
     /**
      * Updates the internal state of the statistic to reflect addition of
@@ -54,9 +56,9 @@ public interface StorelessUnivariateStat
      * @param values  array holding the new values to add
      * @param start  the array index of the first value to add
      * @param length  the number of elements to add
-     * @throws IllegalArgumentException if the array is null or the index
+     * @throws MathIllegalArgumentException if the array is null or the index
      */
-    void incrementAll(double[] values, int start, int length);
+    void incrementAll(double[] values, int start, int length) throws MathIllegalArgumentException;
 
     /**
      * Returns the current value of the Statistic.

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/SummaryStatistics.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/SummaryStatistics.java?rev=1382332&r1=1382331&r2=1382332&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/SummaryStatistics.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/SummaryStatistics.java Sat Sep  8 17:27:47 2012
@@ -127,8 +127,9 @@ public class SummaryStatistics implement
      * A copy constructor. Creates a deep-copy of the {@code original}.
      *
      * @param original the {@code SummaryStatistics} instance to copy
+     * @throws NullArgumentException if original is null
      */
-    public SummaryStatistics(SummaryStatistics original) {
+    public SummaryStatistics(SummaryStatistics original) throws NullArgumentException {
         copy(original, this);
     }
 
@@ -423,11 +424,11 @@ public class SummaryStatistics implement
      * </p>
      * @param sumImpl the StorelessUnivariateStatistic instance to use for
      *        computing the Sum
-     * @throws IllegalStateException if data has already been added (i.e if n >
-     *         0)
+     * @throws MathIllegalStateException if data has already been added (i.e if n >0)
      * @since 1.2
      */
-    public void setSumImpl(StorelessUnivariateStatistic sumImpl) {
+    public void setSumImpl(StorelessUnivariateStatistic sumImpl)
+    throws MathIllegalStateException {
         checkEmpty();
         this.sumImpl = sumImpl;
     }
@@ -452,11 +453,11 @@ public class SummaryStatistics implement
      * </p>
      * @param sumsqImpl the StorelessUnivariateStatistic instance to use for
      *        computing the sum of squares
-     * @throws IllegalStateException if data has already been added (i.e if n >
-     *         0)
+     * @throws MathIllegalStateException if data has already been added (i.e if n > 0)
      * @since 1.2
      */
-    public void setSumsqImpl(StorelessUnivariateStatistic sumsqImpl) {
+    public void setSumsqImpl(StorelessUnivariateStatistic sumsqImpl)
+    throws MathIllegalStateException {
         checkEmpty();
         this.sumsqImpl = sumsqImpl;
     }
@@ -481,11 +482,11 @@ public class SummaryStatistics implement
      * </p>
      * @param minImpl the StorelessUnivariateStatistic instance to use for
      *        computing the minimum
-     * @throws IllegalStateException if data has already been added (i.e if n >
-     *         0)
+     * @throws MathIllegalStateException if data has already been added (i.e if n > 0)
      * @since 1.2
      */
-    public void setMinImpl(StorelessUnivariateStatistic minImpl) {
+    public void setMinImpl(StorelessUnivariateStatistic minImpl)
+    throws MathIllegalStateException {
         checkEmpty();
         this.minImpl = minImpl;
     }
@@ -510,11 +511,11 @@ public class SummaryStatistics implement
      * </p>
      * @param maxImpl the StorelessUnivariateStatistic instance to use for
      *        computing the maximum
-     * @throws IllegalStateException if data has already been added (i.e if n >
-     *         0)
+     * @throws MathIllegalStateException if data has already been added (i.e if n > 0)
      * @since 1.2
      */
-    public void setMaxImpl(StorelessUnivariateStatistic maxImpl) {
+    public void setMaxImpl(StorelessUnivariateStatistic maxImpl)
+    throws MathIllegalStateException {
         checkEmpty();
         this.maxImpl = maxImpl;
     }
@@ -539,11 +540,11 @@ public class SummaryStatistics implement
      * </p>
      * @param sumLogImpl the StorelessUnivariateStatistic instance to use for
      *        computing the log sum
-     * @throws IllegalStateException if data has already been added (i.e if n >
-     *         0)
+     * @throws MathIllegalStateException if data has already been added (i.e if n > 0)
      * @since 1.2
      */
-    public void setSumLogImpl(StorelessUnivariateStatistic sumLogImpl) {
+    public void setSumLogImpl(StorelessUnivariateStatistic sumLogImpl)
+    throws MathIllegalStateException {
         checkEmpty();
         this.sumLogImpl = sumLogImpl;
         geoMean.setSumLogImpl(sumLogImpl);
@@ -569,11 +570,11 @@ public class SummaryStatistics implement
      * </p>
      * @param geoMeanImpl the StorelessUnivariateStatistic instance to use for
      *        computing the geometric mean
-     * @throws IllegalStateException if data has already been added (i.e if n >
-     *         0)
+     * @throws MathIllegalStateException if data has already been added (i.e if n > 0)
      * @since 1.2
      */
-    public void setGeoMeanImpl(StorelessUnivariateStatistic geoMeanImpl) {
+    public void setGeoMeanImpl(StorelessUnivariateStatistic geoMeanImpl)
+    throws MathIllegalStateException {
         checkEmpty();
         this.geoMeanImpl = geoMeanImpl;
     }
@@ -598,11 +599,11 @@ public class SummaryStatistics implement
      * </p>
      * @param meanImpl the StorelessUnivariateStatistic instance to use for
      *        computing the mean
-     * @throws IllegalStateException if data has already been added (i.e if n >
-     *         0)
+     * @throws MathIllegalStateException if data has already been added (i.e if n > 0)
      * @since 1.2
      */
-    public void setMeanImpl(StorelessUnivariateStatistic meanImpl) {
+    public void setMeanImpl(StorelessUnivariateStatistic meanImpl)
+    throws MathIllegalStateException {
         checkEmpty();
         this.meanImpl = meanImpl;
     }
@@ -627,19 +628,20 @@ public class SummaryStatistics implement
      * </p>
      * @param varianceImpl the StorelessUnivariateStatistic instance to use for
      *        computing the variance
-     * @throws IllegalStateException if data has already been added (i.e if n >
-     *         0)
+     * @throws MathIllegalStateException if data has already been added (i.e if n > 0)
      * @since 1.2
      */
-    public void setVarianceImpl(StorelessUnivariateStatistic varianceImpl) {
+    public void setVarianceImpl(StorelessUnivariateStatistic varianceImpl)
+    throws MathIllegalStateException {
         checkEmpty();
         this.varianceImpl = varianceImpl;
     }
 
     /**
      * Throws IllegalStateException if n > 0.
+     * @throws MathIllegalStateException if data has been added
      */
-    private void checkEmpty() {
+    private void checkEmpty() throws MathIllegalStateException {
         if (n > 0) {
             throw new MathIllegalStateException(
                 LocalizedFormats.VALUES_ADDED_BEFORE_CONFIGURING_STATISTIC, n);
@@ -653,6 +655,7 @@ public class SummaryStatistics implement
      */
     public SummaryStatistics copy() {
         SummaryStatistics result = new SummaryStatistics();
+        // No try-catch or advertised exception because arguments are guaranteed non-null
         copy(this, result);
         return result;
     }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/SynchronizedDescriptiveStatistics.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/SynchronizedDescriptiveStatistics.java?rev=1382332&r1=1382331&r2=1382332&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/SynchronizedDescriptiveStatistics.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/SynchronizedDescriptiveStatistics.java Sat Sep  8 17:27:47 2012
@@ -16,6 +16,7 @@
  */
 package org.apache.commons.math3.stat.descriptive;
 
+import org.apache.commons.math3.exception.MathIllegalArgumentException;
 import org.apache.commons.math3.exception.NullArgumentException;
 import org.apache.commons.math3.util.MathUtils;
 
@@ -41,14 +42,17 @@ public class SynchronizedDescriptiveStat
      * Construct an instance with infinite window
      */
     public SynchronizedDescriptiveStatistics() {
+        // no try-catch or advertized IAE because arg is valid
         this(INFINITE_WINDOW);
     }
 
     /**
      * Construct an instance with finite window
      * @param window the finite window size.
+     * @throws MathIllegalArgumentException if window size is less than 1 but
+     * not equal to {@link #INFINITE_WINDOW}
      */
-    public SynchronizedDescriptiveStatistics(int window) {
+    public SynchronizedDescriptiveStatistics(int window) throws MathIllegalArgumentException {
         super(window);
     }
 
@@ -56,8 +60,10 @@ public class SynchronizedDescriptiveStat
      * A copy constructor. Creates a deep-copy of the {@code original}.
      *
      * @param original the {@code SynchronizedDescriptiveStatistics} instance to copy
+     * @throws NullArgumentException if original is null
      */
-    public SynchronizedDescriptiveStatistics(SynchronizedDescriptiveStatistics original) {
+    public SynchronizedDescriptiveStatistics(SynchronizedDescriptiveStatistics original)
+    throws NullArgumentException {
         copy(original, this);
     }
 
@@ -129,7 +135,7 @@ public class SynchronizedDescriptiveStat
      * {@inheritDoc}
      */
     @Override
-    public synchronized void setWindowSize(int windowSize) {
+    public synchronized void setWindowSize(int windowSize) throws MathIllegalArgumentException {
         super.setWindowSize(windowSize);
     }
 
@@ -151,6 +157,7 @@ public class SynchronizedDescriptiveStat
     public synchronized SynchronizedDescriptiveStatistics copy() {
         SynchronizedDescriptiveStatistics result =
             new SynchronizedDescriptiveStatistics();
+        // No try-catch or advertised exception because arguments are guaranteed non-null
         copy(this, result);
         return result;
     }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/SynchronizedMultivariateSummaryStatistics.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/SynchronizedMultivariateSummaryStatistics.java?rev=1382332&r1=1382331&r2=1382332&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/SynchronizedMultivariateSummaryStatistics.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/SynchronizedMultivariateSummaryStatistics.java Sat Sep  8 17:27:47 2012
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.math3.stat.descriptive;
 
+import org.apache.commons.math3.exception.DimensionMismatchException;
+import org.apache.commons.math3.exception.MathIllegalStateException;
 import org.apache.commons.math3.linear.RealMatrix;
 
 /**
@@ -51,7 +53,7 @@ public class SynchronizedMultivariateSum
      * {@inheritDoc}
      */
     @Override
-    public synchronized void addValue(double[] value) {
+    public synchronized void addValue(double[] value) throws DimensionMismatchException {
       super.addValue(value);
     }
 
@@ -187,7 +189,8 @@ public class SynchronizedMultivariateSum
      * {@inheritDoc}
      */
     @Override
-    public synchronized void setSumImpl(StorelessUnivariateStatistic[] sumImpl) {
+    public synchronized void setSumImpl(StorelessUnivariateStatistic[] sumImpl)
+    throws DimensionMismatchException, MathIllegalStateException {
         super.setSumImpl(sumImpl);
     }
 
@@ -203,7 +206,8 @@ public class SynchronizedMultivariateSum
      * {@inheritDoc}
      */
     @Override
-    public synchronized void setSumsqImpl(StorelessUnivariateStatistic[] sumsqImpl) {
+    public synchronized void setSumsqImpl(StorelessUnivariateStatistic[] sumsqImpl)
+    throws DimensionMismatchException, MathIllegalStateException {
         super.setSumsqImpl(sumsqImpl);
     }
 
@@ -219,7 +223,8 @@ public class SynchronizedMultivariateSum
      * {@inheritDoc}
      */
     @Override
-    public synchronized void setMinImpl(StorelessUnivariateStatistic[] minImpl) {
+    public synchronized void setMinImpl(StorelessUnivariateStatistic[] minImpl)
+    throws DimensionMismatchException, MathIllegalStateException {
         super.setMinImpl(minImpl);
     }
 
@@ -235,7 +240,8 @@ public class SynchronizedMultivariateSum
      * {@inheritDoc}
      */
     @Override
-    public synchronized void setMaxImpl(StorelessUnivariateStatistic[] maxImpl) {
+    public synchronized void setMaxImpl(StorelessUnivariateStatistic[] maxImpl)
+    throws DimensionMismatchException, MathIllegalStateException{
         super.setMaxImpl(maxImpl);
     }
 
@@ -251,7 +257,8 @@ public class SynchronizedMultivariateSum
      * {@inheritDoc}
      */
     @Override
-    public synchronized void setSumLogImpl(StorelessUnivariateStatistic[] sumLogImpl) {
+    public synchronized void setSumLogImpl(StorelessUnivariateStatistic[] sumLogImpl)
+    throws DimensionMismatchException, MathIllegalStateException {
         super.setSumLogImpl(sumLogImpl);
     }
 
@@ -267,7 +274,8 @@ public class SynchronizedMultivariateSum
      * {@inheritDoc}
      */
     @Override
-    public synchronized void setGeoMeanImpl(StorelessUnivariateStatistic[] geoMeanImpl) {
+    public synchronized void setGeoMeanImpl(StorelessUnivariateStatistic[] geoMeanImpl)
+    throws DimensionMismatchException, MathIllegalStateException {
         super.setGeoMeanImpl(geoMeanImpl);
     }
 
@@ -283,7 +291,8 @@ public class SynchronizedMultivariateSum
      * {@inheritDoc}
      */
     @Override
-    public synchronized void setMeanImpl(StorelessUnivariateStatistic[] meanImpl) {
+    public synchronized void setMeanImpl(StorelessUnivariateStatistic[] meanImpl)
+    throws DimensionMismatchException, MathIllegalStateException {
         super.setMeanImpl(meanImpl);
     }
 }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/SynchronizedSummaryStatistics.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/SynchronizedSummaryStatistics.java?rev=1382332&r1=1382331&r2=1382332&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/SynchronizedSummaryStatistics.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/SynchronizedSummaryStatistics.java Sat Sep  8 17:27:47 2012
@@ -16,6 +16,7 @@
  */
 package org.apache.commons.math3.stat.descriptive;
 
+import org.apache.commons.math3.exception.MathIllegalStateException;
 import org.apache.commons.math3.exception.NullArgumentException;
 import org.apache.commons.math3.util.MathUtils;
 
@@ -48,8 +49,10 @@ public class SynchronizedSummaryStatisti
      * A copy constructor. Creates a deep-copy of the {@code original}.
      *
      * @param original the {@code SynchronizedSummaryStatistics} instance to copy
+     * @throws NullArgumentException if original is null
      */
-    public SynchronizedSummaryStatistics(SynchronizedSummaryStatistics original) {
+    public SynchronizedSummaryStatistics(SynchronizedSummaryStatistics original)
+    throws NullArgumentException {
         copy(original, this);
     }
 
@@ -193,7 +196,8 @@ public class SynchronizedSummaryStatisti
      * {@inheritDoc}
      */
     @Override
-    public synchronized void setSumImpl(StorelessUnivariateStatistic sumImpl) {
+    public synchronized void setSumImpl(StorelessUnivariateStatistic sumImpl)
+    throws MathIllegalStateException {
         super.setSumImpl(sumImpl);
     }
 
@@ -209,7 +213,8 @@ public class SynchronizedSummaryStatisti
      * {@inheritDoc}
      */
     @Override
-    public synchronized void setSumsqImpl(StorelessUnivariateStatistic sumsqImpl) {
+    public synchronized void setSumsqImpl(StorelessUnivariateStatistic sumsqImpl)
+    throws MathIllegalStateException {
         super.setSumsqImpl(sumsqImpl);
     }
 
@@ -225,7 +230,8 @@ public class SynchronizedSummaryStatisti
      * {@inheritDoc}
      */
     @Override
-    public synchronized void setMinImpl(StorelessUnivariateStatistic minImpl) {
+    public synchronized void setMinImpl(StorelessUnivariateStatistic minImpl)
+    throws MathIllegalStateException {
         super.setMinImpl(minImpl);
     }
 
@@ -241,7 +247,8 @@ public class SynchronizedSummaryStatisti
      * {@inheritDoc}
      */
     @Override
-    public synchronized void setMaxImpl(StorelessUnivariateStatistic maxImpl) {
+    public synchronized void setMaxImpl(StorelessUnivariateStatistic maxImpl)
+    throws MathIllegalStateException {
         super.setMaxImpl(maxImpl);
     }
 
@@ -257,7 +264,8 @@ public class SynchronizedSummaryStatisti
      * {@inheritDoc}
      */
     @Override
-    public synchronized void setSumLogImpl(StorelessUnivariateStatistic sumLogImpl) {
+    public synchronized void setSumLogImpl(StorelessUnivariateStatistic sumLogImpl)
+    throws MathIllegalStateException {
         super.setSumLogImpl(sumLogImpl);
     }
 
@@ -273,7 +281,8 @@ public class SynchronizedSummaryStatisti
      * {@inheritDoc}
      */
     @Override
-    public synchronized void setGeoMeanImpl(StorelessUnivariateStatistic geoMeanImpl) {
+    public synchronized void setGeoMeanImpl(StorelessUnivariateStatistic geoMeanImpl)
+    throws MathIllegalStateException {
         super.setGeoMeanImpl(geoMeanImpl);
     }
 
@@ -289,7 +298,8 @@ public class SynchronizedSummaryStatisti
      * {@inheritDoc}
      */
     @Override
-    public synchronized void setMeanImpl(StorelessUnivariateStatistic meanImpl) {
+    public synchronized void setMeanImpl(StorelessUnivariateStatistic meanImpl)
+    throws MathIllegalStateException {
         super.setMeanImpl(meanImpl);
     }
 
@@ -305,7 +315,8 @@ public class SynchronizedSummaryStatisti
      * {@inheritDoc}
      */
     @Override
-    public synchronized void setVarianceImpl(StorelessUnivariateStatistic varianceImpl) {
+    public synchronized void setVarianceImpl(StorelessUnivariateStatistic varianceImpl)
+    throws MathIllegalStateException {
         super.setVarianceImpl(varianceImpl);
     }
 
@@ -319,6 +330,7 @@ public class SynchronizedSummaryStatisti
     public synchronized SynchronizedSummaryStatistics copy() {
         SynchronizedSummaryStatistics result =
             new SynchronizedSummaryStatistics();
+        // No try-catch or advertised exception because arguments are guaranteed non-null
         copy(this, result);
         return result;
     }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/UnivariateStatistic.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/UnivariateStatistic.java?rev=1382332&r1=1382331&r2=1382332&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/UnivariateStatistic.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/UnivariateStatistic.java Sat Sep  8 17:27:47 2012
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.math3.stat.descriptive;
 
+import org.apache.commons.math3.exception.MathIllegalArgumentException;
+
 
 /**
  * Base interface implemented by all statistics.
@@ -29,8 +31,9 @@ public interface UnivariateStatistic {
      *
      * @param values input array
      * @return the value of the statistic applied to the input array
+     * @throws MathIllegalArgumentException  if values is null
      */
-    double evaluate(double[] values);
+    double evaluate(double[] values) throws MathIllegalArgumentException;
 
     /**
      * Returns the result of evaluating the statistic over the specified entries
@@ -40,8 +43,9 @@ public interface UnivariateStatistic {
      * @param begin the index of the first element to include
      * @param length the number of elements to include
      * @return the value of the statistic applied to the included array entries
+     * @throws MathIllegalArgumentException if values is null or the indices are invalid
      */
-    double evaluate(double[] values, int begin, int length);
+    double evaluate(double[] values, int begin, int length) throws MathIllegalArgumentException;
 
     /**
      * Returns a copy of the statistic with the same internal state.

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/WeightedEvaluation.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/WeightedEvaluation.java?rev=1382332&r1=1382331&r2=1382332&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/WeightedEvaluation.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/WeightedEvaluation.java Sat Sep  8 17:27:47 2012
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.math3.stat.descriptive;
 
+import org.apache.commons.math3.exception.MathIllegalArgumentException;
+
 /**
  * Weighted evaluation for statistics.
  *
@@ -31,8 +33,11 @@ public interface WeightedEvaluation {
      * @param values input array
      * @param weights array of weights
      * @return the value of the weighted statistic applied to the input array
+     * @throws MathIllegalArgumentException if either array is null, lengths
+     * do not match, weights contain NaN, negative or infinite values, or
+     * weights does not include at least on positive value
      */
-    double evaluate(double[] values, double[] weights);
+    double evaluate(double[] values, double[] weights) throws MathIllegalArgumentException;
 
     /**
      * Returns the result of evaluating the statistic over the specified entries
@@ -43,7 +48,11 @@ public interface WeightedEvaluation {
      * @param begin the index of the first element to include
      * @param length the number of elements to include
      * @return the value of the weighted statistic applied to the included array entries
+     * @throws MathIllegalArgumentException if either array is null, lengths
+     * do not match, indices are invalid, weights contain NaN, negative or
+     * infinite values, or weights does not include at least on positive value
      */
-    double evaluate(double[] values, double[] weights, int begin, int length);
+    double evaluate(double[] values, double[] weights, int begin, int length)
+    throws MathIllegalArgumentException;
 
 }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/FirstMoment.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/FirstMoment.java?rev=1382332&r1=1382331&r2=1382332&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/FirstMoment.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/FirstMoment.java Sat Sep  8 17:27:47 2012
@@ -88,8 +88,9 @@ class FirstMoment extends AbstractStorel
      * to the {@code original}
      *
      * @param original the {@code FirstMoment} instance to copy
+     * @throws NullArgumentException if original is null
      */
-     public FirstMoment(FirstMoment original) {
+     public FirstMoment(FirstMoment original) throws NullArgumentException {
          super();
          copy(original, this);
      }
@@ -141,6 +142,7 @@ class FirstMoment extends AbstractStorel
     @Override
     public FirstMoment copy() {
         FirstMoment result = new FirstMoment();
+        // No try-catch or advertised exception because args are guaranteed non-null
         copy(this, result);
         return result;
     }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/FourthMoment.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/FourthMoment.java?rev=1382332&r1=1382331&r2=1382332&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/FourthMoment.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/FourthMoment.java Sat Sep  8 17:27:47 2012
@@ -74,8 +74,9 @@ class FourthMoment extends ThirdMoment i
      * to the {@code original}
      *
      * @param original the {@code FourthMoment} instance to copy
+     * @throws NullArgumentException if original is null
      */
-     public FourthMoment(FourthMoment original) {
+     public FourthMoment(FourthMoment original) throws NullArgumentException {
          super();
          copy(original, this);
      }
@@ -126,6 +127,7 @@ class FourthMoment extends ThirdMoment i
     @Override
     public FourthMoment copy() {
         FourthMoment result = new FourthMoment();
+        // No try-catch or advertised exception because args are guaranteed non-null
         copy(this, result);
         return result;
     }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/GeometricMean.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/GeometricMean.java?rev=1382332&r1=1382331&r2=1382332&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/GeometricMean.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/GeometricMean.java Sat Sep  8 17:27:47 2012
@@ -18,6 +18,7 @@ package org.apache.commons.math3.stat.de
 
 import java.io.Serializable;
 
+import org.apache.commons.math3.exception.MathIllegalArgumentException;
 import org.apache.commons.math3.exception.MathIllegalStateException;
 import org.apache.commons.math3.exception.NullArgumentException;
 import org.apache.commons.math3.exception.util.LocalizedFormats;
@@ -71,8 +72,9 @@ public class GeometricMean extends Abstr
      * to the {@code original}
      *
      * @param original the {@code GeometricMean} instance to copy
+     * @throws NullArgumentException if original is null
      */
-    public GeometricMean(GeometricMean original) {
+    public GeometricMean(GeometricMean original) throws NullArgumentException {
         super();
         copy(original, this);
     }
@@ -91,6 +93,7 @@ public class GeometricMean extends Abstr
     @Override
     public GeometricMean copy() {
         GeometricMean result = new GeometricMean();
+        // no try-catch or advertised exception because args guaranteed non-null
         copy(this, result);
         return result;
     }
@@ -136,12 +139,13 @@ public class GeometricMean extends Abstr
      * @param length the number of elements to include
      * @return the geometric mean or Double.NaN if length = 0 or
      * any of the values are &lt;= 0.
-     * @throws IllegalArgumentException if the input array is null or the array
+     * @throws MathIllegalArgumentException if the input array is null or the array
      * index parameters are not valid
      */
     @Override
     public double evaluate(
-        final double[] values, final int begin, final int length) {
+        final double[] values, final int begin, final int length)
+    throws MathIllegalArgumentException {
         return FastMath.exp(
             sumOfLogs.evaluate(values, begin, length) / length);
     }
@@ -161,11 +165,11 @@ public class GeometricMean extends Abstr
      *
      * @param sumLogImpl the StorelessUnivariateStatistic instance to use
      * for computing the log sum
-     * @throws IllegalStateException if data has already been added
+     * @throws MathIllegalStateException if data has already been added
      *  (i.e if n > 0)
      */
-    public void setSumLogImpl(
-            StorelessUnivariateStatistic sumLogImpl) {
+    public void setSumLogImpl(StorelessUnivariateStatistic sumLogImpl)
+    throws MathIllegalStateException {
         checkEmpty();
         this.sumOfLogs = sumLogImpl;
     }
@@ -197,9 +201,10 @@ public class GeometricMean extends Abstr
 
 
     /**
-     * Throws IllegalStateException if n > 0.
+     * Throws MathIllegalStateException if n > 0.
+     * @throws MathIllegalStateException if data has been added to this statistic
      */
-    private void checkEmpty() {
+    private void checkEmpty() throws MathIllegalStateException {
         if (getN() > 0) {
             throw new MathIllegalStateException(
                     LocalizedFormats.VALUES_ADDED_BEFORE_CONFIGURING_STATISTIC,

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/Kurtosis.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/Kurtosis.java?rev=1382332&r1=1382331&r2=1382332&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/Kurtosis.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/Kurtosis.java Sat Sep  8 17:27:47 2012
@@ -18,9 +18,8 @@ package org.apache.commons.math3.stat.de
 
 import java.io.Serializable;
 
-import org.apache.commons.math3.exception.MathIllegalStateException;
+import org.apache.commons.math3.exception.MathIllegalArgumentException;
 import org.apache.commons.math3.exception.NullArgumentException;
-import org.apache.commons.math3.exception.util.LocalizedFormats;
 import org.apache.commons.math3.stat.descriptive.AbstractStorelessUnivariateStatistic;
 import org.apache.commons.math3.util.FastMath;
 import org.apache.commons.math3.util.MathUtils;
@@ -85,20 +84,22 @@ public class Kurtosis extends AbstractSt
      * to the {@code original}
      *
      * @param original the {@code Kurtosis} instance to copy
+     * @throws NullArgumentException if original is null
      */
-    public Kurtosis(Kurtosis original) {
+    public Kurtosis(Kurtosis original) throws NullArgumentException {
         copy(original, this);
     }
 
     /**
      * {@inheritDoc}
+     * <p>Note that when {@link #Kurtosis(FourthMoment)} is used to
+     * create a Variance, this method does nothing. In that case, the
+     * FourthMoment should be incremented directly.</p>
      */
     @Override
     public void increment(final double d) {
         if (incMoment) {
             moment.increment(d);
-        }  else  {
-            throw new MathIllegalStateException(LocalizedFormats.CANNOT_INCREMENT_STATISTIC_CONSTRUCTED_FROM_EXTERNAL_MOMENTS);
         }
     }
 
@@ -130,8 +131,6 @@ public class Kurtosis extends AbstractSt
     public void clear() {
         if (incMoment) {
             moment.clear();
-        } else  {
-            throw new MathIllegalStateException(LocalizedFormats.CANNOT_CLEAR_STATISTIC_CONSTRUCTED_FROM_EXTERNAL_MOMENTS);
         }
     }
 
@@ -155,13 +154,13 @@ public class Kurtosis extends AbstractSt
      * @param values the input array
      * @param begin index of the first array element to include
      * @param length the number of elements to include
-     * @return the kurtosis of the values or Double.NaN if length is less than
-     * 4
-     * @throws IllegalArgumentException if the input array is null or the array
+     * @return the kurtosis of the values or Double.NaN if length is less than 4
+     * @throws MathIllegalArgumentException if the input array is null or the array
      * index parameters are not valid
      */
     @Override
-    public double evaluate(final double[] values,final int begin, final int length) {
+    public double evaluate(final double[] values,final int begin, final int length)
+    throws MathIllegalArgumentException {
         // Initialize the kurtosis
         double kurt = Double.NaN;
 
@@ -201,6 +200,7 @@ public class Kurtosis extends AbstractSt
     @Override
     public Kurtosis copy() {
         Kurtosis result = new Kurtosis();
+        // No try-catch because args are guaranteed non-null
         copy(this, result);
         return result;
     }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/Mean.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/Mean.java?rev=1382332&r1=1382331&r2=1382332&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/Mean.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/Mean.java Sat Sep  8 17:27:47 2012
@@ -18,6 +18,7 @@ package org.apache.commons.math3.stat.de
 
 import java.io.Serializable;
 
+import org.apache.commons.math3.exception.MathIllegalArgumentException;
 import org.apache.commons.math3.exception.NullArgumentException;
 import org.apache.commons.math3.stat.descriptive.AbstractStorelessUnivariateStatistic;
 import org.apache.commons.math3.stat.descriptive.WeightedEvaluation;
@@ -96,13 +97,17 @@ public class Mean extends AbstractStorel
      * to the {@code original}
      *
      * @param original the {@code Mean} instance to copy
+     * @throws NullArgumentException if original is null
      */
-    public Mean(Mean original) {
+    public Mean(Mean original) throws NullArgumentException {
         copy(original, this);
     }
 
     /**
      * {@inheritDoc}
+     * <p>Note that when {@link #Mean(FirstMoment)} is used to
+     * create a Mean, this method does nothing. In that case, the
+     * FirstMoment should be incremented directly.</p>
      */
     @Override
     public void increment(final double d) {
@@ -149,11 +154,12 @@ public class Mean extends AbstractStorel
      * @param begin index of the first array element to include
      * @param length the number of elements to include
      * @return the mean of the values or Double.NaN if length = 0
-     * @throws IllegalArgumentException if the array is null or the array index
+     * @throws MathIllegalArgumentException if the array is null or the array index
      *  parameters are not valid
      */
     @Override
-    public double evaluate(final double[] values,final int begin, final int length) {
+    public double evaluate(final double[] values,final int begin, final int length)
+    throws MathIllegalArgumentException {
         if (test(values, begin, length)) {
             Sum sum = new Sum();
             double sampleSize = length;
@@ -197,11 +203,11 @@ public class Mean extends AbstractStorel
      * @param begin index of the first array element to include
      * @param length the number of elements to include
      * @return the mean of the values or Double.NaN if length = 0
-     * @throws IllegalArgumentException if the parameters are not valid
+     * @throws MathIllegalArgumentException if the parameters are not valid
      * @since 2.1
      */
     public double evaluate(final double[] values, final double[] weights,
-                           final int begin, final int length) {
+                           final int begin, final int length) throws MathIllegalArgumentException {
         if (test(values, weights, begin, length)) {
             Sum sum = new Sum();
 
@@ -222,13 +228,13 @@ public class Mean extends AbstractStorel
     /**
      * Returns the weighted arithmetic mean of the entries in the input array.
      * <p>
-     * Throws <code>IllegalArgumentException</code> if either array is null.</p>
+     * Throws <code>MathIllegalArgumentException</code> if either array is null.</p>
      * <p>
      * See {@link Mean} for details on the computing algorithm. The two-pass algorithm
      * described above is used here, with weights applied in computing both the original
      * estimate and the correction factor.</p>
      * <p>
-     * Throws <code>IllegalArgumentException</code> if any of the following are true:
+     * Throws <code>MathIllegalArgumentException</code> if any of the following are true:
      * <ul><li>the values array is null</li>
      *     <li>the weights array is null</li>
      *     <li>the weights array does not have the same length as the values array</li>
@@ -240,10 +246,11 @@ public class Mean extends AbstractStorel
      * @param values the input array
      * @param weights the weights array
      * @return the mean of the values or Double.NaN if length = 0
-     * @throws IllegalArgumentException if the parameters are not valid
+     * @throws MathIllegalArgumentException if the parameters are not valid
      * @since 2.1
      */
-    public double evaluate(final double[] values, final double[] weights) {
+    public double evaluate(final double[] values, final double[] weights)
+    throws MathIllegalArgumentException {
         return evaluate(values, weights, 0, values.length);
     }
 
@@ -253,6 +260,7 @@ public class Mean extends AbstractStorel
     @Override
     public Mean copy() {
         Mean result = new Mean();
+        // No try-catch or advertised exception because args are guaranteed non-null
         copy(this, result);
         return result;
     }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/SecondMoment.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/SecondMoment.java?rev=1382332&r1=1382331&r2=1382332&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/SecondMoment.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/SecondMoment.java Sat Sep  8 17:27:47 2012
@@ -66,8 +66,10 @@ public class SecondMoment extends FirstM
      * to the {@code original}
      *
      * @param original the {@code SecondMoment} instance to copy
+     * @throws NullArgumentException if original is null
      */
-    public SecondMoment(SecondMoment original) {
+    public SecondMoment(SecondMoment original)
+    throws NullArgumentException {
         super(original);
         this.m2 = original.m2;
     }
@@ -107,6 +109,7 @@ public class SecondMoment extends FirstM
     @Override
     public SecondMoment copy() {
         SecondMoment result = new SecondMoment();
+        // no try-catch or advertised NAE because args are guaranteed non-null
         copy(this, result);
         return result;
     }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/SemiVariance.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/SemiVariance.java?rev=1382332&r1=1382331&r2=1382332&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/SemiVariance.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/SemiVariance.java Sat Sep  8 17:27:47 2012
@@ -18,8 +18,9 @@
 package org.apache.commons.math3.stat.descriptive.moment;
 
 import java.io.Serializable;
+
+import org.apache.commons.math3.exception.MathIllegalArgumentException;
 import org.apache.commons.math3.exception.NullArgumentException;
-import org.apache.commons.math3.exception.util.LocalizedFormats;
 import org.apache.commons.math3.stat.descriptive.AbstractUnivariateStatistic;
 import org.apache.commons.math3.util.MathUtils;
 
@@ -133,8 +134,9 @@ public class SemiVariance extends Abstra
      * to the {@code original}
      *
      * @param original the {@code SemiVariance} instance to copy
+     * @throws NullArgumentException  if original is null
      */
-    public SemiVariance(final SemiVariance original) {
+    public SemiVariance(final SemiVariance original) throws NullArgumentException {
         copy(original, this);
     }
 
@@ -145,6 +147,7 @@ public class SemiVariance extends Abstra
     @Override
     public SemiVariance copy() {
         SemiVariance result = new SemiVariance();
+        // No try-catch or advertised exception because args are guaranteed non-null
         copy(this, result);
         return result;
     }
@@ -167,25 +170,6 @@ public class SemiVariance extends Abstra
         dest.varianceDirection = source.varianceDirection;
     }
 
-
-    /**
-     * This method calculates {@link SemiVariance} for the entire array against the mean, using
-     * instance properties varianceDirection and biasCorrection.
-     *
-     * @param values the input array
-     * @return the SemiVariance
-     * @throws IllegalArgumentException if values is null
-     *
-     */
-    @Override
-    public double evaluate(final double[] values) {
-        if (values == null) {
-            throw new NullArgumentException(LocalizedFormats.INPUT_ARRAY);
-         }
-        return evaluate(values, 0, values.length);
-    }
-
-
     /**
       * <p>Returns the {@link SemiVariance} of the designated values against the mean, using
       * instance properties varianceDirection and biasCorrection.</p>
@@ -197,11 +181,12 @@ public class SemiVariance extends Abstra
       * @param start index of the first array element to include
       * @param length the number of elements to include
       * @return the SemiVariance
-      * @throws IllegalArgumentException if the parameters are not valid
+      * @throws MathIllegalArgumentException if the parameters are not valid
       *
       */
       @Override
-      public double evaluate(final double[] values, final int start, final int length) {
+      public double evaluate(final double[] values, final int start, final int length)
+      throws MathIllegalArgumentException {
         double m = (new Mean()).evaluate(values, start, length);
         return evaluate(values, m, varianceDirection, biasCorrected, 0, values.length);
       }
@@ -214,10 +199,11 @@ public class SemiVariance extends Abstra
        * @param values the input array
        * @param direction the {@link Direction} of the semivariance
        * @return the SemiVariance
-       * @throws IllegalArgumentException if values is null
+       * @throws MathIllegalArgumentException if values is null
        *
        */
-      public double evaluate(final double[] values, Direction direction) {
+      public double evaluate(final double[] values, Direction direction)
+      throws MathIllegalArgumentException {
           double m = (new Mean()).evaluate(values);
           return evaluate (values, m, direction, biasCorrected, 0, values.length);
       }
@@ -270,11 +256,11 @@ public class SemiVariance extends Abstra
       * @param start index of the first array element to include
       * @param length the number of elements to include
       * @return the SemiVariance
-      * @throws IllegalArgumentException if the parameters are not valid
+      * @throws MathIllegalArgumentException if the parameters are not valid
       *
       */
     public double evaluate (final double[] values, final double cutoff, final Direction direction,
-            final boolean corrected, final int start, final int length) {
+            final boolean corrected, final int start, final int length) throws MathIllegalArgumentException {
 
         test(values, start, length);
         if (values.length == 0) {