import javastat.inference.twosamples.TwoSampMeansTTest;

 

/**

 *

 * <p>Example: class TwoSampMeansTTest.</p>

 * <p>Data Source: Anderson, D. R., Sweeney, D. J. and Williams, T. A. (2001).

 *    Contemporary Business Statistics with Microsoft Excel. South-Western,

 *    p. 395. </p>

 */

 

double[] testdata1 = {300, 280, 344, 385, 372, 360, 288, 321, 376, 290,

                  301, 283};

double[] testdata2 = {276, 222, 310, 338, 200, 302, 317, 260, 320, 312,

                  334, 265};

 

testclass1 = new TwoSampMeansTTest(0.05, 0, "equal", testdata1, testdata2);

testStatistic = testclass1.testStatistic;

pValue = testclass1.pValue;

lowerBound = testclass1.confidenceInterval[0];

upperBound = testclass1.confidenceInterval[1];

print("The test statistic (non-null constructor)         =  " + testStatistic);

print("The p-value (non-null constructor)             =  " + pValue);

print("The confidence interval (non-null constructor)   = [" +

     lowerBound + " , " + upperBound + "]");

 

testclass2 = new TwoSampMeansTTest();

confidenceInterval = testclass2.confidenceInterval(0.05, testdata1, testdata2);

testStatistic = testclass2.testStatistic(0, testdata1, testdata2);

pValue = testclass2.pValue(0, "greater", testdata1, testdata2);

print("The test statistic (null constructor)             =  " + testStatistic);

print("The p-value (null constructor)                 =  " + pValue);

print("The confidence interval (null constructor)       = [" +

     confidenceInterval[0] + " , " + confidenceInterval[1] + "]");

 

Results:

The test statistic based on non-null constructor         =  2.156

The p-value based on non-null constructor             =  0.042

The confidence interval based on non-null constructor   = [1.403 , 72.597]

The test statistic based on null constructor             =  2.156

The p-value based on null constructor                 =  0.021

The confidence interval based on null constructor       = [1.403 , 72.597]

 

See also:

Estimation of the Difference between the Means,

Hypothesis Test about the Difference