Cleanup: automatic code inspection via Android Studio.

This commit is contained in:
Dennis Guse
2019-08-18 14:46:43 +02:00
parent 4fa2401b27
commit f537cc7321
15 changed files with 22 additions and 105 deletions
@@ -77,30 +77,6 @@ public class DoubleBuffer {
return sum / numberOfEntries;
}
/**
* Gets the average and the variance of the buffer.
*
* @return an array of two elements - the first is the average, the second is
* the variance
*/
public double[] getAverageAndVariance() {
int numberOfEntries = isFull ? buffer.length : index;
if (numberOfEntries == 0) {
return new double[]{0, 0};
}
double sum = 0;
double sumSquares = 0;
for (int i = 0; i < numberOfEntries; i++) {
sum += buffer[i];
sumSquares += Math.pow(buffer[i], 2);
}
double average = sum / numberOfEntries;
double variance = sumSquares / numberOfEntries - Math.pow(average, 2);
return new double[]{average, variance};
}
/**
* Adds a double to the buffer. If the buffer is full the oldest element is
* overwritten.