Skip to content

Commit d729d24

Browse files
committed
improved test coverage
1 parent 97b24db commit d729d24

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/org/cicirello/math/stats/StatisticsTests.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,4 +315,32 @@ public void testCorrelationMatrixOfDoubles() {
315315
}
316316
}
317317
}
318+
319+
@Test
320+
public void testWelchsTTestDoubles() {
321+
double[] a1 = {27.5, 21.0, 19.0, 23.6, 17.0, 17.9,
322+
16.9, 20.1, 21.9, 22.6, 23.1, 19.6, 19.0, 21.7, 21.4};
323+
double[] a2 = {27.1, 22.0, 20.8, 23.4, 23.4, 23.5,
324+
25.8, 22.0, 24.8, 20.2, 21.9, 22.1, 22.9, 20.5, 24.4};
325+
assertEquals(-2.46, Statistics.tTestUnequalVariances(a1, a2), 0.01);
326+
assertEquals(2.46, Statistics.tTestUnequalVariances(a2, a1), 0.01);
327+
double[] b1 = {17.2, 20.9, 22.6, 18.1, 21.7, 21.4, 23.5, 24.2, 14.7, 21.8};
328+
double[] b2 = {21.5, 22.8, 21.0, 23.0, 21.6, 23.6, 22.5, 20.7, 23.4, 21.8,
329+
20.7, 21.7, 21.5, 22.5, 23.6, 21.5, 22.5, 23.5, 21.5, 21.8};
330+
assertEquals(-1.57, Statistics.tTestUnequalVariances(b1, b2), 0.01);
331+
assertEquals(1.57, Statistics.tTestUnequalVariances(b2, b1), 0.01);
332+
333+
Number[] result = Statistics.tTestWelch(a1, a2);
334+
assertEquals(-2.46, (Double)result[0], 0.01);
335+
assertEquals(24, ((Integer)result[1]).intValue());
336+
result = Statistics.tTestWelch(a2, a1);
337+
assertEquals(2.46, (Double)result[0], 0.01);
338+
assertEquals(24, ((Integer)result[1]).intValue());
339+
result = Statistics.tTestWelch(b1, b2);
340+
assertEquals(-1.57, (Double)result[0], 0.01);
341+
assertEquals(9, ((Integer)result[1]).intValue());
342+
result = Statistics.tTestWelch(b2, b1);
343+
assertEquals(1.57, (Double)result[0], 0.01);
344+
assertEquals(9, ((Integer)result[1]).intValue());
345+
}
318346
}

0 commit comments

Comments
 (0)