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 answer;
if (hasPositive.length != 0 && hasNegative.length != 0) {
answer = avg(expectedRelativeValues);
answer = avg(expectedRelativeValuesFiltered);
} else {
if (hasNegative.length == 0) {
answer = geomMean(expectedRelativeValues);
answer = geomMean(expectedRelativeValuesFiltered);
} else {
let arrayAsPositive = expectedRelativeValues.map((x) => -x);
let arrayAsPositive = expectedRelativeValuesFiltered.map((x) => -x);
answer = -geomMean(arrayAsPositive);
}
}
return {
name: orderedList[i].name,
aggregatedMeans: answer,
arrayMeans: expectedRelativeValues,
arrayMeans: expectedRelativeValuesFiltered,
allPositive: hasNegative.length == 0,
};
});