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
26 lines (20 loc) • 857 B
JavaScript
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
import { approx1e8, approx1e6 } from './_approx.js';
import { ALL_TOOLS, EPS } from './registry.js';
import test from 'node:test'
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const GOLDEN = path.join(__dirname, 'golden_v2.json');
// мапа id -> tool
const byId = Object.fromEntries(ALL_TOOLS.map(t => [t.id, t]));
const golden = JSON.parse(fs.readFileSync(GOLDEN, 'utf-8'));
for (const rec of golden.records) {
const tool = byId[rec.tool];
if (!tool) throw new Error(`Unknown tool in golden: ${rec.tool}`);
const approx = (rec.tool === 'cronbach') ? approx1e6 : approx1e8;
test(`golden ${rec.tool} #${rec.i}`, () => {
const fresh = tool.compute(rec.input);
tool.compare(rec.result, fresh, approx);
});
}