Added test utility inadvertently omitted from r910264. JIRA: MATH-323.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@910784 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Phil Steitz 2010-02-17 00:25:19 +00:00
parent c1ce0e39e0
commit ccf7732750
1 changed files with 16 additions and 0 deletions

View File

@ -345,5 +345,21 @@ public class TestUtils {
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;
}
}