In class MovingWindowStDev, the standard deviation calculation is incorrect.
For example the standard deviation of the array {0 , 2} is 1.
But:
MovingWindowStDev stdDev = new MovingWindowStDev(2);
stdDev.add(0.);
stdDev.add(2.);
System.out.println(stdDev.getStdev());
will display a result of 1.41[..] instead.
Here's a fix:
public double getStdev() {
int capacity = getCapacity();
double num = sumSquared - (sum * sum) / capacity;
return Math.sqrt(num / capacity);
}
Original issue reported on code.google.com by donnef...@gmail.com on 5 Feb 2011 at 3:44
Original issue reported on code.google.com by
donnef...@gmail.com
on 5 Feb 2011 at 3:44