From 649a45386492c58b2aa2f9a88e64a4f2e793f85b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Wed, 29 Jan 2025 13:20:58 +0100 Subject: [PATCH] refactor: order utils.ts helpers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/utils.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 782abea..ce9f8ad 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -265,6 +265,13 @@ const quantileSorted = (samples: number[], q: number) => { return samples[baseIndex] } +/** + * Computes the median of a sorted sample. + * @param samples - the sorted sample + * @returns the median of the sample + */ +const medianSorted = (samples: number[]) => quantileSorted(samples, 0.5) + /** * Computes the median of a sample. * @param samples - the sample @@ -274,13 +281,6 @@ const median = (samples: number[]) => { return medianSorted(samples.sort((a, b) => a - b)) } -/** - * Computes the median of a sorted sample. - * @param samples - the sorted sample - * @returns the median of the sample - */ -const medianSorted = (samples: number[]) => quantileSorted(samples, 0.5) - /** * Computes the absolute deviation of a sample given an aggregation. * @param samples - the sample