Skip to content

compute incrmsum

kgryte edited this page May 12, 2015 · 1 revision

Returns a method to compute a moving sum incrementally. window sets the window size, i.e., the number of values over which to compute a moving sum.

var data = [ 2, 4, 2, 7, 3 ];

var msum = compute.incrmsum( 3 ),
	sum;

for ( var i = 0; i < data.length; i++ ) {
	sum = msum( data[ i ] );
	console.log( sum );
}
console.log( msum() );
Clone this wiki locally