Skip to content

Commit

Permalink
refactor: order utils.ts helpers
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 Jan 29, 2025
1 parent 90a8af7 commit 649a453
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 649a453

Please sign in to comment.