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:
@ -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;
|
||||
|
@ -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) {
|
||||
|
Reference in New Issue
Block a user