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
21 lines (17 loc) • 695 B
JavaScript
import { describe, it } from 'node:test';
import assert from 'node:assert';
import CDF from '../../../lib/analyze/cdf/index.js';
function approx(a,b,eps=1e-7){ assert.ok(Math.abs(a-b) <= eps*(1+Math.max(Math.abs(a),Math.abs(b))), `~${b}, got ${a}`); }
describe('Normal CDF: CDF.phi', () => {
it('basic points', () => {
approx(CDF.phi(0), 0.5, 1e-7);
approx(CDF.phi(1.5), 0.9331927987311419, 1e-7);
approx(CDF.phi(-2.0), 0.02275013194817921, 1e-7);
});
it('tails', () => {
assert.strictEqual(CDF.phi(Infinity), 1);
assert.strictEqual(CDF.phi(-Infinity), 0);
assert.strictEqual(CDF.phi(9), 1);
assert.strictEqual(CDF.phi(-9), 0);
});
});