UNPKG

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

10 lines (9 loc) 290 B
function slopeByIndex(arr) { if (arr.length < 2) return 0; const firstIndex = 0; const lastIndex = arr.length - 1; const deltaY = arr[lastIndex] - arr[firstIndex]; const deltaX = lastIndex - firstIndex; return deltaY / deltaX; } export default slopeByIndex