Skip to content

Commit b52b7b5

Browse files
committed
improved test coverage
1 parent d729d24 commit b52b7b5

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,4 +343,29 @@ public void testWelchsTTestDoubles() {
343343
assertEquals(1.57, (Double)result[0], 0.01);
344344
assertEquals(9, ((Integer)result[1]).intValue());
345345
}
346+
347+
@Test
348+
public void testWelchsTTestInts() {
349+
int[] a1 = {2, 4, 7, 1, 8, 10, 11, 6, 2, 9, 1, 23, 12, 0, 7};
350+
int[] a2 = {17, 2, 8, 19, 12, 4, 2, 0, 22, 7, 7, 1, 9, 12, 13};
351+
assertEquals(-0.9173, Statistics.tTestUnequalVariances(a1, a2), 0.0001);
352+
assertEquals(0.9173, Statistics.tTestUnequalVariances(a2, a1), 0.0001);
353+
int[] b1 = {2, 4, 7, 1, 8, 10, 11, 6, 2, 9};
354+
int[] b2 = {17, 2, 8, 19, 12, 4, 2, 0, 22, 7, 7, 1, 9, 12, 13, 0, 14, 1, 6, 30};
355+
assertEquals(-1.5369, Statistics.tTestUnequalVariances(b1, b2), 0.0001);
356+
assertEquals(1.5369, Statistics.tTestUnequalVariances(b2, b1), 0.0001);
357+
358+
Number[] result = Statistics.tTestWelch(a1, a2);
359+
assertEquals(-0.9173, (Double)result[0], 0.0001);
360+
assertEquals(27, ((Integer)result[1]).intValue());
361+
result = Statistics.tTestWelch(a2, a1);
362+
assertEquals(0.9173, (Double)result[0], 0.0001);
363+
assertEquals(27, ((Integer)result[1]).intValue());
364+
result = Statistics.tTestWelch(b1, b2);
365+
assertEquals(-1.5369, (Double)result[0], 0.0001);
366+
assertEquals(27, ((Integer)result[1]).intValue());
367+
result = Statistics.tTestWelch(b2, b1);
368+
assertEquals(1.5369, (Double)result[0], 0.0001);
369+
assertEquals(27, ((Integer)result[1]).intValue());
370+
}
346371
}

0 commit comments

Comments
 (0)