You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ps...@apache.org on 2004/05/23 07:06:20 UTC
cvs commit: jakarta-commons/math/src/test/org/apache/commons/math/stat/inference TTestTest.java
psteitz 2004/05/22 22:06:20
Modified: math/src/test/org/apache/commons/math/stat/inference
TTestTest.java
Log:
Added test case for small samples, adjusted for PR #29050 changes.
Revision Changes Path
1.2 +13 -6 jakarta-commons/math/src/test/org/apache/commons/math/stat/inference/TTestTest.java
Index: TTestTest.java
===================================================================
RCS file: /home/cvs/jakarta-commons/math/src/test/org/apache/commons/math/stat/inference/TTestTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TTestTest.java 3 May 2004 03:04:54 -0000 1.1
+++ TTestTest.java 23 May 2004 05:06:20 -0000 1.2
@@ -91,29 +91,28 @@
double[] tooShortObs = { 1.0 };
try {
testStatistic.t(mu, tooShortObs);
- fail("arguments too short, IllegalArgumentException expected");
+ fail("insufficient data to compute t statistic, IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
// exptected
}
try {
testStatistic.tTest(mu, tooShortObs);
- fail("arguments too short, IllegalArgumentException expected");
+ fail("insufficient data to perform t test, IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
// expected
}
SummaryStatistics tooShortStats = SummaryStatistics.newInstance();
tooShortStats.addValue(0d);
- tooShortStats.addValue(2d);
try {
testStatistic.t(mu, tooShortStats);
- fail("arguments too short, IllegalArgumentException expected");
+ fail("insufficient data to compute t statistic, IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
// exptected
}
try {
testStatistic.tTest(mu, tooShortStats);
- fail("arguments too short, IllegalArgumentException expected");
+ fail("insufficient data to perform t test, IllegalArgumentException expected");
} catch (IllegalArgumentException ex) {
// exptected
}
@@ -224,5 +223,13 @@
} catch (IllegalArgumentException ex) {
// 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);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org