Skip to content

onlinestats/online-covariance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

online-covariance

Covariance calculation (piece-by-piece) Based on online algorithm from wiki

Usage

Use a parameter ddof: 1 to calculate sample covariance, ddof: 0 (default) - to get population covariance

const Cov = require('online-covariance')
const cov = Cov({ddof: 1})

const a = [1, 3, 2, 5, 8, 7, 12, 2, 4]
const b = [8, 6, 9, 4, 3, 3, 2, 7, 7]

a.forEach((x, i) => { cov(x, b[i]) })

console.log('Unbiased covariance: ', cov()) // -> -8.069

About

Online covariance calculation (piece-by-piece)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published