import javastat.inference.onesample.OneSampMeanZTest;

 

/**

 *

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

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

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

 *    p. 340. </p>

 */

 

double[] testdata = {86, 97, 159, 92, 146, 138, 101, 87, 151, 69,

                 97, 79, 103, 104, 104, 105, 105, 102, 112, 116,

                 118, 124, 125, 129, 132, 98, 88, 68, 135, 100};

 

testclass1 = new OneSampMeanZTest(0.05, 100, "equal", 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 OneSampMeanZTest();

confidenceInterval = testclass2.confidenceInterval(0.05, testdata);

testStatistic = testclass2.testStatistic(100, testdata);

pValue = testclass2.pValue(100, "greater", 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.143

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

The confidence interval based on non-null constructor   = [100.769 , 117.231]

The test statistic based on null constructor             =  2.143

The p-value based on null constructor                 =  0.016

The confidence interval based on null constructor       = [100.769 , 117.231]

 

See also:

Population Mean: Large Sample Case,

One-Tailed Tests about a Population Mean: Large Sample Case,

Modern Approach: P-value,

Two-Tailed Tests about a Population Mean: Large Sample Case