fix: aggregation bug

This commit is contained in:
NunoSempere 2022-06-19 21:22:07 -04:00
parent 988b2af12d
commit 0657ed6b00

View File

@ -112,19 +112,19 @@ export function aggregatePathsThroughMixtureOfMeans({
let hasNegative = expectedRelativeValuesFiltered.filter((x) => x < 0); let hasNegative = expectedRelativeValuesFiltered.filter((x) => x < 0);
let answer; let answer;
if (hasPositive.length != 0 && hasNegative.length != 0) { if (hasPositive.length != 0 && hasNegative.length != 0) {
answer = avg(expectedRelativeValues); answer = avg(expectedRelativeValuesFiltered);
} else { } else {
if (hasNegative.length == 0) { if (hasNegative.length == 0) {
answer = geomMean(expectedRelativeValues); answer = geomMean(expectedRelativeValuesFiltered);
} else { } else {
let arrayAsPositive = expectedRelativeValues.map((x) => -x); let arrayAsPositive = expectedRelativeValuesFiltered.map((x) => -x);
answer = -geomMean(arrayAsPositive); answer = -geomMean(arrayAsPositive);
} }
} }
return { return {
name: orderedList[i].name, name: orderedList[i].name,
aggregatedMeans: answer, aggregatedMeans: answer,
arrayMeans: expectedRelativeValues, arrayMeans: expectedRelativeValuesFiltered,
allPositive: hasNegative.length == 0, allPositive: hasNegative.length == 0,
}; };
}); });