lib/eep.fn.stats.js
function StdevFunction(win) {
  var self = this, m, m2, d, n;
  self.name = "stdevs";
  self.type = "simple";
  self.init = function() { m = 0, m2 = 0, d = 0, n = 0; };
  self.accumulate = function(v) {
    n+=1; 
    d = v - m;
    m = m + d/n;
    m2 = m2 + d*(v-m);
  };
  self.compensate = function(v) {
    n-=1;
    d = m - v;
    m = d/n + m;
    m2 = d*(v-m) + m2;
  };
  self.emit = function()  { return Math.sqrt(m2/(n-1)); };
  self.make = function(win) { return new StdevFunction(win); };
}
function StdevFunction(win) {
  var self = this, m, m2, d, n;
  self.name = "stdevs";
  self.type = "simple";
  self.init = function() { m = 0, m2 = 0, d = 0, n = 0; };
  self.accumulate = function(v) {
    n+=1; 
    d = v - m;
    m = m + d/n;
    m2 = m2 + d*(v-m);
  };
  self.compensate = function(v) {
    n-=1;
    d = m - v;
    m = d/n + m;
    m2 = d*(v-m) + m2;
  };
  self.emit = function()  { return Math.sqrt(m2/(n-1)); };
  self.make = function(win) { return new StdevFunction(win); };
}
function StdevFunction ( win ) { var self = this , m , m2 , d , n ; self . name = "stdevs" ; self . type = "simple" ; self . init = function ( ) { m = 0 , m2 = 0 , d = 0 , n = 0 ; } ; self . accumulate = function ( v ) { n += 1 ; d = v - m ; m = m + d / n ; m2 = m2 + d * ( v - m ) ; } ; self . compensate = function ( v ) { n -= 1 ; d = m - v ; m = d / n + m ; m2 = d * ( v - m ) + m2 ; } ; self . emit = function ( ) { return Math . sqrt ( m2 / ( n - 1 ) ) ; } ; self . make = function ( win ) { return new StdevFunction ( win ) ; } ; }
Get the standard deviation of all the things
Get the standard deviation of all the things