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:
parent
c1ce0e39e0
commit
ccf7732750
|
@ -346,4 +346,20 @@ public class TestUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue