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;
+    }
 
 }


Reply via email to