import { shapiroWilk } from './normality.js' import { Vector } from './vector.js' describe('Normality', () => { const w = new Vector([ 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.3, 0.2, 0.2, 0.1, 0.2, 0.2, 0.1, 0.1, 0.2, 0.4, 0.4, 0.3, 0.3, 0.3, 0.2, 0.4, 0.2, 0.5, 0.2, 0.2, 0.4, 0.2, 0.2, 0.2, 0.2, 0.4, 0.1, 0.2, 0.2, 0.2, 0.2, 0.1, 0.2, 0.2, 0.3, 0.3, 0.2, 0.6, 0.4, 0.3, 0.2, 0.2, 0.2, 0.2, 1.4, 1.5, 1.5, 1.3, 1.5, 1.3, 1.6, 1, 1.3, 1.4, 1, 1.5, 1, 1.4, 1.3, 1.4, 1.5, 1, 1.5, 1.1, 1.8, 1.3, 1.5, 1.2, 1.3, 1.4, 1.4, 1.7, 1.5, 1, 1.1, 1, 1.2, 1.6, 1.5, 1.6, 1.5, 1.3, 1.3, 1.3, 1.2, 1.4, 1.2, 1, 1.3, 1.2, 1.3, 1.3, 1.1, 1.3, 2.5, 1.9, 2.1, 1.8, 2.2, 2.1, 1.7, 1.8, 1.8, 2.5, 2, 1.9, 2.1, 2, 2.4, 2.3, 1.8, 2.2, 2.3, 1.5, 2.3, 2, 2, 1.8, 2.1, 1.8, 1.8, 1.8, 2.1, 1.6, 1.9, 2, 2.2, 1.5, 1.4, 2.3, 2.4, 1.8, 1.8, 2.1, 2.4, 2.3, 1.9, 2.3, 2.5, 2.3, 1.9, 2, 2.3, 1.8, ]) const sw = shapiroWilk(w) const c = new Vector([1, 2, 3, 4]) const sc = shapiroWilk(c) const b = new Vector([ 36.58, 36.73, 36.93, 37.15, 37.23, 37.24, 37.24, 36.9, 36.95, 36.89, 36.95, 37, 36.9, 36.99, 36.99, 37.01, 37.04, 37.04, 37.14, 37.07, 36.98, 37.01, 36.97, 36.97, 37.12, 37.13, 37.14, 37.15, 37.17, 37.12, 37.12, 37.17, 37.28, 37.28, 37.44, 37.51, 37.64, 37.51, 37.98, 38.02, 38, 38.24, 38.1, 38.24, 38.11, 38.02, 38.11, 38.01, 37.91, 37.96, 38.03, 38.17, 38.19, 38.18, 38.15, 38.04, 37.96, 37.84, 37.83, 37.84, 37.74, 37.76, 37.76, 37.64, 37.63, 38.06, 38.19, 38.35, 38.25, 37.86, 37.95, 37.95, 37.76, 37.6, 37.89, 37.86, 37.71, 37.78, 37.82, 37.76, 37.81, 37.84, 38.01, 38.1, 38.15, 37.92, 37.64, 37.7, 37.46, 37.41, 37.46, 37.56, 37.55, 37.75, 37.76, 37.73, 37.77, 38.01, 38.04, 38.07, ]) const sb = shapiroWilk(b) it('should return the correct W statistic', () => { expect(sw.w).toBeCloseTo(0.901_8, 4) expect(sc.w).toBeCloseTo(0.992_9, 4) expect(sb.w).toBeCloseTo(0.933_4, 4) }) it('should return the correct p value', () => { expect(sw.p).toBeCloseTo(0.000_000_017, 9) expect(sc.p).toBeCloseTo(0.971_9, 4) expect(sb.p).toBeCloseTo(0.000_078, 6) }) })