import javastat.inference.onesample.OneSampMeanTTest;

 

/**

 *

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

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

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

 *    p. 354. </p>

 */

 

double[] testdata = {7, 8, 10, 8, 6, 9, 6, 7, 7, 8, 9, 8};

 

testclass1 = new OneSampMeanTTest(0.05, 7, "greater", testdata);

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 OneSampMeanTTest();

confidenceInterval = testclass2.confidenceInterval(0.05, testdata);

testStatistic = testclass2.testStatistic(7, testdata);

pValue = testclass2.pValue(7, "equal", testdata);

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.138

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

The confidence interval based on non-null constructor   = [6.978 , 8.522]

The test statistic based on null constructor             =  2.138

The p-value based on null constructor                 =  0.056

The confidence interval based on null constructor       = [6.978 , 8.522]

 

See also:

Population Mean: Small Sample Case,

Tests about a Population Mean: Small Sample Case