Example 1: NormTwoSample

This example taken from Conover and Iman(1983, p294), involves scores on arithmetic tests of two grade-school classes.

Scores for Standard Group Scores for Experimental Group
72 111
75 118
77 128
80 138
104 140
110 150
125 163
164
169

The question is whether a group taught by an experimental method has a higher mean score. The difference in means and the t test are ouput. The variances of the two populations are assumed to be equal. It is seen from the output that there is strong reason to believe that the two means are different (t value of -4.804). Since the lower 97.5-percent confidence limit does not include 0, the null hypothesis is that \mu_1 \leq \mu_2 would be rejected at the 0.05 significance level. (The closeness of the values of the sample variances provides some qualitative substantiation of the assumption of equal variances.)


import com.imsl.stat.*;

public class NormTwoSampleEx1 {

    public static void main(String args[]) {
        double x1[] = {72.0, 75.0, 77.0, 80.0, 104.0, 110.0, 125.0};
        double x2[] = {
            111.0, 118.0, 128.0, 138.0, 140.0, 150.0, 163.0, 164.0, 169.0
        };

        /* Perform Analysis for one sample x2*/
        NormTwoSample n2samp = new NormTwoSample(x1, x2);
        double mean = n2samp.getDiffMean();

        System.out.println("x1mean-x2mean  = " + mean);
        System.out.println("X1 mean = " + n2samp.getMeanX());
        System.out.println("X2 mean = " + n2samp.getMeanY());

        double pVar = n2samp.getPooledVariance();
        System.out.println("pooledVar = " + pVar);

        double loCI = n2samp.getLowerCIDiff();
        double upCI = n2samp.getUpperCIDiff();
        System.out.println("95% CI for the mean is "
                + loCI + " " + upCI);

        loCI = n2samp.getLowerCIDiff();
        upCI = n2samp.getUpperCIDiff();
        System.out.println("95% CI for the ueq mean is "
                + loCI + " " + upCI);

        System.out.println("T Test Results");
        double tDF = n2samp.getTTestDF();
        double tT = n2samp.getTTest();
        double tPval = n2samp.getTTestP();
        System.out.println("T default = " + tDF);
        System.out.println("t = " + tT);
        System.out.println("p-value = " + tPval);

        double stdevX = n2samp.getStdDevX();
        double stdevY = n2samp.getStdDevY();
        System.out.println("stdev x1 = " + stdevX);
        System.out.println("stdev x2 = " + stdevY);
    }
}

Output

x1mean-x2mean  = -50.476190476190496
X1 mean = 91.85714285714285
X2 mean = 142.33333333333334
pooledVar = 434.6326530612244
95% CI for the mean is -73.01001962529507 -27.942361327085916
95% CI for the ueq mean is -73.01001962529507 -27.942361327085916
T Test Results
T default = 14.0
t = -4.8043615047163355
p-value = 2.8025836567727923E-4
stdev x1 = 20.87605144201182
stdev x2 = 20.826665599658526
Link to Java source.