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

27 lines (23 loc) 787 B
import test from 'node:test'; import assert from 'node:assert/strict'; import CDF from '../../lib/analyze/cdf/index.js'; test('phi: symmetry and infinities', () => { assert.equal(CDF.phi(-Infinity), 0); assert.equal(CDF.phi(Infinity), 1); assert.ok(Math.abs(CDF.phi(0) - 0.5) < 1e-6); const x = 1.2345; assert.ok(Math.abs(CDF.phi(-x) - (1 - CDF.phi(x))) < 1e-12); }); test('t CDF: df behavior', () => { assert.ok(Math.abs(CDF.t(0, 1) - 0.5) < 1e-12); assert.ok(Math.abs(CDF.t(0, 30) - 0.5) < 1e-12); assert.ok(CDF.t(5, 1) > 0.93); assert.ok(CDF.t(-5, 1) < 0.07); }); test('F CDF: tails and df>0', () => { // Right tail ~ 0 at huge x const c = CDF.f(1e9, 5, 10); assert.ok(1 - c < 1e-12); // Left tail ~ 0 at x ~ 0 assert.ok(CDF.f(1e-9, 5, 10) < 1e-6); });