doc/tests/math.test.ts
raw| 1 | import {expect, test} from "vitest"; |
| 2 | |
| 3 | import {median, percentile} from "../viewer_src/math"; |
| 4 | |
| 5 | test("matches COLMAP percentile interpolation and median", () => { |
| 6 | expect(percentile([0, 100], 0.01)).toBe(1); |
| 7 | expect(percentile([0, 1, 2, 3], 0.34)).toBeCloseTo(1.02); |
| 8 | expect(median([4, 1, 3, 2])).toBe(2.5); |
| 9 | }); |