Skip to content

Calculate population or sample variance with online algorithm (process input piece-by-piece)

Notifications You must be signed in to change notification settings

onlinestats/online-variance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

online-variance

Online variance calculation (piece-by-piece) Based on online Welford's algorithm

Usage

const Variance = require('online-variance')
const v = Variance()
;[1,2,3,4,5].forEach(value => { v(value) })

console.log('Population variance:', v()) // -> 2

Population vs Sample variance

Use a parameter ddof: 1 to calculate sample variance

const Variance = require('online-variance')
const v = Variance({ddof: 1}) // Delta degrees of freedom. The divisor used in calculations (N - ddof), where N - number of elements
;[1,2,3,4,5].forEach(value => { v(value) })

console.log('Sample variance:', v()) // -> 2.5

About

Calculate population or sample variance with online algorithm (process input piece-by-piece)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published