Fixed the Standard Deviation. Although Excel seems to calculate it differently.

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@1873 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
David Dixon-Peugh
2003-04-29 00:13:07 +00:00
parent 255fdcc8d4
commit 9f81b4e75e
2 changed files with 15 additions and 2 deletions

View File

@ -66,7 +66,7 @@ public class StatisticalRuleTest extends TestCase {
public static final double MEAN = 49.5;
public static final double SIGMA = 28.86750;
public static final double SIGMA = 29.0115;
public static final int NUM_TESTS = 1;
public static final double DELTA = 0.005;

View File

@ -77,7 +77,20 @@ public abstract class StatisticalRule extends AbstractRule {
}
protected double getStdDev() {
return Math.sqrt(((totalSquared / count) - (getMean() * getMean())));
Iterator points = dataPoints.iterator();
double mean = getMean();
double deltaSq = 0.0;
if (dataPoints.size() < 2) {
return Double.NaN;
}
while (points.hasNext()) {
DataPoint point = (DataPoint) points.next();
deltaSq += ((point.getScore() - mean) * (point.getScore() - mean));
}
return Math.sqrt( deltaSq / (dataPoints.size() - 1));
}
protected SortedSet applyMinimumValue(SortedSet pointSet, double minValue) {