Class CellTableAdTree
java.lang.Object
edu.cmu.tetrad.data.CellTableAdTree
- All Implemented Interfaces:
CellTable
-
Constructor Summary
ConstructorsConstructorDescriptionCellTableAdTree(int[][] data, List<DiscreteVariable> variables, int[] testIndices, List<Integer> rows) Constructs a new CellTableAdTree instance using the provided data, variables, test indices, and rows.CellTableAdTree(DataSet dataSet, int[] testIndices) Constructs a new CellTableAdTree using the provided data set and test indices.CellTableAdTree(DataSet dataSet, int[] testIndices, List<Integer> rows) Constructs a new cell table using the given array for dimensions, initializing all cells in the table to zero. -
Method Summary
Modifier and TypeMethodDescriptionintcalcMargin(int[] coords) Calculates a marginal sum for the cell table.intcalcMargin(int[] coords, int[] marginVars) An alternative way to specify a marginal calculation.intgetDimension(int varIndex) Returns the dimensions of the given variable.intgetValue(int[] coords) Returns the value of the cell specified by the given coordinates.
-
Constructor Details
-
CellTableAdTree
Constructs a new CellTableAdTree using the provided data set and test indices.- Parameters:
dataSet- the data set to be used in the table.testIndices- the indices of the variables to be used in the table.
-
CellTableAdTree
Constructs a new cell table using the given array for dimensions, initializing all cells in the table to zero.- Parameters:
dataSet- the data set to be used in the table.testIndices- the indices of the variables to be used in the table.rows- the rows to be used in the table; if null, all rows are used.
-
CellTableAdTree
public CellTableAdTree(int[][] data, List<DiscreteVariable> variables, int[] testIndices, List<Integer> rows) Constructs a new CellTableAdTree instance using the provided data, variables, test indices, and rows. The constructor initializes the ADTree for efficient cell table operations and computes dimensions for the test variables.- Parameters:
data- a 2D array representing the dataset, where each inner array corresponds to an observation, and columns represent variable values.variables- a list of discrete variables corresponding to the columns of the dataset.testIndices- an array containing the indices of the variables to be used for constructing the cell table.rows- a list of row indices to be used in the cell table; if null, all rows in the dataset are included.- Throws:
IllegalArgumentException- if any row index inrowsis out of bounds for the dataset.
-
-
Method Details
-
getDimension
public int getDimension(int varIndex) Returns the dimensions of the given variable.- Specified by:
getDimensionin interfaceCellTable- Parameters:
varIndex- the index of the variable in question.- Returns:
- the dimension of the variable.
-
calcMargin
public int 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.- Specified by:
calcMarginin interfaceCellTable- Parameters:
coords- an array of the sort described above.- Returns:
- the marginal sum specified.
-
calcMargin
public int 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.- Specified by:
calcMarginin interfaceCellTable- Parameters:
coords- anint[]valuemarginVars- anint[]value- Returns:
- an
intvalue
-
getValue
-