Returns an accumulator function which incrementally computes a moving unbiased sample covariance.
W
parameter defines the number of values over which to compute the moving unbiased sample covariance.W
(x,y) pairs are needed to fill the window buffer, the first W-1
returned values are calculated from smaller sample sizes. Until the window is full, each returned value is calculated from all provided values.window size
mean value
mean value
accumulator function
var accumulator = incrmcovariance( 3, -2.0, 10.0 );
Returns an accumulator function which incrementally computes a moving unbiased sample covariance.
W
parameter defines the number of values over which to compute the moving unbiased sample covariance.W
(x,y) pairs are needed to fill the window buffer, the first W-1
returned values are calculated from smaller sample sizes. Until the window is full, each returned value is calculated from all provided values.window size
accumulator function
var accumulator = incrmcovariance( 3 );
var v = accumulator();
// returns null
v = accumulator( 2.0, 1.0 );
// returns 0.0
v = accumulator( -5.0, 3.14 );
// returns ~-7.49
v = accumulator( 3.0, -1.0 );
// returns -8.35
v = accumulator( 5.0, -9.5 );
// returns -29.42
v = accumulator();
// returns -29.42
If provided arguments, returns an updated moving unbiased sample covariance; otherwise, returns the current moving unbiased sample covariance.
Notes
NaN
or a value which, when used in computations, results inNaN
, the accumulated value isNaN
for all future invocations.value
value
moving unbiased sample covariance