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

28 lines (25 loc) 947 B
import test from 'node:test'; import assert from 'node:assert/strict'; import { OneWayAnova } from '../../lib/analyze/compare-means/one-way-anova.js'; test('ANOVA: equal means → small F, p≈1', () => { const groups = { A: [1,2,3,4,5], B: [1,2,3,4,5].map(x=>x+0), // same mean C: [1,2,3,4,5].map(x=>x+0) }; const a = new OneWayAnova(groups, false); assert.ok(a.F >= 0); assert.ok(a.p <= 1 && a.p >= 0); assert.ok(a.p > 0.2); // не значимо }); test('Welch vs classic differ under unequal variances', () => { const G1 = [10, 11, 9, 10]; const G2 = [10, 30, -10, 50, -20]; const G3 = [12, 13, 12, 11, 14]; const classic = new OneWayAnova({ G1, G2, G3 }, false); const welch = new OneWayAnova({ G1, G2, G3 }, true); assert.notEqual(classic.dfWithin, welch.dfWithin); assert.notEqual(classic.F, welch.F); assert.ok(classic.p >= 0 && classic.p <= 1); assert.ok(welch.p >= 0 && welch.p <= 1); });