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,
|
||||
formatLargeOrSmall,
|
||||
avg,
|
||||
geomMean,
|
||||
hackyGeomMean,
|
||||
} from "../lib/utils.js";
|
||||
|
||||
/* Functions */
|
||||
|
@ -315,7 +315,7 @@ export function CreateTable({ tableRows }) {
|
|||
<td className="">{abridgeArrayAndDisplay(row.distances)}</td>
|
||||
<td> </td>
|
||||
<td className="">
|
||||
{formatLargeOrSmall(geomMean(row.distances))}
|
||||
{formatLargeOrSmall(hackyGeomMean(row.distances))}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user