From 850e46c9ad002f81ba1edd2529be571a8bb12d68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 29 Sep 2024 20:39:58 +0200 Subject: [PATCH] refactor: median() -> medianSorted() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/lib.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib.js b/src/lib.js index 86776a0..d8a7bb8 100644 --- a/src/lib.js +++ b/src/lib.js @@ -299,7 +299,7 @@ const average = arr => { return arr.reduce((a, b) => a + b, 0) / arr.length } -const median = arr => { +const medianSorted = arr => { return quantileSorted(arr, 0.5) } @@ -365,7 +365,7 @@ const buildStats = samples => { samples: samples.length, min: samples[0], max: samples[samples.length - 1], - p50: median(samples), + p50: medianSorted(samples), p75: quantileSorted(samples, 0.75), p99: quantileSorted(samples, 0.99), p995: quantileSorted(samples, 0.995), @@ -375,7 +375,7 @@ const buildStats = samples => { sd, rmoe, aad: absoluteDeviation(samples, average), - mad: absoluteDeviation(samples, median), + mad: absoluteDeviation(samples, medianSorted), ss: samples.length >= minimumSamples, } }