Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Sep 26, 2021
1 parent ed63d2d commit 13601ac
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/stats/outliers/indexes.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { THRESHOLDS, isOutlier } from './threshold.js'
export const getThresholdsIndexes = function (quantiles, quantilesCount) {
// eslint-disable-next-line fp/no-mutating-methods
const reversedQuantiles = [...quantiles].reverse()
const outliersLimit = Math.max(Math.floor(quantilesCount * OUTLIERS_LIMIT), 1)
const outliersLimit = getOutliersLimit(quantilesCount)

return THRESHOLDS.reduce(
(thresholdsIndexes, threshold) =>
Expand All @@ -50,6 +50,10 @@ export const getThresholdsIndexes = function (quantiles, quantilesCount) {
)
}

const getOutliersLimit = function (quantilesCount) {
return Math.max(Math.floor(quantilesCount * OUTLIERS_LIMIT), 1)
}

// Computes the index where outliers start on each side.
// The main criteria to consider whether a quantile is likely to be an outlier
// or not is:
Expand Down

0 comments on commit 13601ac

Please sign in to comment.