Added test case for small samples, adjusted for PR #29050 changes.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/math/trunk@141240 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2552cb1aee
commit
414788a045
|
@ -23,7 +23,7 @@ import org.apache.commons.math.stat.univariate.SummaryStatistics;
|
||||||
/**
|
/**
|
||||||
* Test cases for the TTestImpl class.
|
* Test cases for the TTestImpl class.
|
||||||
*
|
*
|
||||||
* @version $Revision: 1.1 $ $Date: 2004/05/03 03:04:54 $
|
* @version $Revision: 1.2 $ $Date: 2004/05/23 05:06:20 $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public final class TTestTest extends TestCase {
|
public final class TTestTest extends TestCase {
|
||||||
|
@ -91,29 +91,28 @@ public final class TTestTest extends TestCase {
|
||||||
double[] tooShortObs = { 1.0 };
|
double[] tooShortObs = { 1.0 };
|
||||||
try {
|
try {
|
||||||
testStatistic.t(mu, tooShortObs);
|
testStatistic.t(mu, tooShortObs);
|
||||||
fail("arguments too short, IllegalArgumentException expected");
|
fail("insufficient data to compute t statistic, IllegalArgumentException expected");
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (IllegalArgumentException ex) {
|
||||||
// exptected
|
// exptected
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
testStatistic.tTest(mu, tooShortObs);
|
testStatistic.tTest(mu, tooShortObs);
|
||||||
fail("arguments too short, IllegalArgumentException expected");
|
fail("insufficient data to perform t test, IllegalArgumentException expected");
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (IllegalArgumentException ex) {
|
||||||
// expected
|
// expected
|
||||||
}
|
}
|
||||||
|
|
||||||
SummaryStatistics tooShortStats = SummaryStatistics.newInstance();
|
SummaryStatistics tooShortStats = SummaryStatistics.newInstance();
|
||||||
tooShortStats.addValue(0d);
|
tooShortStats.addValue(0d);
|
||||||
tooShortStats.addValue(2d);
|
|
||||||
try {
|
try {
|
||||||
testStatistic.t(mu, tooShortStats);
|
testStatistic.t(mu, tooShortStats);
|
||||||
fail("arguments too short, IllegalArgumentException expected");
|
fail("insufficient data to compute t statistic, IllegalArgumentException expected");
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (IllegalArgumentException ex) {
|
||||||
// exptected
|
// exptected
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
testStatistic.tTest(mu, tooShortStats);
|
testStatistic.tTest(mu, tooShortStats);
|
||||||
fail("arguments too short, IllegalArgumentException expected");
|
fail("insufficient data to perform t test, IllegalArgumentException expected");
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (IllegalArgumentException ex) {
|
||||||
// exptected
|
// exptected
|
||||||
}
|
}
|
||||||
|
@ -225,4 +224,12 @@ public final class TTestTest extends TestCase {
|
||||||
// expected
|
// expected
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testSmallSamples() throws Exception {
|
||||||
|
double[] sample1 = {1d, 3d};
|
||||||
|
double[] sample2 = {4d, 5d};
|
||||||
|
// Target values computed using R, version 1.8.1 (linux version)
|
||||||
|
assertEquals(-2.2361, testStatistic.t(sample1, sample2), 1E-4);
|
||||||
|
assertEquals(0.1987, testStatistic.tTest(sample1, sample2), 1E-4);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue