Skip to content

Commit

Permalink
refactor: median() -> medianSorted()
Browse files Browse the repository at this point in the history
Signed-off-by: Jérôme Benoit <[email protected]>
  • Loading branch information
jerome-benoit committed Sep 29, 2024
1 parent c5e2c8e commit 850e46c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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),
Expand All @@ -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,
}
}

0 comments on commit 850e46c

Please sign in to comment.