als-statistics
Version:
A powerful and lightweight JavaScript library for descriptive statistics, regression, clustering, outlier detection, and noise analysis using a flexible table/column architecture.
13 lines (12 loc) • 456 B
JavaScript
function outliersZScore({ zScores, values },threshold = 3, twoFactors = true) {
const outliers = [], indexes = [], zs = [];
for (let i = 0; i < zScores.length; i++) {
const z = twoFactors ? Math.abs(zScores[i]) : zScores[i]
if (z <= threshold) continue
outliers.push(values[i]);
indexes.push(i)
zs.push(zScores[i])
}
return { values: outliers, indexes, zScores: zs };
}
module.exports = outliersZScore