UNPKG

nstatistics

Version:

Solve equations using numerical methods, linear álgebra and solver of linear equation system

19 lines (17 loc) 530 B
const { matrix } = require('lalgebra'); function media() { const unitData = matrix.create(this.ndata, 1, () => 1); const data = this.dataMatrix(); return unitData.trans().x(data).x(1 / this.ndata).trans(); } module.exports = function(cb) { const self = this; if (typeof cb !== 'function') return media.call(self); return new Promise((full, rej) => { try { full(cb.call(self, null, media.call(self))); } catch (e) { rej(cb.call(self, e, null)); } }); };