replaced calls to deprecated SummaryStatistics.newInstance() method
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@610795 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4d498d1bdd
commit
d4101572a6
|
@ -33,7 +33,7 @@ public class TTestTest extends TestCase {
|
||||||
|
|
||||||
private double[] tooShortObs = { 1.0 };
|
private double[] tooShortObs = { 1.0 };
|
||||||
private double[] emptyObs = {};
|
private double[] emptyObs = {};
|
||||||
private SummaryStatistics emptyStats = SummaryStatistics.newInstance();
|
private SummaryStatistics emptyStats = new SummaryStatistics();
|
||||||
SummaryStatistics tooShortStats = null;
|
SummaryStatistics tooShortStats = null;
|
||||||
|
|
||||||
public TTestTest(String name) {
|
public TTestTest(String name) {
|
||||||
|
@ -41,7 +41,7 @@ public class TTestTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
tooShortStats = SummaryStatistics.newInstance();
|
tooShortStats = new SummaryStatistics();
|
||||||
tooShortStats.addValue(0d);
|
tooShortStats.addValue(0d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ public class TTestTest extends TestCase {
|
||||||
{93.0, 103.0, 95.0, 101.0, 91.0, 105.0, 96.0, 94.0, 101.0, 88.0, 98.0, 94.0, 101.0, 92.0, 95.0 };
|
{93.0, 103.0, 95.0, 101.0, 91.0, 105.0, 96.0, 94.0, 101.0, 88.0, 98.0, 94.0, 101.0, 92.0, 95.0 };
|
||||||
double mu = 100.0;
|
double mu = 100.0;
|
||||||
SummaryStatistics sampleStats = null;
|
SummaryStatistics sampleStats = null;
|
||||||
sampleStats = SummaryStatistics.newInstance();
|
sampleStats = new SummaryStatistics();
|
||||||
for (int i = 0; i < observed.length; i++) {
|
for (int i = 0; i < observed.length; i++) {
|
||||||
sampleStats.addValue(observed[i]);
|
sampleStats.addValue(observed[i]);
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ public class TTestTest extends TestCase {
|
||||||
testStatistic.t(mu, tooShortObs);
|
testStatistic.t(mu, tooShortObs);
|
||||||
fail("insufficient data to compute t statistic, IllegalArgumentException expected");
|
fail("insufficient data to compute t statistic, IllegalArgumentException expected");
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (IllegalArgumentException ex) {
|
||||||
// exptected
|
// expected
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
testStatistic.tTest(mu, tooShortObs);
|
testStatistic.tTest(mu, tooShortObs);
|
||||||
|
@ -116,20 +116,20 @@ public class TTestTest extends TestCase {
|
||||||
testStatistic.t(mu, tooShortStats);
|
testStatistic.t(mu, tooShortStats);
|
||||||
fail("insufficient data to compute t statistic, IllegalArgumentException expected");
|
fail("insufficient data to compute t statistic, IllegalArgumentException expected");
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (IllegalArgumentException ex) {
|
||||||
// exptected
|
// expected
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
testStatistic.tTest(mu, tooShortStats);
|
testStatistic.tTest(mu, tooShortStats);
|
||||||
fail("insufficient data to perform t test, IllegalArgumentException expected");
|
fail("insufficient data to perform t test, IllegalArgumentException expected");
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (IllegalArgumentException ex) {
|
||||||
// exptected
|
// expected
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testOneSampleTTest() throws Exception {
|
public void testOneSampleTTest() throws Exception {
|
||||||
double[] oneSidedP =
|
double[] oneSidedP =
|
||||||
{2d, 0d, 6d, 6d, 3d, 3d, 2d, 3d, -6d, 6d, 6d, 6d, 3d, 0d, 1d, 1d, 0d, 2d, 3d, 3d };
|
{2d, 0d, 6d, 6d, 3d, 3d, 2d, 3d, -6d, 6d, 6d, 6d, 3d, 0d, 1d, 1d, 0d, 2d, 3d, 3d };
|
||||||
SummaryStatistics oneSidedPStats = SummaryStatistics.newInstance();
|
SummaryStatistics oneSidedPStats = new SummaryStatistics();
|
||||||
for (int i = 0; i < oneSidedP.length; i++) {
|
for (int i = 0; i < oneSidedP.length; i++) {
|
||||||
oneSidedPStats.addValue(oneSidedP[i]);
|
oneSidedPStats.addValue(oneSidedP[i]);
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ public class TTestTest extends TestCase {
|
||||||
testStatistic.tTest(0d, oneSidedP, 95);
|
testStatistic.tTest(0d, oneSidedP, 95);
|
||||||
fail("alpha out of range, IllegalArgumentException expected");
|
fail("alpha out of range, IllegalArgumentException expected");
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (IllegalArgumentException ex) {
|
||||||
// exptected
|
// expected
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -166,11 +166,11 @@ public class TTestTest extends TestCase {
|
||||||
public void testTwoSampleTHeterscedastic() throws Exception {
|
public void testTwoSampleTHeterscedastic() throws Exception {
|
||||||
double[] sample1 = { 7d, -4d, 18d, 17d, -3d, -5d, 1d, 10d, 11d, -2d };
|
double[] sample1 = { 7d, -4d, 18d, 17d, -3d, -5d, 1d, 10d, 11d, -2d };
|
||||||
double[] sample2 = { -1d, 12d, -1d, -3d, 3d, -5d, 5d, 2d, -11d, -1d, -3d };
|
double[] sample2 = { -1d, 12d, -1d, -3d, 3d, -5d, 5d, 2d, -11d, -1d, -3d };
|
||||||
SummaryStatistics sampleStats1 = SummaryStatistics.newInstance();
|
SummaryStatistics sampleStats1 = new SummaryStatistics();
|
||||||
for (int i = 0; i < sample1.length; i++) {
|
for (int i = 0; i < sample1.length; i++) {
|
||||||
sampleStats1.addValue(sample1[i]);
|
sampleStats1.addValue(sample1[i]);
|
||||||
}
|
}
|
||||||
SummaryStatistics sampleStats2 = SummaryStatistics.newInstance();
|
SummaryStatistics sampleStats2 = new SummaryStatistics();
|
||||||
for (int i = 0; i < sample2.length; i++) {
|
for (int i = 0; i < sample2.length; i++) {
|
||||||
sampleStats2.addValue(sample2[i]);
|
sampleStats2.addValue(sample2[i]);
|
||||||
}
|
}
|
||||||
|
@ -252,11 +252,11 @@ public class TTestTest extends TestCase {
|
||||||
public void testTwoSampleTHomoscedastic() throws Exception {
|
public void testTwoSampleTHomoscedastic() throws Exception {
|
||||||
double[] sample1 ={2, 4, 6, 8, 10, 97};
|
double[] sample1 ={2, 4, 6, 8, 10, 97};
|
||||||
double[] sample2 = {4, 6, 8, 10, 16};
|
double[] sample2 = {4, 6, 8, 10, 16};
|
||||||
SummaryStatistics sampleStats1 = SummaryStatistics.newInstance();
|
SummaryStatistics sampleStats1 = new SummaryStatistics();
|
||||||
for (int i = 0; i < sample1.length; i++) {
|
for (int i = 0; i < sample1.length; i++) {
|
||||||
sampleStats1.addValue(sample1[i]);
|
sampleStats1.addValue(sample1[i]);
|
||||||
}
|
}
|
||||||
SummaryStatistics sampleStats2 = SummaryStatistics.newInstance();
|
SummaryStatistics sampleStats2 = new SummaryStatistics();
|
||||||
for (int i = 0; i < sample2.length; i++) {
|
for (int i = 0; i < sample2.length; i++) {
|
||||||
sampleStats2.addValue(sample2[i]);
|
sampleStats2.addValue(sample2[i]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,14 +194,14 @@ public class TestUtilsTest extends TestCase {
|
||||||
|
|
||||||
private double[] tooShortObs = { 1.0 };
|
private double[] tooShortObs = { 1.0 };
|
||||||
private double[] emptyObs = {};
|
private double[] emptyObs = {};
|
||||||
private SummaryStatistics emptyStats = SummaryStatistics.newInstance();
|
private SummaryStatistics emptyStats = new SummaryStatistics();
|
||||||
|
|
||||||
public void testOneSampleT() throws Exception {
|
public void testOneSampleT() throws Exception {
|
||||||
double[] observed =
|
double[] observed =
|
||||||
{93.0, 103.0, 95.0, 101.0, 91.0, 105.0, 96.0, 94.0, 101.0, 88.0, 98.0, 94.0, 101.0, 92.0, 95.0 };
|
{93.0, 103.0, 95.0, 101.0, 91.0, 105.0, 96.0, 94.0, 101.0, 88.0, 98.0, 94.0, 101.0, 92.0, 95.0 };
|
||||||
double mu = 100.0;
|
double mu = 100.0;
|
||||||
SummaryStatistics sampleStats = null;
|
SummaryStatistics sampleStats = null;
|
||||||
sampleStats = SummaryStatistics.newInstance();
|
sampleStats = new SummaryStatistics();
|
||||||
for (int i = 0; i < observed.length; i++) {
|
for (int i = 0; i < observed.length; i++) {
|
||||||
sampleStats.addValue(observed[i]);
|
sampleStats.addValue(observed[i]);
|
||||||
}
|
}
|
||||||
|
@ -248,7 +248,7 @@ public class TestUtilsTest extends TestCase {
|
||||||
TestUtils.t(mu, tooShortObs);
|
TestUtils.t(mu, tooShortObs);
|
||||||
fail("insufficient data to compute t statistic, IllegalArgumentException expected");
|
fail("insufficient data to compute t statistic, IllegalArgumentException expected");
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (IllegalArgumentException ex) {
|
||||||
// exptected
|
// expected
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
TestUtils.tTest(mu, tooShortObs);
|
TestUtils.tTest(mu, tooShortObs);
|
||||||
|
@ -261,20 +261,20 @@ public class TestUtilsTest extends TestCase {
|
||||||
TestUtils.t(mu, (SummaryStatistics) null);
|
TestUtils.t(mu, (SummaryStatistics) null);
|
||||||
fail("insufficient data to compute t statistic, IllegalArgumentException expected");
|
fail("insufficient data to compute t statistic, IllegalArgumentException expected");
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (IllegalArgumentException ex) {
|
||||||
// exptected
|
// expected
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
TestUtils.tTest(mu, (SummaryStatistics) null);
|
TestUtils.tTest(mu, (SummaryStatistics) null);
|
||||||
fail("insufficient data to perform t test, IllegalArgumentException expected");
|
fail("insufficient data to perform t test, IllegalArgumentException expected");
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (IllegalArgumentException ex) {
|
||||||
// exptected
|
// expected
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testOneSampleTTest() throws Exception {
|
public void testOneSampleTTest() throws Exception {
|
||||||
double[] oneSidedP =
|
double[] oneSidedP =
|
||||||
{2d, 0d, 6d, 6d, 3d, 3d, 2d, 3d, -6d, 6d, 6d, 6d, 3d, 0d, 1d, 1d, 0d, 2d, 3d, 3d };
|
{2d, 0d, 6d, 6d, 3d, 3d, 2d, 3d, -6d, 6d, 6d, 6d, 3d, 0d, 1d, 1d, 0d, 2d, 3d, 3d };
|
||||||
SummaryStatistics oneSidedPStats = SummaryStatistics.newInstance();
|
SummaryStatistics oneSidedPStats = new SummaryStatistics();
|
||||||
for (int i = 0; i < oneSidedP.length; i++) {
|
for (int i = 0; i < oneSidedP.length; i++) {
|
||||||
oneSidedPStats.addValue(oneSidedP[i]);
|
oneSidedPStats.addValue(oneSidedP[i]);
|
||||||
}
|
}
|
||||||
|
@ -296,7 +296,7 @@ public class TestUtilsTest extends TestCase {
|
||||||
TestUtils.tTest(0d, oneSidedP, 95);
|
TestUtils.tTest(0d, oneSidedP, 95);
|
||||||
fail("alpha out of range, IllegalArgumentException expected");
|
fail("alpha out of range, IllegalArgumentException expected");
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (IllegalArgumentException ex) {
|
||||||
// exptected
|
// expected
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -311,11 +311,11 @@ public class TestUtilsTest extends TestCase {
|
||||||
public void testTwoSampleTHeterscedastic() throws Exception {
|
public void testTwoSampleTHeterscedastic() throws Exception {
|
||||||
double[] sample1 = { 7d, -4d, 18d, 17d, -3d, -5d, 1d, 10d, 11d, -2d };
|
double[] sample1 = { 7d, -4d, 18d, 17d, -3d, -5d, 1d, 10d, 11d, -2d };
|
||||||
double[] sample2 = { -1d, 12d, -1d, -3d, 3d, -5d, 5d, 2d, -11d, -1d, -3d };
|
double[] sample2 = { -1d, 12d, -1d, -3d, 3d, -5d, 5d, 2d, -11d, -1d, -3d };
|
||||||
SummaryStatistics sampleStats1 = SummaryStatistics.newInstance();
|
SummaryStatistics sampleStats1 = new SummaryStatistics();
|
||||||
for (int i = 0; i < sample1.length; i++) {
|
for (int i = 0; i < sample1.length; i++) {
|
||||||
sampleStats1.addValue(sample1[i]);
|
sampleStats1.addValue(sample1[i]);
|
||||||
}
|
}
|
||||||
SummaryStatistics sampleStats2 = SummaryStatistics.newInstance();
|
SummaryStatistics sampleStats2 = new SummaryStatistics();
|
||||||
for (int i = 0; i < sample2.length; i++) {
|
for (int i = 0; i < sample2.length; i++) {
|
||||||
sampleStats2.addValue(sample2[i]);
|
sampleStats2.addValue(sample2[i]);
|
||||||
}
|
}
|
||||||
|
@ -397,11 +397,11 @@ public class TestUtilsTest extends TestCase {
|
||||||
public void testTwoSampleTHomoscedastic() throws Exception {
|
public void testTwoSampleTHomoscedastic() throws Exception {
|
||||||
double[] sample1 ={2, 4, 6, 8, 10, 97};
|
double[] sample1 ={2, 4, 6, 8, 10, 97};
|
||||||
double[] sample2 = {4, 6, 8, 10, 16};
|
double[] sample2 = {4, 6, 8, 10, 16};
|
||||||
SummaryStatistics sampleStats1 = SummaryStatistics.newInstance();
|
SummaryStatistics sampleStats1 = new SummaryStatistics();
|
||||||
for (int i = 0; i < sample1.length; i++) {
|
for (int i = 0; i < sample1.length; i++) {
|
||||||
sampleStats1.addValue(sample1[i]);
|
sampleStats1.addValue(sample1[i]);
|
||||||
}
|
}
|
||||||
SummaryStatistics sampleStats2 = SummaryStatistics.newInstance();
|
SummaryStatistics sampleStats2 = new SummaryStatistics();
|
||||||
for (int i = 0; i < sample2.length; i++) {
|
for (int i = 0; i < sample2.length; i++) {
|
||||||
sampleStats2.addValue(sample2[i]);
|
sampleStats2.addValue(sample2[i]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue