Example 3: TableMultiWay

The unbalanced table of frequencies for a data matrix of size 4 x 3 is output.

using System;
using Imsl.Stat;
using Imsl.Math;

public class TableMultiWayEx3
{
    public static void  Main(String[] args)
    {
        int[] indkeys = new int[]{0, 1};
        double[,] x = {
            {2.0, 5.0, 1.0}, {1.0, 5.0, 2.0}, 
            {1.0, 6.0, 3.0}, {2.0, 6.0, 4.0}};
        double[] frq = new double[]{1.0, 2.0, 3.0, 4.0};
        
        TableMultiWay tbl = new TableMultiWay(x, indkeys);
        tbl.SetFrequencies(frq);
        
        int ncells = tbl.UnbalancedTable.NCells;
        double[] listCells = tbl.UnbalancedTable.GetListCells();
        double[] table = tbl.UnbalancedTable.GetTable();
        
        PrintMatrix pm = new PrintMatrix("List Cells");
        PrintMatrixFormat mf = new PrintMatrixFormat();
        mf.SetNoRowLabels();
        mf.SetNoColumnLabels();
        //    Print the array
        pm.Print(mf, listCells);
        Console.Out.WriteLine();
        
        pm = new PrintMatrix("Unbalanced Table");
        mf = new PrintMatrixFormat();
        mf.SetNoRowLabels();
        mf.SetNoColumnLabels();
        //    Print the array
        pm.Print(mf, table);
        Console.Out.WriteLine();
    }
}

Output

List Cells
     
1  
5  
1  
6  
2  
5  
2  
6  


Unbalanced Table
     
2  
3  
1  
4  



Link to C# source.