( values: Iterable<BigDecimal> )
| 434 | * agree on which value wins a tie. |
| 435 | * |
| 436 | * Two data count together only when their doubles are equal. That is the |
| 437 | * precision of the sample: two machine values that differ in the last bit |
| 438 | * are two values. (`0` and `-0` count together, and so do two `NaN`.) |
| 439 | */ |
| 440 | export function mode(values: Iterable<number>): number { |
| 441 | const counts = new Map<number, number>(); |
| 442 | for (const v of values) counts.set(v, (counts.get(v) ?? 0) + 1); |
| 443 | let max = 0; |
| 444 | let mode = NaN; |
no test coverage detected