package com.imsl.test.example.stat; import com.imsl.stat.*; /** *
* Performs a hypothesis test for the mean of a normal distribution. *
** 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 \(H_0: \mu = 20.0\) is tested. The extremely large * t value and the correspondingly small p-value provide strong * evidence to reject the null hypothesis.
* * * @see Code * @see Output */ public class NormOneSampleEx1 { public static void main(String args[]) { double mean, stdev, lomean, upmean, t, pvalue; int df; 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); } }