@Test public void testTwoSampleTHomoscedastic() { double[] sample1 = {2, 4, 6, 8, 10, 97}; double[] sample2 = {4, 6, 8, 10, 16}; SummaryStatistics sampleStats1 = new SummaryStatistics(); for (int i = 0; i < sample1.length; i++) { sampleStats1.addValue(sample1[i]); } SummaryStatistics sampleStats2 = new SummaryStatistics(); for (int i = 0; i < sample2.length; i++) { sampleStats2.addValue(sample2[i]); } // Target comparison values computed using R version 1.8.1 (Linux version) Assert.assertEquals( "two sample homoscedastic t stat", 0.73096310086, TestUtils.homoscedasticT(sample1, sample2), 10E-11); Assert.assertEquals( "two sample homoscedastic p value", 0.4833963785, TestUtils.homoscedasticTTest(sampleStats1, sampleStats2), 1E-10); Assert.assertTrue( "two sample homoscedastic t-test reject", TestUtils.homoscedasticTTest(sample1, sample2, 0.49)); Assert.assertTrue( "two sample homoscedastic t-test accept", !TestUtils.homoscedasticTTest(sample1, sample2, 0.48)); }