Skip to content

compute mprod

kgryte edited this page May 12, 2015 · 1 revision

Computes a moving product over an array.

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

var arr = compute.mprod( data, 2 );
// returns [ 8, 8, 14, 21 ]

For object arrays, provide an accessor function for accessing array values

var data = [
	[2],
	[1],
	[3]
];

function getValue( d ) {
	return d[ 0 ];
}

var arr = compute.mprod( data, 2, getValue );
// returns [ 2, 3 ]
Clone this wiki locally