UNPKG

calculate-correlation

Version:

Calculates the correlation coefficient of two arrays. Simple, with no dependencies

4 lines (3 loc) 198 B
// idea from https://www.w3resource.com/javascript-exercises/javascript-math-exercise-14.php module.exports = (num, dec) => Math.round(num * 10 ** dec + (num >= 0 ? 1 : -1) * 0.0001) / 10 ** dec;