UNPKG

distributions-lognormal-pdf

Version:

Lognormal distribution probability density function (PDF)

38 lines (29 loc) 867 B
'use strict'; // MODULES // var partial = require( './partial.js' ); // PDF // /** * FUNCTION: pdf( out, matrix, mu, sigma ) * Evaluates the probability density function (PDF) for a Lognormal distribution with location parameter `mu` and scale parameter `sigma` for each matrix element. * * @param {Matrix} out - output matrix * @param {Matrix} arr - input matrix * @param {Number} mu - location parameter * @param {Number} sigma - scale parameter * @returns {Matrix} output matrix */ function pdf( y, x, mu, sigma ) { var len = x.length, fcn, i; if ( y.length !== len ) { throw new Error( 'pdf()::invalid input arguments. Input and output matrices must be the same length.' ); } fcn = partial( mu, sigma ); for ( i = 0; i < len; i++ ) { y.data[ i ] = fcn( x.data[ i ] ); } return y; } // end FUNCTION pdf() // EXPORTS // module.exports = pdf;