package com.imsl.test.example.stat; import com.imsl.stat.*; /** *
* Computes a one-way table for a continuous scale variable. *
* ** The data for this example is from Hinkley (1977) and Belleman and Hoaglin * (1981). The measurement (in inches) are for precipitation in Minneapolis/St. * Paul during the month of March for \(30\) consecutive years.
** The first test uses the default tally method which may be appropriate when * the range of data is unknown. The minimum and maximum data bounds are * displayed.
** The second test computes the table using known bounds, where the lower bound * is 0.5 and the upper bound is 4.5. The eight interior intervals each have * width \((4.5 - 0.5)/(10-2) = 0.5\). The 10 intervals are \((-\infty, 0.5], * (0.5,1.0],...,(4.0,4.5]\), and \((4.5,\infty]\). *
** In the third test, 10 class marks, \(0.25, 0.75, 1.25,...,4.75\), are input. * This defines the class intervals * \((0.0,0.5],(0.5,1.0],...,(4.0,4.5],(4.5,5.0]\). Note that unlike the * previous test, the initial and last intervals are the same length as the * remaining intervals.
** In the fourth test, cutpoints, \(0.5,1.0, 1.5, 2.0, ...,4.5\), are input to * define the same 10 intervals as in the second test. Here again, the initial * and last intervals are semi- infinite intervals.
* * * @see Code * @see Output */ public class TableOneWayEx1 { public static void main(String args[]) { int nIntervals = 10; double[] x = { 0.77, 1.74, 0.81, 1.20, 1.95, 1.20, 0.47, 1.43, 3.37, 2.20, 3.00, 3.09, 1.51, 2.10, 0.52, 1.62, 1.31, 0.32, 0.59, 0.81, 2.81, 1.87, 1.18, 1.35, 4.75, 2.48, 0.96, 1.89, 0.9, 2.05 }; double cutPoints[] = { 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5 }; double classMarks[] = { 0.25, 0.75, 1.25, 1.75, 2.25, 2.75, 3.25, 3.75, 4.25, 4.75 }; TableOneWay fTbl = new TableOneWay(x, nIntervals); double table[] = fTbl.getFrequencyTable(); System.out.println("Example 1 "); for (int i = 0; i < table.length; i++) { System.out.println(i + " " + table[i]); } System.out.println("--------------------------"); System.out.println("Lower bounds= " + fTbl.getMinimum()); System.out.println("Upper bounds= " + fTbl.getMaximum()); System.out.println("--------------------------"); /* getFrequencyTable using a set of known bounds */ table = fTbl.getFrequencyTable(0.5, 4.5); for (int i = 0; i < table.length; i++) { System.out.println(i + " " + table[i]); } System.out.println("---------------------"); table = fTbl.getFrequencyTableUsingClassmarks(classMarks); for (int i = 0; i < table.length; i++) { System.out.println(i + " " + table[i]); } System.out.println("--------------------"); table = fTbl.getFrequencyTableUsingCutpoints(cutPoints); for (int i = 0; i < table.length; i++) { System.out.println(i + " " + table[i]); } } }