import javastat.inference.twosamples.TwoSampMeansZTest;

 

/**

 *

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

 */

 

double[] testdata1 = {30, 40, 28, 5, 28, 29, 38, 36, 23, 22, 51, 33, 35,

                  42, 21, 31, 44, 32, 30, 32, 30, 30, 45, 29, 35,

                  33, 40, 31, 37, 41, 34, 40, 29, 42, 17, 29, 34,

                  39};

double[] testdata2 = {60, 68, 63, 37, 57, 52, 63, 68, 47, 44, 74, 71,

                  83, 92, 66, 64, 62, 73, 62, 51, 77, 77, 71, 53,

                  72, 58, 70, 58, 72, 81, 64, 60, 60, 72, 40, 61,

                  58, 69};

 

testclass1 = new TwoSampMeansZTest(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 TwoSampMeansZTest();

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         =  -13.402

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

The confidence interval based on non-null constructor   = [-35.745 , -26.624]

The test statistic based on null constructor             =  -13.402

The p-value based on null constructor                 =  1.0

The confidence interval based on null constructor       = [-35.745 , -26.624]

 

See also:

Estimation of the Difference between the Means,

Hypothesis Test about the Difference