distributions-poisson-cdf
Version:
Poisson distribution cumulative distribution function (CDF).
37 lines (28 loc) • 790 B
JavaScript
;
// MODULES //
var partial = require( './partial.js' );
// CDF //
/**
* FUNCTION: cdf( out, matrix, lambda )
* Evaluates the cumulative distribution function (CDF) for a Poisson distribution with mean parameter `lambda` for each matrix element.
*
* @param {Matrix} out - output matrix
* @param {Matrix} arr - input matrix
* @param {Number} lambda - mean parameter
* @returns {Matrix} output matrix
*/
function cdf( y, x, lambda ) {
var len = x.length,
fcn,
i;
if ( y.length !== len ) {
throw new Error( 'cdf()::invalid input arguments. Input and output matrices must be the same length.' );
}
fcn = partial( lambda );
for ( i = 0; i < len; i++ ) {
y.data[ i ] = fcn( x.data[ i ] );
}
return y;
} // end FUNCTION cdf()
// EXPORTS //
module.exports = cdf;