diff --git a/src/test/java/org/apache/commons/math/TestUtils.java b/src/test/java/org/apache/commons/math/TestUtils.java index 209b2f81a..2558d691b 100644 --- a/src/test/java/org/apache/commons/math/TestUtils.java +++ b/src/test/java/org/apache/commons/math/TestUtils.java @@ -345,5 +345,21 @@ public class TestUtils { Assert.assertEquals(m[i],n[i]); } } + + /** + * Computes the sum of squared deviations of from + * @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; + } }