UNPKG

als-statistics

Version:

Modular JS statistics toolkit for Node.js and the browser: descriptive stats, correlations (Pearson/Spearman/Kendall), t-tests & ANOVA (Student/Welch), reliability (Cronbach’s alpha), regression (linear/logistic), clustering (DBSCAN/HDBSCAN), and table/co

22 lines (17 loc) 723 B
import test from 'node:test'; import assert from 'node:assert/strict'; import MU from '../../../lib/analyze/regression/matrix-utils.js'; test('matrix-utils: базовая алгебра', () => { const A = [[1,2],[3,4]]; const B = [[5,6],[7,8]]; const AT = MU.transpose(A); assert.deepEqual(AT, [[1,3],[2,4]]); const AB = MU.multiply(A,B); assert.deepEqual(AB, [[19,22],[43,50]]); }); test('matrix-utils: solve выбрасывает на вырожденной матрице', () => { if (!MU.solve) return; // если solve нет — пропускаем const A = [[1,2],[2,4]]; // rank 1 const b = [1,2]; assert.throws(() => MU.solve(A,b), /singular|rank|invert/i); });