Commit 86cb6c8d authored by patrick.lambert's avatar patrick.lambert
Browse files

add mean without NaN

parent 44552ff8
......@@ -78,7 +78,7 @@ public class QueueMemory<E extends Number> extends ArrayBlockingQueue<E> {
double sum = 0.;
double total = 0.;
for (E item : this) {
if (this.doubleValue(item) > 0.) {
if (this.doubleValue(item) != 0.) {
sum += this.doubleValue(item);
total++;
}
......@@ -90,6 +90,23 @@ public class QueueMemory<E extends Number> extends ArrayBlockingQueue<E> {
}
public double getMeanWithoutNaN() {
double sum = 0.;
double total = 0.;
for (E item : this) {
Double value = this.doubleValue(item);
if (!Double.isNaN(value)) {
sum += value;
total++;
}
}
if (total > 0) {
sum = sum / total;
}
return (sum);
}
public double getGeometricMean() {
double sum = 0.;
for (E item : this) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment