commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject svn commit: r1410126 - in /commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive: DescriptiveStatistics.java UnivariateStatistic.java
Date Fri, 16 Nov 2012 00:32:19 GMT
Author: erans
Date: Fri Nov 16 00:32:18 2012
New Revision: 1410126

URL: http://svn.apache.org/viewvc?rev=1410126&view=rev
Log:
By having "UnivariateStatistic" extend the new "MathArrays.Function"
interface, subclassing "ResizableDoubleArray" is not necessary to achieve
the required functionality (see MATH-894).

Modified:
    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/UnivariateStatistic.java

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=1410126&r1=1410125&r2=1410126&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
Fri Nov 16 00:32:18 2012
@@ -79,7 +79,7 @@ public class DescriptiveStatistics imple
     /**
      *  Stored data values
      */
-    private StatArray eDA = new StatArray();
+    private ResizableDoubleArray eDA = new ResizableDoubleArray();
 
     /** Mean statistic implementation - can be reset by setter. */
     private UnivariateStatistic meanImpl = new Mean();
@@ -138,7 +138,7 @@ public class DescriptiveStatistics imple
      */
     public DescriptiveStatistics(double[] initialDoubleArray) {
         if (initialDoubleArray != null) {
-            eDA = new StatArray(initialDoubleArray);
+            eDA = new ResizableDoubleArray(initialDoubleArray);
         }
     }
 
@@ -762,55 +762,4 @@ public class DescriptiveStatistics imple
         dest.skewnessImpl = source.skewnessImpl;
         dest.percentileImpl = source.percentileImpl;
     }
-
-    /**
-     * Provides a method to compute a statistics on the contents of the
-     * array.
-     */
-    private static class StatArray extends ResizableDoubleArray {
-        /** Default constructor. */
-        public StatArray() {}
-
-        /**
-         * Builds an instance with the same contents as the given array.
-         *
-         * @param initialArray Data.
-         */
-        public StatArray(double[] initialArray) {
-            super(initialArray);
-        }
-
-        /**
-         * Builds a copy of the given instance.
-         *
-         * @param other Array.
-         * @throws NullArgumentException if the argument is {@code null}.
-         */
-        public StatArray(StatArray other)
-            throws NullArgumentException {
-            super(other);
-        }
-
-        /**
-         * Computes the given statistics from the contents of this array.
-         *
-         * @param stat Statistics.
-         * @return the result of evaluating the statistics on the current
-         * contents of this array.
-         */
-        public double compute(UnivariateStatistic stat) {
-            return stat.evaluate(getArrayRef(),
-                                 getStartIndex(),
-                                 getNumElements());
-        }
-
-        /**
-         * Creates a copy of this instance.
-         *
-         * @return a copy of this instance.
-         */
-        public StatArray copy() {
-            return new StatArray(this);
-        }
-    }
 }

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=1410126&r1=1410125&r2=1410126&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
Fri Nov 16 00:32:18 2012
@@ -17,6 +17,7 @@
 package org.apache.commons.math3.stat.descriptive;
 
 import org.apache.commons.math3.exception.MathIllegalArgumentException;
+import org.apache.commons.math3.util.MathArrays;
 
 
 /**
@@ -24,8 +25,7 @@ import org.apache.commons.math3.exceptio
  *
  * @version $Id$
  */
-public interface UnivariateStatistic {
-
+public interface UnivariateStatistic extends MathArrays.Function {
     /**
      * Returns the result of evaluating the statistic over the input array.
      *
@@ -53,5 +53,4 @@ public interface UnivariateStatistic {
      * @return a copy of the statistic
      */
     UnivariateStatistic copy();
-
 }



Mime
View raw message