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

26 lines (23 loc) 991 B
// Дет- кейсы для CDF/PPF. Генерация не нужна: фиксируем набор точек. import CDF from '../../../lib/analyze/cdf/index.js'; const cases = [ { dist:'norm', fn:'phi', args:[-2.0] }, { dist:'norm', fn:'phi', args:[0.0] }, { dist:'norm', fn:'phi', args:[1.5] }, { dist:'t', fn:'t', args:[2.0, 10] }, { dist:'t', fn:'t', args:[3.0, 5] }, { dist:'f', fn:'f', args:[2.0, 4, 20] }, { dist:'f', fn:'f', args:[5.5, 2, 12] }, ]; export const cdfTool = { id: 'cdf', cases: cases.length, gen(seed, i) { return cases[i]; }, compute(c) { if (c.fn === 'phi') return { y: CDF.phi(c.args[0]) }; if (c.fn === 't') return { y: CDF.t(c.args[0], c.args[1]) }; if (c.fn === 'f') return { y: 1 - CDF.f(c.args[0], c.args[1], c.args[2]) /* правохвост */ }; throw new Error('unknown cdf case'); }, compare(exp, got, approx) { approx(got.y, exp.y); }, };