Class CellTable

java.lang.Object
edu.cmu.tetrad.data.CellTable

public final class CellTable extends Object
Stores a cell count table of arbitrary dimension. Provides methods for incrementing particular cells and for calculating marginals.
Version:
$Id: $Id
Author:
josephramsey
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    CellTable(int[] dims)
    Constructs a new cell table using the given array for dimensions, initializing all cells in the table to zero.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addToTable(DataSet dataSet, int[] indices)
    Adds the given data set to the table, using the given indices to specify the variables to be used in the table.
    long
    calcMargin(int[] coords)
    Calculates a marginal sum for the cell table.
    long
    calcMargin(int[] coords, int[] marginVars)
    An alternative way to specify a marginal calculation.
    int
    getNumValues(int varIndex)
    getNumValues.
    long
    getValue(int[] testCell)
    Returns the value of the cell specified by the given coordinates.
    void
    setMissingValue(int missingValue)
    Sets the missing value marker.
    void
    Sets the rows to be used in the table.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CellTable

      public CellTable(int[] dims)
      Constructs a new cell table using the given array for dimensions, initializing all cells in the table to zero.
      Parameters:
      dims - an int[] value
  • Method Details

    • addToTable

      public void addToTable(DataSet dataSet, int[] indices)
      Adds the given data set to the table, using the given indices to specify the variables to be used in the table.
      Parameters:
      dataSet - the data set to be used in the table.
      indices - the indices of the variables to be used in the table.
    • getNumValues

      public int getNumValues(int varIndex)

      getNumValues.

      Parameters:
      varIndex - the index of the variable in question.
      Returns:
      the number of dimensions of the variable.
    • calcMargin

      public long calcMargin(int[] coords)
      Calculates a marginal sum for the cell table. The variables over which marginal sums should be taken are indicated by placing "-1's" in the appropriate positions in the coordinate argument. For instance, to find the margin for v0 = 1, v1 = 3, and v3 = 2, where the marginal sum ranges over all values of v2 and v4, the array [1, 3, -1, 2, -1] should be used.
      Parameters:
      coords - an array of the sort described above.
      Returns:
      the marginal sum specified.
    • calcMargin

      public long calcMargin(int[] coords, int[] marginVars)
      An alternative way to specify a marginal calculation. In this case, coords specifies a particular cell in the table, and varIndices is an array containing the indices of the variables over which the margin sum should be calculated. The sum is over the cell specified by 'coord' and all the cells which differ from that cell in any of the specified coordinates.
      Parameters:
      coords - an int[] value
      marginVars - an int[] value
      Returns:
      an int value
    • setMissingValue

      public void setMissingValue(int missingValue)
      Sets the missing value marker.
      Parameters:
      missingValue - the missing value marker.
    • getValue

      public long getValue(int[] testCell)
      Returns the value of the cell specified by the given coordinates.
      Parameters:
      testCell - the coordinates of the cell.
      Returns:
      the value of the cell.
    • setRows

      public void setRows(List<Integer> rows)
      Sets the rows to be used in the table. If the rows are null, the table will use all the rows in the data set. Otherwise, the table will use only the rows specified.
      Parameters:
      rows - the rows to be used in the table.