Simplified calculation, removing extra division.

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/math/trunk@140922 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark R. Diggory 2003-06-18 03:05:45 +00:00
parent 7c57c2ed60
commit 5179d78ef8
1 changed files with 2 additions and 1 deletions

View File

@ -180,7 +180,8 @@ public class StatUtils {
accum += Math.pow((values[i] - mean), 2.0);
accum2 += (values[i] - mean);
}
variance = (accum - (Math.pow(accum2,2)/(double)values.length)) / (double)(values.length - 1);
variance = ((accum*(double)values.length) - Math.pow(accum2,2)) /
(double)(values.length*(values.length - 1));
}
return variance;
}