diff --git a/lib/findPaths.js b/lib/findPaths.js
index b44dd50..7f20757 100644
--- a/lib/findPaths.js
+++ b/lib/findPaths.js
@@ -4,7 +4,7 @@ import {
numToAlphabeticalString,
formatLargeOrSmall,
avg,
- geomMean,
+ hackyGeomMean,
} from "../lib/utils.js";
/* Functions */
@@ -315,7 +315,7 @@ export function CreateTable({ tableRows }) {
{abridgeArrayAndDisplay(row.distances)} |
|
- {formatLargeOrSmall(geomMean(row.distances))}
+ {formatLargeOrSmall(hackyGeomMean(row.distances))}
|
))}
diff --git a/lib/utils.js b/lib/utils.js
index d9af918..5d48779 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -102,6 +102,15 @@ export const geomMean = (arr) => {
return result;
};
+export const hackyGeomMean = (arr) => {
+ let nonPositiveNumbers = arr.filter((x) => x <= 0);
+ if (nonPositiveNumbers.length == 0) {
+ return geomMean(arr);
+ } else {
+ return avg(arr);
+ }
+};
+
export function conservativeNumMergeSortSteps(n) {
return Math.ceil((expectedNumMergeSortSteps(n) + maxMergeSortSteps(n)) / 2);
}