hack: Generalize geom mean to negative values...
by falling back to the arithmetic mean if there are any
This commit is contained in:
parent
2e4c76a257
commit
981b2ca568
|
@ -4,7 +4,7 @@ import {
|
||||||
numToAlphabeticalString,
|
numToAlphabeticalString,
|
||||||
formatLargeOrSmall,
|
formatLargeOrSmall,
|
||||||
avg,
|
avg,
|
||||||
geomMean,
|
hackyGeomMean,
|
||||||
} from "../lib/utils.js";
|
} from "../lib/utils.js";
|
||||||
|
|
||||||
/* Functions */
|
/* Functions */
|
||||||
|
@ -315,7 +315,7 @@ export function CreateTable({ tableRows }) {
|
||||||
<td className="">{abridgeArrayAndDisplay(row.distances)}</td>
|
<td className="">{abridgeArrayAndDisplay(row.distances)}</td>
|
||||||
<td> </td>
|
<td> </td>
|
||||||
<td className="">
|
<td className="">
|
||||||
{formatLargeOrSmall(geomMean(row.distances))}
|
{formatLargeOrSmall(hackyGeomMean(row.distances))}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
|
|
|
@ -102,6 +102,15 @@ export const geomMean = (arr) => {
|
||||||
return result;
|
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) {
|
export function conservativeNumMergeSortSteps(n) {
|
||||||
return Math.ceil((expectedNumMergeSortSteps(n) + maxMergeSortSteps(n)) / 2);
|
return Math.ceil((expectedNumMergeSortSteps(n) + maxMergeSortSteps(n)) / 2);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user