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
31 lines (29 loc) • 1.07 kB
JavaScript
// ПУТИ ИМПОРТОВ подстрой под свою библиотеку!
import { IndependentTTest } from '../../../lib/analyze/compare-means/independent-t-test.js';
import { makeRng } from '../_rng.js';
export const ttestTool = {
id: 'ttest',
cases: 8,
gen(seed, i) {
const R = makeRng(`${seed}/tt/${i}`);
const n1 = 12 + (i % 5);
const n2 = 10 + ((i + 2) % 5);
return { A: R.normal(0, 1, n1), B: R.normal(0.5, 1.8, n2) };
},
compute(input) {
const pooled = new IndependentTTest(input, false);
const welch = new IndependentTTest(input, true);
return {
pooled: { t: pooled.t, df: pooled.df, p: pooled.p, F: pooled.F },
welch: { t: welch.t, df: welch.df, p: welch.p, F: welch.F },
};
},
compare(expected, recomputed, approx) {
['pooled','welch'].forEach(k => {
approx(recomputed[k].t, expected[k].t);
approx(recomputed[k].df, expected[k].df);
approx(recomputed[k].p, expected[k].p);
approx(recomputed[k].F, expected[k].F);
});
},
};