commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject [1/3] [math] [MATH-1205] Major refactoring of the descriptive statistics package.
Date Mon, 13 Apr 2015 20:16:25 GMT
Repository: commons-math
Updated Branches:
  refs/heads/master e588c8f2e -> 0a799598c


http://git-wip-us.apache.org/repos/asf/commons-math/blob/845e1d54/src/main/java/org/apache/commons/math4/stat/descriptive/rank/PSquarePercentile.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/stat/descriptive/rank/PSquarePercentile.java b/src/main/java/org/apache/commons/math4/stat/descriptive/rank/PSquarePercentile.java
index 2e1e27b..097b8fd 100644
--- a/src/main/java/org/apache/commons/math4/stat/descriptive/rank/PSquarePercentile.java
+++ b/src/main/java/org/apache/commons/math4/stat/descriptive/rank/PSquarePercentile.java
@@ -70,20 +70,18 @@ public class PSquarePercentile extends AbstractStorelessUnivariateStatistic
     /**
      * Serial ID
      */
-    private static final long serialVersionUID = 2283912083175715479L;
+    private static final long serialVersionUID = 20150412L;
 
     /**
      * A decimal formatter for print convenience
      */
-    private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat(
-            "00.00");
+    private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("00.00");
 
     /**
      * Initial list of 5 numbers corresponding to 5 markers. <b>NOTE:</b>watch
      * out for the add methods that are overloaded
      */
-    private final List<Double> initialFive = new FixedCapacityList<Double>(
-            PSQUARE_CONSTANT);
+    private final List<Double> initialFive = new FixedCapacityList<Double>(PSQUARE_CONSTANT);
 
     /**
      * The quantile needed should be in range of 0-1. The constructor
@@ -122,15 +120,14 @@ public class PSquarePercentile extends AbstractStorelessUnivariateStatistic
      */
     public PSquarePercentile(final double p) {
         if (p > 100 || p < 0) {
-            throw new OutOfRangeException(LocalizedFormats.OUT_OF_RANGE,
-                    p, 0, 100);
+            throw new OutOfRangeException(LocalizedFormats.OUT_OF_RANGE, p, 0, 100);
         }
         this.quantile = p / 100d;// always set it within (0,1]
     }
 
     /**
      * Default constructor that assumes a {@link #DEFAULT_QUANTILE_DESIRED
-     * default quantile} needed
+     * default quantile} needed.
      */
     PSquarePercentile() {
         this(DEFAULT_QUANTILE_DESIRED);
@@ -540,13 +537,10 @@ public class PSquarePercentile extends AbstractStorelessUnivariateStatistic
             anInputStream.defaultReadObject();
             // Build links
             for (int i = 1; i < PSQUARE_CONSTANT; i++) {
-                markerArray[i].previous(markerArray[i - 1])
-                        .next(markerArray[i + 1]).index(i);
+                markerArray[i].previous(markerArray[i - 1]).next(markerArray[i + 1]).index(i);
             }
-            markerArray[0].previous(markerArray[0]).next(markerArray[1])
-                    .index(0);
-            markerArray[5].previous(markerArray[4]).next(markerArray[5])
-                    .index(5);
+            markerArray[0].previous(markerArray[0]).next(markerArray[1]).index(0);
+            markerArray[5].previous(markerArray[4]).next(markerArray[5]).index(5);
         }
 
         /**
@@ -558,8 +552,7 @@ public class PSquarePercentile extends AbstractStorelessUnivariateStatistic
         @Override
         public double height(final int markerIndex) {
             if (markerIndex >= markerArray.length || markerIndex <= 0) {
-                throw new OutOfRangeException(markerIndex, 1,
-                        markerArray.length);
+                throw new OutOfRangeException(markerIndex, 1, markerArray.length);
             }
             return markerArray[markerIndex].markerHeight;
         }
@@ -649,14 +642,12 @@ public class PSquarePercentile extends AbstractStorelessUnivariateStatistic
         /**
          * Nonlinear interpolator
          */
-        private final UnivariateInterpolator nonLinear =
-                new NevilleInterpolator();
+        private final UnivariateInterpolator nonLinear = new NevilleInterpolator();
 
         /**
          * Linear interpolator which is not serializable
          */
-        private transient UnivariateInterpolator linear =
-                new LinearInterpolator();
+        private transient UnivariateInterpolator linear = new LinearInterpolator();
 
         /**
          * Default constructor
@@ -861,8 +852,7 @@ public class PSquarePercentile extends AbstractStorelessUnivariateStatistic
          */
         @Override
         public Object clone() {
-            return new Marker(markerHeight, desiredMarkerPosition,
-                    desiredMarkerIncrement, intMarkerPosition);
+            return new Marker(markerHeight, desiredMarkerPosition, desiredMarkerIncrement, intMarkerPosition);
         }
 
         /**
@@ -887,8 +877,8 @@ public class PSquarePercentile extends AbstractStorelessUnivariateStatistic
      *
      * @param <E>
      */
-    private static class FixedCapacityList<E> extends ArrayList<E> implements
-            Serializable {
+    private static class FixedCapacityList<E> extends ArrayList<E> implements Serializable {
+
         /**
          * Serialization Version Id
          */
@@ -945,8 +935,7 @@ public class PSquarePercentile extends AbstractStorelessUnivariateStatistic
      * @param p the quantile desired
      * @return an instance of PSquareMarkers
      */
-    public static PSquareMarkers newMarkers(final List<Double> initialFive,
-            final double p) {
+    public static PSquareMarkers newMarkers(final List<Double> initialFive, final double p) {
         return new Markers(initialFive, p);
     }
 

http://git-wip-us.apache.org/repos/asf/commons-math/blob/845e1d54/src/main/java/org/apache/commons/math4/stat/descriptive/rank/Percentile.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/stat/descriptive/rank/Percentile.java b/src/main/java/org/apache/commons/math4/stat/descriptive/rank/Percentile.java
index 3b6f065..f820437 100644
--- a/src/main/java/org/apache/commons/math4/stat/descriptive/rank/Percentile.java
+++ b/src/main/java/org/apache/commons/math4/stat/descriptive/rank/Percentile.java
@@ -90,12 +90,11 @@ import org.apache.commons.math4.util.Precision;
  * multiple threads access an instance of this class concurrently, and at least
  * one of the threads invokes the <code>increment()</code> or
  * <code>clear()</code> method, it must be synchronized externally.</p>
- *
  */
 public class Percentile extends AbstractUnivariateStatistic implements Serializable {
 
     /** Serializable version identifier */
-    private static final long serialVersionUID = -8091216485095130416L;
+    private static final long serialVersionUID = 20150412L;
 
     /** Maximum number of partitioning pivots cached (each level double the number of pivots). */
     private static final int MAX_CACHED_LEVELS = 10;
@@ -112,8 +111,10 @@ public class Percentile extends AbstractUnivariateStatistic implements Serializa
     /** NaN Handling of the input as defined by {@link NaNStrategy} */
     private final NaNStrategy nanStrategy;
 
-    /** Determines what percentile is computed when evaluate() is activated
-     * with no quantile argument */
+    /**
+     * Determines what percentile is computed when evaluate() is activated
+     * with no quantile argument.
+     */
     private double quantile;
 
     /** Cached pivots. */
@@ -263,12 +264,12 @@ public class Percentile extends AbstractUnivariateStatistic implements Serializa
      * @param values input array of values
      * @param p the percentile value to compute
      * @return the percentile value or Double.NaN if the array is empty
-     * @throws MathIllegalArgumentException if <code>values</code> is null
-     *     or p is invalid
+     * @throws MathIllegalArgumentException if <code>values</code> is null or p is invalid
      */
     public double evaluate(final double[] values, final double p)
-    throws MathIllegalArgumentException {
-        test(values, 0, 0);
+        throws MathIllegalArgumentException {
+
+        MathArrays.verifyValues(values, 0, 0);
         return evaluate(values, 0, values.length, p);
     }
 
@@ -297,7 +298,7 @@ public class Percentile extends AbstractUnivariateStatistic implements Serializa
      */
     @Override
     public double evaluate(final double[] values, final int start, final int length)
-    throws MathIllegalArgumentException {
+        throws MathIllegalArgumentException {
         return evaluate(values, start, length, quantile);
     }
 
@@ -335,10 +336,9 @@ public class Percentile extends AbstractUnivariateStatistic implements Serializa
                            final int length, final double p)
         throws MathIllegalArgumentException {
 
-        test(values, begin, length);
+        MathArrays.verifyValues(values, begin, length);
         if (p > 100 || p <= 0) {
-            throw new OutOfRangeException(
-                    LocalizedFormats.OUT_OF_BOUNDS_QUANTILE_VALUE, p, 0, 100);
+            throw new OutOfRangeException(LocalizedFormats.OUT_OF_BOUNDS_QUANTILE_VALUE, p, 0, 100);
         }
         if (length == 0) {
             return Double.NaN;
@@ -401,11 +401,11 @@ public class Percentile extends AbstractUnivariateStatistic implements Serializa
      * @throws MathIllegalArgumentException if values or indices are invalid
      */
     protected double[] getWorkArray(final double[] values, final int begin, final int length) {
-            final double[] work;
-            if (values == getDataRef()) {
-                work = getDataRef();
-            } else {
-                switch (nanStrategy) {
+        final double[] work;
+        if (values == getDataRef()) {
+            work = getDataRef();
+        } else {
+            switch (nanStrategy) {
                 case MAXIMAL:// Replace NaNs with +INFs
                     work = replaceAndSlice(values, begin, length, Double.NaN, Double.POSITIVE_INFINITY);
                     break;
@@ -422,9 +422,9 @@ public class Percentile extends AbstractUnivariateStatistic implements Serializa
                 default: //FIXED
                     work = copyOf(values,begin,length);
                     break;
-                }
             }
-            return work;
+        }
+        return work;
     }
 
     /**
@@ -486,7 +486,7 @@ public class Percentile extends AbstractUnivariateStatistic implements Serializa
         //Check if empty then create a new copy
         if (bits.isEmpty()) {
             temp = copyOf(values, begin, length); // Nothing removed, just copy
-        } else if(bits.cardinality() == length){
+        } else if(bits.cardinality() == length) {
             temp = new double[0];                 // All removed, just empty
         }else {                                   // Some removable, so new
             temp = new double[length - bits.cardinality()];
@@ -630,8 +630,7 @@ public class Percentile extends AbstractUnivariateStatistic implements Serializa
      * @throws NullArgumentException when newKthSelector is null
      */
     public Percentile withKthSelector(final KthSelector newKthSelector) {
-        return new Percentile(quantile, estimationType, nanStrategy,
-                                newKthSelector);
+        return new Percentile(quantile, estimationType, nanStrategy, newKthSelector);
     }
 
     /**
@@ -669,7 +668,6 @@ public class Percentile extends AbstractUnivariateStatistic implements Serializa
      * <a href="http://stat.ethz.ch/R-manual/R-devel/library/stats/html/quantile.html">
      * R-Manual </a></li>
      * </ol>
-     *
      */
     public static enum EstimationType {
         /**
@@ -808,7 +806,7 @@ public class Percentile extends AbstractUnivariateStatistic implements Serializa
          * &amp;maxLimit = (N-0.5)/N
          * \end{align}\)
          */
-        R_5("R-5"){
+        R_5("R-5") {
 
             @Override
             protected double index(final double p, final int length) {
@@ -836,7 +834,7 @@ public class Percentile extends AbstractUnivariateStatistic implements Serializa
          * first element (p&lt;1(N+1)) and last elements (p&gt;N/(N+1))are done.
          * While in default case; these are done with p=0 and p=1 respectively.
          */
-        R_6("R-6"){
+        R_6("R-6") {
 
             @Override
             protected double index(final double p, final int length) {

http://git-wip-us.apache.org/repos/asf/commons-math/blob/845e1d54/src/main/java/org/apache/commons/math4/stat/descriptive/summary/Product.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/stat/descriptive/summary/Product.java b/src/main/java/org/apache/commons/math4/stat/descriptive/summary/Product.java
index 99e1fa7..5be6ce9 100644
--- a/src/main/java/org/apache/commons/math4/stat/descriptive/summary/Product.java
+++ b/src/main/java/org/apache/commons/math4/stat/descriptive/summary/Product.java
@@ -23,6 +23,7 @@ import org.apache.commons.math4.exception.NullArgumentException;
 import org.apache.commons.math4.stat.descriptive.AbstractStorelessUnivariateStatistic;
 import org.apache.commons.math4.stat.descriptive.WeightedEvaluation;
 import org.apache.commons.math4.util.FastMath;
+import org.apache.commons.math4.util.MathArrays;
 import org.apache.commons.math4.util.MathUtils;
 
 /**
@@ -36,12 +37,11 @@ import org.apache.commons.math4.util.MathUtils;
  * multiple threads access an instance of this class concurrently, and at least
  * one of the threads invokes the <code>increment()</code> or
  * <code>clear()</code> method, it must be synchronized externally.</p>
- *
  */
 public class Product extends AbstractStorelessUnivariateStatistic implements Serializable, WeightedEvaluation {
 
     /** Serializable version identifier */
-    private static final long serialVersionUID = 2824226005990582538L;
+    private static final long serialVersionUID = 20150412L;
 
     /**The number of values that have been added */
     private long n;
@@ -52,7 +52,7 @@ public class Product extends AbstractStorelessUnivariateStatistic implements Ser
     private double value;
 
     /**
-     * Create a Product instance
+     * Create a Product instance.
      */
     public Product() {
         n = 0;
@@ -61,7 +61,7 @@ public class Product extends AbstractStorelessUnivariateStatistic implements Ser
 
     /**
      * Copy constructor, creates a new {@code Product} identical
-     * to the {@code original}
+     * to the {@code original}.
      *
      * @param original the {@code Product} instance to copy
      * @throws NullArgumentException  if original is null
@@ -120,9 +120,9 @@ public class Product extends AbstractStorelessUnivariateStatistic implements Ser
      */
     @Override
     public double evaluate(final double[] values, final int begin, final int length)
-    throws MathIllegalArgumentException {
+        throws MathIllegalArgumentException {
         double product = Double.NaN;
-        if (test(values, begin, length, true)) {
+        if (MathArrays.verifyValues(values, begin, length, true)) {
             product = 1.0;
             for (int i = begin; i < begin + length; i++) {
                 product *= values[i];
@@ -161,9 +161,9 @@ public class Product extends AbstractStorelessUnivariateStatistic implements Ser
      */
     @Override
     public double evaluate(final double[] values, final double[] weights,
-        final int begin, final int length) throws MathIllegalArgumentException {
+                           final int begin, final int length) throws MathIllegalArgumentException {
         double product = Double.NaN;
-        if (test(values, weights, begin, length, true)) {
+        if (MathArrays.verifyValues(values, weights, begin, length, true)) {
             product = 1.0;
             for (int i = begin; i < begin + length; i++) {
                 product *= FastMath.pow(values[i], weights[i]);
@@ -184,7 +184,8 @@ public class Product extends AbstractStorelessUnivariateStatistic implements Ser
      *     <li>the weights array contains negative values</li>
      * </ul></p>
      *
-     * <p>Uses the formula, <pre>
+     * <p>Uses the formula,
+     * <pre>
      *    weighted product = &prod;values[i]<sup>weights[i]</sup>
      * </pre>
      * that is, the weights are applied as exponents when computing the weighted product.</p>
@@ -196,12 +197,10 @@ public class Product extends AbstractStorelessUnivariateStatistic implements Ser
      * @since 2.1
      */
     @Override
-    public double evaluate(final double[] values, final double[] weights)
-    throws MathIllegalArgumentException {
+    public double evaluate(final double[] values, final double[] weights) throws MathIllegalArgumentException {
         return evaluate(values, weights, 0, values.length);
     }
 
-
     /**
      * {@inheritDoc}
      */
@@ -225,7 +224,6 @@ public class Product extends AbstractStorelessUnivariateStatistic implements Ser
         throws NullArgumentException {
         MathUtils.checkNotNull(source);
         MathUtils.checkNotNull(dest);
-        dest.setData(source.getDataRef());
         dest.n = source.n;
         dest.value = source.value;
     }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/845e1d54/src/main/java/org/apache/commons/math4/stat/descriptive/summary/Sum.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/stat/descriptive/summary/Sum.java b/src/main/java/org/apache/commons/math4/stat/descriptive/summary/Sum.java
index 523de97..bbe29fa 100644
--- a/src/main/java/org/apache/commons/math4/stat/descriptive/summary/Sum.java
+++ b/src/main/java/org/apache/commons/math4/stat/descriptive/summary/Sum.java
@@ -21,6 +21,7 @@ import java.io.Serializable;
 import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.apache.commons.math4.exception.NullArgumentException;
 import org.apache.commons.math4.stat.descriptive.AbstractStorelessUnivariateStatistic;
+import org.apache.commons.math4.util.MathArrays;
 import org.apache.commons.math4.util.MathUtils;
 
 
@@ -35,12 +36,11 @@ import org.apache.commons.math4.util.MathUtils;
  * multiple threads access an instance of this class concurrently, and at least
  * one of the threads invokes the <code>increment()</code> or
  * <code>clear()</code> method, it must be synchronized externally.</p>
- *
  */
 public class Sum extends AbstractStorelessUnivariateStatistic implements Serializable {
 
     /** Serializable version identifier */
-    private static final long serialVersionUID = -8231831954703408316L;
+    private static final long serialVersionUID = 20150412L;
 
     /** */
     private long n;
@@ -51,7 +51,7 @@ public class Sum extends AbstractStorelessUnivariateStatistic implements Seriali
     private double value;
 
     /**
-     * Create a Sum instance
+     * Create a Sum instance.
      */
     public Sum() {
         n = 0;
@@ -60,7 +60,7 @@ public class Sum extends AbstractStorelessUnivariateStatistic implements Seriali
 
     /**
      * Copy constructor, creates a new {@code Sum} identical
-     * to the {@code original}
+     * to the {@code original}.
      *
      * @param original the {@code Sum} instance to copy
      * @throws NullArgumentException if original is null
@@ -104,9 +104,8 @@ public class Sum extends AbstractStorelessUnivariateStatistic implements Seriali
     }
 
     /**
-     * The sum of the entries in the specified portion of
-     * the input array, or 0 if the designated subarray
-     * is empty.
+     * The sum of the entries in the specified portion of the input array,
+     * or 0 if the designated subarray is empty.
      * <p>
      * Throws <code>MathIllegalArgumentException</code> if the array is null.</p>
      *
@@ -119,9 +118,10 @@ public class Sum extends AbstractStorelessUnivariateStatistic implements Seriali
      */
     @Override
     public double evaluate(final double[] values, final int begin, final int length)
-    throws MathIllegalArgumentException {
+        throws MathIllegalArgumentException {
+
         double sum = Double.NaN;
-        if (test(values, begin, length, true)) {
+        if (MathArrays.verifyValues(values, begin, length, true)) {
             sum = 0.0;
             for (int i = begin; i < begin + length; i++) {
                 sum += values[i];
@@ -158,9 +158,9 @@ public class Sum extends AbstractStorelessUnivariateStatistic implements Seriali
      * @since 2.1
      */
     public double evaluate(final double[] values, final double[] weights,
-        final int begin, final int length) throws MathIllegalArgumentException {
+                           final int begin, final int length) throws MathIllegalArgumentException {
         double sum = Double.NaN;
-        if (test(values, weights, begin, length, true)) {
+        if (MathArrays.verifyValues(values, weights, begin, length, true)) {
             sum = 0.0;
             for (int i = begin; i < begin + length; i++) {
                 sum += values[i] * weights[i];
@@ -191,8 +191,7 @@ public class Sum extends AbstractStorelessUnivariateStatistic implements Seriali
      * @throws MathIllegalArgumentException if the parameters are not valid
      * @since 2.1
      */
-    public double evaluate(final double[] values, final double[] weights)
-    throws MathIllegalArgumentException {
+    public double evaluate(final double[] values, final double[] weights) throws MathIllegalArgumentException {
         return evaluate(values, weights, 0, values.length);
     }
 
@@ -219,7 +218,6 @@ public class Sum extends AbstractStorelessUnivariateStatistic implements Seriali
         throws NullArgumentException {
         MathUtils.checkNotNull(source);
         MathUtils.checkNotNull(dest);
-        dest.setData(source.getDataRef());
         dest.n = source.n;
         dest.value = source.value;
     }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/845e1d54/src/main/java/org/apache/commons/math4/stat/descriptive/summary/SumOfLogs.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/stat/descriptive/summary/SumOfLogs.java b/src/main/java/org/apache/commons/math4/stat/descriptive/summary/SumOfLogs.java
index 5a95de1..fcb00b9 100644
--- a/src/main/java/org/apache/commons/math4/stat/descriptive/summary/SumOfLogs.java
+++ b/src/main/java/org/apache/commons/math4/stat/descriptive/summary/SumOfLogs.java
@@ -22,6 +22,7 @@ import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.apache.commons.math4.exception.NullArgumentException;
 import org.apache.commons.math4.stat.descriptive.AbstractStorelessUnivariateStatistic;
 import org.apache.commons.math4.util.FastMath;
+import org.apache.commons.math4.util.MathArrays;
 import org.apache.commons.math4.util.MathUtils;
 
 /**
@@ -43,14 +44,13 @@ import org.apache.commons.math4.util.MathUtils;
  * multiple threads access an instance of this class concurrently, and at least
  * one of the threads invokes the <code>increment()</code> or
  * <code>clear()</code> method, it must be synchronized externally.</p>
- *
  */
 public class SumOfLogs extends AbstractStorelessUnivariateStatistic implements Serializable {
 
     /** Serializable version identifier */
-    private static final long serialVersionUID = -370076995648386763L;
+    private static final long serialVersionUID = 20150412L;
 
-    /**Number of values that have been added */
+    /** Number of values that have been added */
     private int n;
 
     /**
@@ -59,7 +59,7 @@ public class SumOfLogs extends AbstractStorelessUnivariateStatistic implements S
     private double value;
 
     /**
-     * Create a SumOfLogs instance
+     * Create a SumOfLogs instance.
      */
     public SumOfLogs() {
        value = 0d;
@@ -68,7 +68,7 @@ public class SumOfLogs extends AbstractStorelessUnivariateStatistic implements S
 
     /**
      * Copy constructor, creates a new {@code SumOfLogs} identical
-     * to the {@code original}
+     * to the {@code original}.
      *
      * @param original the {@code SumOfLogs} instance to copy
      * @throws NullArgumentException if original is null
@@ -130,9 +130,10 @@ public class SumOfLogs extends AbstractStorelessUnivariateStatistic implements S
      */
     @Override
     public double evaluate(final double[] values, final int begin, final int length)
-    throws MathIllegalArgumentException {
+        throws MathIllegalArgumentException {
+
         double sumLog = Double.NaN;
-        if (test(values, begin, length, true)) {
+        if (MathArrays.verifyValues(values, begin, length, true)) {
             sumLog = 0.0;
             for (int i = begin; i < begin + length; i++) {
                 sumLog += FastMath.log(values[i]);
@@ -164,7 +165,6 @@ public class SumOfLogs extends AbstractStorelessUnivariateStatistic implements S
         throws NullArgumentException {
         MathUtils.checkNotNull(source);
         MathUtils.checkNotNull(dest);
-        dest.setData(source.getDataRef());
         dest.n = source.n;
         dest.value = source.value;
     }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/845e1d54/src/main/java/org/apache/commons/math4/stat/descriptive/summary/SumOfSquares.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/stat/descriptive/summary/SumOfSquares.java b/src/main/java/org/apache/commons/math4/stat/descriptive/summary/SumOfSquares.java
index d55c890..d37e35b 100644
--- a/src/main/java/org/apache/commons/math4/stat/descriptive/summary/SumOfSquares.java
+++ b/src/main/java/org/apache/commons/math4/stat/descriptive/summary/SumOfSquares.java
@@ -21,6 +21,7 @@ import java.io.Serializable;
 import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.apache.commons.math4.exception.NullArgumentException;
 import org.apache.commons.math4.stat.descriptive.AbstractStorelessUnivariateStatistic;
+import org.apache.commons.math4.util.MathArrays;
 import org.apache.commons.math4.util.MathUtils;
 
 /**
@@ -34,14 +35,13 @@ import org.apache.commons.math4.util.MathUtils;
  * multiple threads access an instance of this class concurrently, and at least
  * one of the threads invokes the <code>increment()</code> or
  * <code>clear()</code> method, it must be synchronized externally.</p>
- *
  */
 public class SumOfSquares extends AbstractStorelessUnivariateStatistic implements Serializable {
 
     /** Serializable version identifier */
-    private static final long serialVersionUID = 1460986908574398008L;
+    private static final long serialVersionUID = 20150412L;
 
-    /** */
+    /** Number of values that have been added */
     private long n;
 
     /**
@@ -50,7 +50,7 @@ public class SumOfSquares extends AbstractStorelessUnivariateStatistic implement
     private double value;
 
     /**
-     * Create a SumOfSquares instance
+     * Create a SumOfSquares instance.
      */
     public SumOfSquares() {
         n = 0;
@@ -59,7 +59,7 @@ public class SumOfSquares extends AbstractStorelessUnivariateStatistic implement
 
     /**
      * Copy constructor, creates a new {@code SumOfSquares} identical
-     * to the {@code original}
+     * to the {@code original}.
      *
      * @param original the {@code SumOfSquares} instance to copy
      * @throws NullArgumentException if original is null
@@ -118,9 +118,10 @@ public class SumOfSquares extends AbstractStorelessUnivariateStatistic implement
      */
     @Override
     public double evaluate(final double[] values,final int begin, final int length)
-    throws MathIllegalArgumentException {
+        throws MathIllegalArgumentException {
+
         double sumSq = Double.NaN;
-        if (test(values, begin, length, true)) {
+        if (MathArrays.verifyValues(values, begin, length, true)) {
             sumSq = 0.0;
             for (int i = begin; i < begin + length; i++) {
                 sumSq += values[i] * values[i];
@@ -152,7 +153,6 @@ public class SumOfSquares extends AbstractStorelessUnivariateStatistic implement
         throws NullArgumentException {
         MathUtils.checkNotNull(source);
         MathUtils.checkNotNull(dest);
-        dest.setData(source.getDataRef());
         dest.n = source.n;
         dest.value = source.value;
     }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/845e1d54/src/test/java/org/apache/commons/math4/stat/descriptive/AbstractUnivariateStatisticTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/AbstractUnivariateStatisticTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/AbstractUnivariateStatisticTest.java
deleted file mode 100644
index b455f5b..0000000
--- a/src/test/java/org/apache/commons/math4/stat/descriptive/AbstractUnivariateStatisticTest.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.math4.stat.descriptive;
-
-
-import org.apache.commons.math4.exception.MathIllegalArgumentException;
-import org.apache.commons.math4.exception.NullArgumentException;
-import org.apache.commons.math4.stat.descriptive.moment.Mean;
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * Tests for AbstractUnivariateStatistic
- *
- */
-public class AbstractUnivariateStatisticTest {
-
-    protected double[] testArray = {0, 1, 2, 3, 4, 5};
-    protected double[] testWeightsArray = {0.3, 0.2, 1.3, 1.1, 1.0, 1.8};
-    protected double[] testNegativeWeightsArray = {-0.3, 0.2, -1.3, 1.1, 1.0, 1.8};
-    protected double[] nullArray = null;
-    protected double[] singletonArray = {0};
-    protected Mean testStatistic = new Mean();
-
-    @Test
-    public void testTestPositive() {
-        for (int j = 0; j < 6; j++) {
-            for (int i = 1; i < (7 - j); i++) {
-                Assert.assertTrue(testStatistic.test(testArray, 0, i));
-            }
-        }
-        Assert.assertTrue(testStatistic.test(singletonArray, 0, 1));
-        Assert.assertTrue(testStatistic.test(singletonArray, 0, 0, true));
-    }
-
-    @Test
-    public void testTestNegative() {
-        Assert.assertFalse(testStatistic.test(singletonArray, 0, 0));
-        Assert.assertFalse(testStatistic.test(testArray, 0, 0));
-        try {
-            testStatistic.test(singletonArray, 2, 1);  // start past end
-            Assert.fail("Expecting MathIllegalArgumentException");
-        } catch (MathIllegalArgumentException ex) {
-            // expected
-        }
-        try {
-            testStatistic.test(testArray, 0, 7);  // end past end
-            Assert.fail("Expecting MathIllegalArgumentException");
-        } catch (MathIllegalArgumentException ex) {
-            // expected
-        }
-        try {
-            testStatistic.test(testArray, -1, 1);  // start negative
-            Assert.fail("Expecting MathIllegalArgumentException");
-        } catch (MathIllegalArgumentException ex) {
-            // expected
-        }
-        try {
-            testStatistic.test(testArray, 0, -1);  // length negative
-            Assert.fail("Expecting MathIllegalArgumentException");
-        } catch (MathIllegalArgumentException ex) {
-            // expected
-        }
-        try {
-            testStatistic.test(nullArray, 0, 1);  // null array
-            Assert.fail("Expecting NullArgumentException");
-        } catch (NullArgumentException ex) {
-            // expected
-        }
-        try {
-            testStatistic.test(testArray, nullArray, 0, 1);  // null weights array
-            Assert.fail("Expecting NullArgumentException");
-        } catch (NullArgumentException ex) {
-            // expected
-        }
-        try {
-            testStatistic.test(singletonArray, testWeightsArray, 0, 1);  // weights.length != value.length
-            Assert.fail("Expecting MathIllegalArgumentException");
-        } catch (MathIllegalArgumentException ex) {
-            // expected
-        }
-        try {
-            testStatistic.test(testArray, testNegativeWeightsArray, 0, 6);  // can't have negative weights
-            Assert.fail("Expecting MathIllegalArgumentException");
-        } catch (MathIllegalArgumentException ex) {
-            // expected
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/commons-math/blob/845e1d54/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 5afedd5..5f25f88 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
@@ -226,7 +226,7 @@ public class DescriptiveStatisticsTest {
         checkremoval(dstat, DescriptiveStatistics.INFINITE_WINDOW, 3.5, 2.5, 3.0);
 
     }
-    
+
     @Test
     public void testSummaryConsistency() {
         final DescriptiveStatistics dstats = new DescriptiveStatistics();
@@ -316,13 +316,16 @@ public class DescriptiveStatisticsTest {
      */
     static class deepMean implements UnivariateStatistic {
 
+        @Override
         public double evaluate(double[] values, int begin, int length) {
             return 42;
         }
 
+        @Override
         public double evaluate(double[] values) {
             return 42;
         }
+        @Override
         public UnivariateStatistic copy() {
             return new deepMean();
         }
@@ -332,16 +335,19 @@ public class DescriptiveStatisticsTest {
      * Test percentile implementation - wraps a Percentile
      */
     static class goodPercentile implements UnivariateStatistic {
-        private Percentile percentile = new Percentile();
+        private final Percentile percentile = new Percentile();
         public void setQuantile(double quantile) {
             percentile.setQuantile(quantile);
         }
+        @Override
         public double evaluate(double[] values, int begin, int length) {
             return percentile.evaluate(values, begin, length);
         }
+        @Override
         public double evaluate(double[] values) {
             return percentile.evaluate(values);
         }
+        @Override
         public UnivariateStatistic copy() {
             goodPercentile result = new goodPercentile();
             result.setQuantile(percentile.getQuantile());
@@ -374,13 +380,16 @@ public class DescriptiveStatisticsTest {
      * "Bad" test percentile implementation - no setQuantile
      */
     static class badPercentile implements UnivariateStatistic {
-        private Percentile percentile = new Percentile();
+        private final Percentile percentile = new Percentile();
+        @Override
         public double evaluate(double[] values, int begin, int length) {
             return percentile.evaluate(values, begin, length);
         }
+        @Override
         public double evaluate(double[] values) {
             return percentile.evaluate(values);
         }
+        @Override
         public UnivariateStatistic copy() {
             return new badPercentile();
         }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/845e1d54/src/test/java/org/apache/commons/math4/stat/descriptive/MixedListUnivariateImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/MixedListUnivariateImplTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/MixedListUnivariateImplTest.java
index 8e69064..410a2e1 100644
--- a/src/test/java/org/apache/commons/math4/stat/descriptive/MixedListUnivariateImplTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/descriptive/MixedListUnivariateImplTest.java
@@ -29,23 +29,21 @@ import org.junit.Test;
 
 /**
  * Test cases for the {@link ListUnivariateImpl} class.
- *
  */
-
 public final class MixedListUnivariateImplTest {
-    private double one = 1;
-    private float two = 2;
-    private int three = 3;
-
-    private double mean = 2;
-    private double sumSq = 18;
-    private double sum = 8;
-    private double var = 0.666666666666666666667;
-    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 two = 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 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;
 
     private TransformerMap transformers = new TransformerMap();
 
@@ -184,6 +182,7 @@ public final class MixedListUnivariateImplTest {
 
     public static final class FooTransformer implements NumberTransformer, Serializable {
         private static final long serialVersionUID = -4252248129291326127L;
+        @Override
         public double transform(Object o) {
             return Double.parseDouble(((Foo) o).heresFoo());
         }
@@ -197,6 +196,7 @@ public final class MixedListUnivariateImplTest {
 
     public static final class BarTransformer implements NumberTransformer, Serializable {
         private static final long serialVersionUID = -1768345377764262043L;
+        @Override
         public double transform(Object o) {
             return Double.parseDouble(((Bar) o).heresBar());
         }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/845e1d54/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 3982428..c9d8c37 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
@@ -142,30 +142,39 @@ public class MultivariateSummaryStatisticsTest {
     static class sumMean implements StorelessUnivariateStatistic {
         private double sum = 0;
         private long n = 0;
+        @Override
         public double evaluate(double[] values, int begin, int length) {
             return 0;
         }
+        @Override
         public double evaluate(double[] values) {
             return 0;
         }
+        @Override
         public void clear() {
           sum = 0;
           n = 0;
         }
+        @Override
         public long getN() {
             return n;
         }
+        @Override
         public double getResult() {
             return sum;
         }
+        @Override
         public void increment(double d) {
             sum += d;
             n++;
         }
+        @Override
         public void incrementAll(double[] values, int start, int length) {
         }
+        @Override
         public void incrementAll(double[] values) {
         }
+        @Override
         public StorelessUnivariateStatistic copy() {
             return new sumMean();
         }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/845e1d54/src/test/java/org/apache/commons/math4/stat/descriptive/StorelessUnivariateStatisticAbstractTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/StorelessUnivariateStatisticAbstractTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/StorelessUnivariateStatisticAbstractTest.java
index 8ac3269..bcbceae 100644
--- a/src/test/java/org/apache/commons/math4/stat/descriptive/StorelessUnivariateStatisticAbstractTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/descriptive/StorelessUnivariateStatisticAbstractTest.java
@@ -76,7 +76,7 @@ public abstract class StorelessUnivariateStatisticAbstractTest
     protected void checkClearValue(StorelessUnivariateStatistic statistic){
         Assert.assertTrue(Double.isNaN(statistic.getResult()));
     }
-    
+
     @Test
     public void testSerialization() {
 
@@ -182,7 +182,6 @@ public abstract class StorelessUnivariateStatisticAbstractTest
     /**
      * Verifies that copied statistics remain equal to originals when
      * incremented the same way.
-     *
      */
     @Test
     public void testCopyConsistency() {
@@ -218,4 +217,24 @@ public abstract class StorelessUnivariateStatisticAbstractTest
             (StorelessUnivariateStatistic) getUnivariateStatistic();
         Assert.assertEquals(s, TestUtils.serializeAndRecover(s));
     }
+
+    /**
+     * Make sure that evaluate(double[]) does not alter the internal state.
+     */
+    @Test
+    public void testEvaluateInternalState() {
+        StorelessUnivariateStatistic stat = (StorelessUnivariateStatistic) getUnivariateStatistic();
+        stat.evaluate(testArray);
+        Assert.assertEquals(0, stat.getN());
+
+        stat.incrementAll(testArray);
+
+        StorelessUnivariateStatistic savedStatistic = stat.copy();
+
+        Assert.assertNotEquals(stat.getResult(), stat.evaluate(testArray, 0, 5), getTolerance());
+
+        Assert.assertEquals(savedStatistic.getResult(), stat.getResult(), 0.0);
+        Assert.assertEquals(savedStatistic.getN(), stat.getN());
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/845e1d54/src/test/java/org/apache/commons/math4/stat/descriptive/UnivariateStatisticAbstractTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/UnivariateStatisticAbstractTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/UnivariateStatisticAbstractTest.java
index bca7dc8..6f12b1e 100644
--- a/src/test/java/org/apache/commons/math4/stat/descriptive/UnivariateStatisticAbstractTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/descriptive/UnivariateStatisticAbstractTest.java
@@ -96,12 +96,9 @@ public abstract class UnivariateStatisticAbstractTest {
 
     @Test
     public void testEvaluation() {
-        Assert.assertEquals(
-            expectedValue(),
-            getUnivariateStatistic().evaluate(testArray),
-            getTolerance());
+        Assert.assertEquals(expectedValue(), getUnivariateStatistic().evaluate(testArray), getTolerance());
     }
-    
+
     @Test
     public void testEvaluateArraySegment() {
         final UnivariateStatistic stat = getUnivariateStatistic();
@@ -115,7 +112,7 @@ public abstract class UnivariateStatisticAbstractTest {
         System.arraycopy(testArray, testArray.length - 5, arrayEnd, 0, 5);
         Assert.assertEquals(stat.evaluate(arrayEnd), stat.evaluate(testArray, testArray.length - 5, 5), 0);
     }
-    
+
     @Test
     public void testEvaluateArraySegmentWeighted() {
         // See if this statistic computes weighted statistics
@@ -149,10 +146,7 @@ public abstract class UnivariateStatisticAbstractTest {
     public void testCopy() {
         UnivariateStatistic original = getUnivariateStatistic();
         UnivariateStatistic copy = original.copy();
-        Assert.assertEquals(
-                expectedValue(),
-                copy.evaluate(testArray),
-                getTolerance());
+        Assert.assertEquals(expectedValue(), copy.evaluate(testArray), getTolerance());
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/commons-math/blob/845e1d54/src/test/java/org/apache/commons/math4/stat/descriptive/moment/KurtosisTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/moment/KurtosisTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/moment/KurtosisTest.java
index eb34f86..288aa65 100644
--- a/src/test/java/org/apache/commons/math4/stat/descriptive/moment/KurtosisTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/descriptive/moment/KurtosisTest.java
@@ -47,7 +47,6 @@ public class KurtosisTest extends StorelessUnivariateStatisticAbstractTest{
 
     /**
      * Make sure Double.NaN is returned iff n < 4
-     *
      */
     @Test
     public void testNaN() {

http://git-wip-us.apache.org/repos/asf/commons-math/blob/845e1d54/src/test/java/org/apache/commons/math4/stat/descriptive/moment/SkewnessTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/moment/SkewnessTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/moment/SkewnessTest.java
index 099607f..5911c01 100644
--- a/src/test/java/org/apache/commons/math4/stat/descriptive/moment/SkewnessTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/descriptive/moment/SkewnessTest.java
@@ -48,7 +48,6 @@ public class SkewnessTest extends StorelessUnivariateStatisticAbstractTest{
 
     /**
      * Make sure Double.NaN is returned iff n < 3
-     *
      */
     @Test
     public void testNaN() {

http://git-wip-us.apache.org/repos/asf/commons-math/blob/845e1d54/src/test/java/org/apache/commons/math4/stat/descriptive/moment/StandardDeviationTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/moment/StandardDeviationTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/moment/StandardDeviationTest.java
index f695fc6..b29138f 100644
--- a/src/test/java/org/apache/commons/math4/stat/descriptive/moment/StandardDeviationTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/descriptive/moment/StandardDeviationTest.java
@@ -69,7 +69,7 @@ public class StandardDeviationTest extends StorelessUnivariateStatisticAbstractT
         double[] values = {-1.0d, 3.1d, 4.0d, -2.1d, 22d, 11.7d, 3d, 14d};
         double sigma = populationStandardDeviation(values);
         SecondMoment m = new SecondMoment();
-        m.evaluate(values);  // side effect is to add values
+        m.incrementAll(values);  // side effect is to add values
         StandardDeviation s1 = new StandardDeviation();
         s1.setBiasCorrected(false);
         Assert.assertEquals(sigma, s1.evaluate(values), 1E-14);

http://git-wip-us.apache.org/repos/asf/commons-math/blob/845e1d54/src/test/java/org/apache/commons/math4/stat/descriptive/moment/VarianceTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/moment/VarianceTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/moment/VarianceTest.java
index c683f83..fc5644c 100644
--- a/src/test/java/org/apache/commons/math4/stat/descriptive/moment/VarianceTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/descriptive/moment/VarianceTest.java
@@ -74,7 +74,7 @@ public class VarianceTest extends StorelessUnivariateStatisticAbstractTest{
     public void testPopulation() {
         double[] values = {-1.0d, 3.1d, 4.0d, -2.1d, 22d, 11.7d, 3d, 14d};
         SecondMoment m = new SecondMoment();
-        m.evaluate(values);  // side effect is to add values
+        m.incrementAll(values);  // side effect is to add values
         Variance v1 = new Variance();
         v1.setBiasCorrected(false);
         Assert.assertEquals(populationVariance(values), v1.evaluate(values), 1E-14);

http://git-wip-us.apache.org/repos/asf/commons-math/blob/845e1d54/src/test/java/org/apache/commons/math4/stat/descriptive/rank/MaxTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/rank/MaxTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/rank/MaxTest.java
index da80792..57363d5 100644
--- a/src/test/java/org/apache/commons/math4/stat/descriptive/rank/MaxTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/descriptive/rank/MaxTest.java
@@ -47,8 +47,7 @@ public class MaxTest extends StorelessUnivariateStatisticAbstractTest {
 
     @Test
     public void testSpecialValues() {
-        double[] testArray = {0d, Double.NaN, Double.NEGATIVE_INFINITY,
-                Double.POSITIVE_INFINITY};
+        double[] testArray = {0d, Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY};
         Max max = new Max();
         Assert.assertTrue(Double.isNaN(max.getResult()));
         max.increment(testArray[0]);

http://git-wip-us.apache.org/repos/asf/commons-math/blob/845e1d54/src/test/java/org/apache/commons/math4/stat/descriptive/rank/MedianTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/rank/MedianTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/rank/MedianTest.java
index c4bd114..6144b58 100644
--- a/src/test/java/org/apache/commons/math4/stat/descriptive/rank/MedianTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/descriptive/rank/MedianTest.java
@@ -82,26 +82,21 @@ public class MedianTest extends UnivariateStatisticAbstractTest{
         for (EstimationType e : EstimationType.values()) {
             UnivariateStatistic percentile = getTestMedian(e);
             Assert.assertEquals(1d, percentile.evaluate(singletonArray), 0);
-            Assert.assertEquals(1d, percentile.evaluate(singletonArray, 0, 1),
-                    0);
-            Assert.assertEquals(1d,
-                    new Median().evaluate(singletonArray, 0, 1, 5), 0);
-            Assert.assertEquals(1d,
-                    new Median().evaluate(singletonArray, 0, 1, 100), 0);
-            Assert.assertTrue(Double.isNaN(percentile.evaluate(singletonArray,
-                    0, 0)));
+            Assert.assertEquals(1d, percentile.evaluate(singletonArray, 0, 1), 0);
+            Assert.assertEquals(1d, new Median().evaluate(singletonArray, 0, 1, 5), 0);
+            Assert.assertEquals(1d, new Median().evaluate(singletonArray, 0, 1, 100), 0);
+            Assert.assertTrue(Double.isNaN(percentile.evaluate(singletonArray, 0, 0)));
         }
     }
+
     @Test
     public void testAllTechniquesMedian() {
         double[] d = new double[] { 1, 3, 2, 4 };
         testAssertMappedValues(d, new Object[][] { { LEGACY, 2.5d },
             { R_1, 2d }, { R_2, 2.5d }, { R_3, 2d }, { R_4, 2d }, { R_5, 2.5 },
             { R_6, 2.5 },{ R_7, 2.5 },{ R_8, 2.5 }, { R_9 , 2.5 } },  1.0e-05);
-
     }
 
-
     /**
      * Simple test assertion utility method
      *
@@ -109,8 +104,7 @@ public class MedianTest extends UnivariateStatisticAbstractTest{
      * @param map of expected result against a {@link EstimationType}
      * @param tolerance the tolerance of difference allowed
      */
-    protected void testAssertMappedValues(double[] d, Object[][] map,
-            Double tolerance) {
+    protected void testAssertMappedValues(double[] d, Object[][] map, Double tolerance) {
         for (Object[] o : map) {
             EstimationType e = (EstimationType) o[0];
             double expected = (Double) o[1];

http://git-wip-us.apache.org/repos/asf/commons-math/blob/845e1d54/src/test/java/org/apache/commons/math4/stat/descriptive/rank/MinTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/rank/MinTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/rank/MinTest.java
index 296248a..7ce8ee3 100644
--- a/src/test/java/org/apache/commons/math4/stat/descriptive/rank/MinTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/descriptive/rank/MinTest.java
@@ -47,8 +47,7 @@ public class MinTest extends StorelessUnivariateStatisticAbstractTest{
 
     @Test
     public void testSpecialValues() {
-        double[] testArray = {0d, Double.NaN, Double.POSITIVE_INFINITY,
-                Double.NEGATIVE_INFINITY};
+        double[] testArray = {0d, Double.NaN, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY};
         Min min = new Min();
         Assert.assertTrue(Double.isNaN(min.getResult()));
         min.increment(testArray[0]);

http://git-wip-us.apache.org/repos/asf/commons-math/blob/845e1d54/src/test/java/org/apache/commons/math4/stat/descriptive/rank/PSquarePercentileTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/rank/PSquarePercentileTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/rank/PSquarePercentileTest.java
index 8751b00..dfdcd4e 100644
--- a/src/test/java/org/apache/commons/math4/stat/descriptive/rank/PSquarePercentileTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/descriptive/rank/PSquarePercentileTest.java
@@ -44,7 +44,7 @@ import org.junit.Test;
 
 /**
  * Test cases for the {@link PSquarePercentile} class which naturally extends
- * {@link StorelessUnivariateStatisticAbstractTest}. 
+ * {@link StorelessUnivariateStatisticAbstractTest}.
  */
 public class PSquarePercentileTest extends
         StorelessUnivariateStatisticAbstractTest {
@@ -52,7 +52,7 @@ public class PSquarePercentileTest extends
     protected double percentile5 = 8.2299d;
     protected double percentile95 = 16.72195;// 20.82d; this is approximation
     protected double tolerance = 10E-12;
-    
+
     private final RandomGenerator randomGenerator = new Well19937c(1000);
 
     @Override
@@ -330,7 +330,7 @@ public class PSquarePercentileTest extends
         Assert.assertTrue(Double.isNaN(new PSquarePercentile(100).getResult()));
 
         double[] d = new double[] { 1, 3, 2, 4, 9, 10, 11 };
-        ptile.evaluate(d);
+        ptile.incrementAll(d);
         Assert.assertEquals(ptile, ptile);
         Assert.assertEquals(1d, ptile.getResult(), 1e-02);// this calls min
     }
@@ -343,8 +343,7 @@ public class PSquarePercentileTest extends
         ptile.increment(2);
         ptile.increment(3);
         Assert.assertNotNull(ptile.toString());
-        Assert.assertEquals(expectedValue(), ptile.evaluate(testArray),
-                getTolerance());
+        Assert.assertEquals(expectedValue(), ptile.evaluate(testArray), getTolerance());
         Assert.assertNotNull(ptile.toString());
     }
 

http://git-wip-us.apache.org/repos/asf/commons-math/blob/845e1d54/src/test/java/org/apache/commons/math4/stat/descriptive/summary/ProductTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/summary/ProductTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/summary/ProductTest.java
index 8bd238c..bc65e12 100644
--- a/src/test/java/org/apache/commons/math4/stat/descriptive/summary/ProductTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/descriptive/summary/ProductTest.java
@@ -54,7 +54,7 @@ public class ProductTest extends StorelessUnivariateStatisticAbstractTest{
         return this.product;
     }
 
-    /**Expected value for  the testArray defined in UnivariateStatisticAbstractTest */
+    /** Expected value for  the testArray defined in UnivariateStatisticAbstractTest */
     public double expectedWeightedValue() {
         return this.weightedProduct;
     }
@@ -78,14 +78,15 @@ public class ProductTest extends StorelessUnivariateStatisticAbstractTest{
     @Test
     public void testWeightedProduct() {
         Product product = new Product();
-        Assert.assertEquals(expectedWeightedValue(), product.evaluate(testArray, testWeightsArray, 0, testArray.length),getTolerance());
-        Assert.assertEquals(expectedValue(), product.evaluate(testArray, unitWeightsArray, 0, testArray.length), getTolerance());
+        Assert.assertEquals(expectedWeightedValue(),
+                            product.evaluate(testArray, testWeightsArray, 0, testArray.length),getTolerance());
+        Assert.assertEquals(expectedValue(),
+                            product.evaluate(testArray, unitWeightsArray, 0, testArray.length), getTolerance());
     }
-    
+
     @Override
     protected void checkClearValue(StorelessUnivariateStatistic statistic){
         Assert.assertEquals(1, statistic.getResult(), 0);
     }
 
-
 }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/845e1d54/src/test/java/org/apache/commons/math4/stat/descriptive/summary/SumLogTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/summary/SumLogTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/summary/SumLogTest.java
index d7f6495..1696dff 100644
--- a/src/test/java/org/apache/commons/math4/stat/descriptive/summary/SumLogTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/descriptive/summary/SumLogTest.java
@@ -76,11 +76,10 @@ public class SumLogTest extends StorelessUnivariateStatisticAbstractTest{
         sum.increment(-2d);
         Assert.assertTrue(Double.isNaN(sum.getResult()));
     }
-    
+
     @Override
-    protected void checkClearValue(StorelessUnivariateStatistic statistic){
+    protected void checkClearValue(StorelessUnivariateStatistic statistic) {
         Assert.assertEquals(0, statistic.getResult(), 0);
     }
-    
 
 }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/845e1d54/src/test/java/org/apache/commons/math4/stat/descriptive/summary/SumSqTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/summary/SumSqTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/summary/SumSqTest.java
index 0b722ed..1f278c6 100644
--- a/src/test/java/org/apache/commons/math4/stat/descriptive/summary/SumSqTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/descriptive/summary/SumSqTest.java
@@ -25,7 +25,6 @@ import org.junit.Test;
 
 /**
  * Test cases for the {@link SumOfSquares} class.
- *
  */
 public class SumSqTest extends StorelessUnivariateStatisticAbstractTest{
 
@@ -62,11 +61,10 @@ public class SumSqTest extends StorelessUnivariateStatisticAbstractTest{
         sumSq.increment(1);
         Assert.assertTrue(Double.isNaN(sumSq.getResult()));
     }
-    
+
     @Override
-    protected void checkClearValue(StorelessUnivariateStatistic statistic){
+    protected void checkClearValue(StorelessUnivariateStatistic statistic) {
         Assert.assertEquals(0, statistic.getResult(), 0);
     }
 
-
 }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/845e1d54/src/test/java/org/apache/commons/math4/stat/descriptive/summary/SumTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/stat/descriptive/summary/SumTest.java b/src/test/java/org/apache/commons/math4/stat/descriptive/summary/SumTest.java
index fa72645..88e509d 100644
--- a/src/test/java/org/apache/commons/math4/stat/descriptive/summary/SumTest.java
+++ b/src/test/java/org/apache/commons/math4/stat/descriptive/summary/SumTest.java
@@ -68,14 +68,15 @@ public class SumTest extends StorelessUnivariateStatisticAbstractTest{
     @Test
     public void testWeightedSum() {
         Sum sum = new Sum();
-        Assert.assertEquals(expectedWeightedValue(), sum.evaluate(testArray, testWeightsArray, 0, testArray.length), getTolerance());
-        Assert.assertEquals(expectedValue(), sum.evaluate(testArray, unitWeightsArray, 0, testArray.length), getTolerance());
+        Assert.assertEquals(expectedWeightedValue(),
+                            sum.evaluate(testArray, testWeightsArray, 0, testArray.length), getTolerance());
+        Assert.assertEquals(expectedValue(),
+                            sum.evaluate(testArray, unitWeightsArray, 0, testArray.length), getTolerance());
     }
-    
+
     @Override
-    protected void checkClearValue(StorelessUnivariateStatistic statistic){
+    protected void checkClearValue(StorelessUnivariateStatistic statistic) {
         Assert.assertEquals(0, statistic.getResult(), 0);
     }
 
-
 }


Mime
View raw message