This example uses data from Devore (1982, p335), which is based on data published in the Journal of Materials . There are 15 observations. The hypothesis is tested. The extremely large t value and the correspondingly small p -value provide strong evidence to reject the null hypothesis.
import com.imsl.stat.*; public class NormOneSampleEx1 { public static void main(String args[]) { double mean, stdev, lomean, upmean; int df; double t, pvalue; double[] x = { 26.7, 25.8, 24.0, 24.9, 26.4, 25.9, 24.4, 21.7, 24.1, 25.9, 27.3, 26.9, 27.3, 24.8, 23.6 }; /* Perform Analysis*/ NormOneSample n1samp = new NormOneSample(x); mean = n1samp.getMean(); stdev = n1samp.getStdDev(); lomean = n1samp.getLowerCIMean(); upmean = n1samp.getUpperCIMean(); n1samp.setTTestNull(20.0); df = n1samp.getTTestDF(); t = n1samp.getTTest(); pvalue = n1samp.getTTestP(); /* Print results */ System.out.println("Sample Mean = "+ mean); System.out.println("Sample Standard Deviation = "+ stdev); System.out.println("95% CI for the mean is "+ lomean +" "+ upmean); System.out.println("T Test results"); System.out.println("df = " + df); System.out.println("t = " + t); System.out.println("pvalue = " + pvalue); System.out.println(""); /* CI variance */ double ciLoVar = n1samp.getLowerCIVariance(); double ciUpVar = n1samp.getUpperCIVariance(); System.out.println("CI variance is "+ciLoVar+" "+ciUpVar); /*chi-squared test */ df = n1samp.getChiSquaredTestDF(); t = n1samp.getChiSquaredTest(); pvalue = n1samp.getChiSquaredTestP(); System.out.println("Chi-squared Test results"); System.out.println("Chi-squared df = " + df); System.out.println("Chi-squared t = " + t); System.out.println("Chi-squared pvalue = " + pvalue); } }
Sample Mean = 25.313333333333336 Sample Standard Deviation = 1.5788181233652814 95% CI for the mean is 24.43901299970965 26.187653666957022 T Test results df = 14 t = 13.03408619922945 pvalue = 3.2147173398634027E-9 CI variance is 1.3360926049992239 6.199863467239491 Chi-squared Test results Chi-squared df = 14 Chi-squared t = 34.89733333333332 Chi-squared pvalue = 0.0015223176141821789Link to Java source.