package com.imsl.test.example.stat; import com.imsl.stat.*; /** *
* Performs Welch's t-test for three example data sets. *
* * @see Code * @see Output */ public class WelchsTTestEx1 { public static void main(String args[]) { double[][] x = new double[3][]; double[][] y = new double[3][]; double st, sdf, sp, lowerCIDiff, upperCIDiff; x[0] = new double[]{27.5, 21.0, 19.0, 23.6, 17.0, 17.9, 16.9, 20.1, 21.9, 22.6, 23.1, 19.6, 19.0, 21.7, 21.4}; y[0] = new double[]{27.1, 22.0, 20.8, 23.4, 23.4, 23.5, 25.8, 22.0, 24.8, 20.2, 21.9, 22.1, 22.9, 20.5, 24.4}; // second example, unequal variances and unequal sample sizes, where the smaller //sample has the larger variance x[1] = new double[]{17.2, 20.9, 22.6, 18.1, 21.7, 21.4, 23.5, 24.2, 14.7, 21.8}; y[1] = new double[]{21.5, 22.8, 21.0, 23.0, 21.6, 23.6, 22.5, 20.7, 23.4, 21.8, 20.7, 21.7, 21.5, 22.5, 23.6, 21.5, 22.5, 23.5, 21.5, 21.8}; // third example, unequal variances and unequal sample sizes, where the larger // sample has the larger variance x[2] = new double[]{19.8, 20.4, 19.6, 17.8, 18.5, 18.9, 18.3, 18.9, 19.5, 22.0}; y[2] = new double[]{28.2, 26.6, 20.1, 23.3, 25.2, 22.1, 17.7, 27.6, 20.6, 13.7, 23.2, 17.5, 20.6, 18.0, 23.9, 21.6, 24.3, 20.4, 24.0, 13.2}; for (int i = 0; i < x.length; i++) { WelchsTTest wts = new WelchsTTest(x[i], y[i]); st = wts.getTTest(); sdf = wts.getTTestDF(); sp = wts.getTTestP(); lowerCIDiff = wts.getLowerCIDiff(); upperCIDiff = wts.getUpperCIDiff(); System.out.println("t-test statistic value: " + st); System.out.println("t-test degrees of freedom: " + sdf); System.out.println("t-test p-value: " + sp); System.out.println("Mean difference 95% confidence interval: (" + lowerCIDiff + "," + upperCIDiff + ")"); } } }