Calculate correlation between two variables
Online (piece by piece)
const corr = require('online-correlation')
const c = corr()
const a = [1, 3, 2, 5, 8, 7, 12, 2, 4]
const b = [8, 6, 9, 4, 3, 3, 2, 7, 7]
a.forEach((_, i) => {
c(a[i], b[i])
})
const res = c()
console.log(res) // -0.9069
Arrays (passing arrays)
const corr = require('online-correlation')
const c = corr()
const a = [1, 3, 2, 5, 8, 7, 12, 2, 4]
const b = [8, 6, 9, 4, 3, 3, 2, 7, 7]
const res = c(a, b)
console.log(res) // -0.9069
or
const res = corr()(a, b)