commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject svn commit: r910784 - /commons/proper/math/trunk/src/test/java/org/apache/commons/math/TestUtils.java
Date Wed, 17 Feb 2010 00:25:19 GMT
Author: psteitz
Date: Wed Feb 17 00:25:19 2010
New Revision: 910784

URL: http://svn.apache.org/viewvc?rev=910784&view=rev
Log:
Added test utility inadvertently omitted from r910264. JIRA: MATH-323.

Modified:
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/TestUtils.java

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/TestUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/TestUtils.java?rev=910784&r1=910783&r2=910784&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/TestUtils.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/TestUtils.java Wed Feb
17 00:25:19 2010
@@ -345,5 +345,21 @@
             Assert.assertEquals(m[i],n[i]);
         }
     }
+    
+    /**
+     * Computes the sum of squared deviations of <values> from <target>
+     * @param values array of deviates
+     * @param target value to compute deviations from
+     * 
+     * @return sum of squared deviations
+     */
+    public static double sumSquareDev(double[] values, double target) {
+        double sumsq = 0d;
+        for (int i = 0; i < values.length; i++) {
+            final double dev = values[i] - target;
+            sumsq += (dev * dev);
+        }
+        return sumsq;
+    }
 
 }



Mime
View raw message