The table of frequencies for a data matrix of size 30 x 2 is output.
import com.imsl.stat.*; import com.imsl.math.*; import java.text.MessageFormat; public class TableMultiWayEx2 { public static void main(String args[]) { int indkeys[]={0,1}; double x[][] = { {0.5, 1.5}, {1.5, 3.5}, {0.5, 3.5}, {1.5, 2.5}, {1.5, 3.5}, {1.5, 4.5}, {0.5, 1.5}, {1.5, 3.5}, {3.5, 6.5}, {2.5, 3.5}, {2.5, 4.5}, {3.5, 6.5}, {1.5, 2.5}, {2.5, 4.5}, {0.5, 3.5}, {1.5, 2.5}, {1.5, 3.5}, {0.5, 3.5}, {0.5, 1.5}, {0.5, 2.5}, {2.5, 5.5}, {1.5, 2.5}, {1.5, 3.5}, {1.5, 4.5}, {4.5, 5.5}, {2.5, 4.5}, {0.5, 3.5}, {1.5, 2.5}, {0.5, 2.5}, {2.5, 5.5} }; TableMultiWay tbl = new TableMultiWay(x,indkeys); int nvalues[] = tbl.getBalancedTable().getNvalues(); double values[] = tbl.getBalancedTable().getValues(); System.out.println(" row values"); for (int i=0; i< nvalues[0]; i++) System.out.print(values[i]+" "); System.out.println(""); System.out.println(""); System.out.println(" column values"); for (int i=0; i< nvalues[1]; i++) System.out.print(values[i+nvalues[0]]+" "); double table[] = tbl.getBalancedTable().getTable(); System.out.println(""); System.out.println(""); System.out.println(" Table"); System.out.print(" "); for (int i=0; i< nvalues[1]; i++) System.out.print(values[i+nvalues[0]]+ " "); System.out.println(""); for (int i=0; i< nvalues[0]; i++) { System.out.print(values[i]+ " "); for (int j=0; j<nvalues[1]; j++) System.out.print(table[j +(nvalues[1]*i)]+ " "); System.out.println(" "); } } }
row values 0.5 1.5 2.5 3.5 4.5 column values 1.5 2.5 3.5 4.5 5.5 6.5 Table 1.5 2.5 3.5 4.5 5.5 6.5 0.5 3.0 2.0 4.0 0.0 0.0 0.0 1.5 0.0 5.0 5.0 2.0 0.0 0.0 2.5 0.0 0.0 1.0 3.0 2.0 0.0 3.5 0.0 0.0 0.0 0.0 0.0 2.0 4.5 0.0 0.0 0.0 0.0 1.0 0.0Link to Java source.