als-statistics
Version:
Modular JS statistics toolkit for Node.js and the browser: descriptive stats, correlations (Pearson/Spearman/Kendall), t-tests & ANOVA (Student/Welch), reliability (Cronbach’s alpha), regression (linear/logistic), clustering (DBSCAN/HDBSCAN), and table/co
15 lines (14 loc) • 654 B
JavaScript
function outliersZScore({ zScores, values }, threshold = 3, twoFactors = true, below = false) {
const outliers = [], indexes = [], zs = [];
for (let i = 0; i < zScores.length; i++) {
const zi = zScores[i];
const z = twoFactors ? Math.abs(zi) : zi;
const isOutlier = twoFactors
? (z > threshold) && (!below || zi < -threshold) // если below=true — только «нижние»
: (below ? (zi < -threshold) : (zi > threshold));
if (!isOutlier) continue;
outliers.push(values[i]); indexes.push(i); zs.push(zi);
}
return { values: outliers, indexes, zScores: zs };
}
export default outliersZScore