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

add mean without NaN

No related merge requests found
Showing with 18 additions and 1 deletion
+18 -1
...@@ -78,7 +78,7 @@ public class QueueMemory<E extends Number> extends ArrayBlockingQueue<E> { ...@@ -78,7 +78,7 @@ public class QueueMemory<E extends Number> extends ArrayBlockingQueue<E> {
double sum = 0.; double sum = 0.;
double total = 0.; double total = 0.;
for (E item : this) { for (E item : this) {
if (this.doubleValue(item) > 0.) { if (this.doubleValue(item) != 0.) {
sum += this.doubleValue(item); sum += this.doubleValue(item);
total++; total++;
} }
...@@ -90,6 +90,23 @@ public class QueueMemory<E extends Number> extends ArrayBlockingQueue<E> { ...@@ -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() { public double getGeometricMean() {
double sum = 0.; double sum = 0.;
for (E item : this) { for (E item : this) {
......
Supports Markdown
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