Class MixedDataBox

java.lang.Object
edu.cmu.tetrad.data.MixedDataBox
All Implemented Interfaces:
DataBox, TetradSerializable, Serializable

public class MixedDataBox extends Object implements DataBox
Stores a 2D array of double continuousData. Note that the missing value marker for this box is -99.
Version:
$Id: $Id
Author:
josephramsey
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    MixedDataBox(List<Node> variables, int numRows)
    The variables here are used only to determine which columns are discrete and which are continuous; bounds checking is not done.
    MixedDataBox(List<Node> variables, int numRows, double[][] continuousData, int[][] discreteData)
    This constructor allows other data readers to populate the fields directly.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addVariable(Node variable)
    addVariable.
    copy.
    get(int row, int col)
    get.
    double[][]
    Getter for the field continuousData.
    int[][]
    Getter for the field discreteData.
    Returns a data box of the same dimensions as this one, without setting any values.
    int
    numCols.
    int
    numRows.
    static BoxDataSet
    Generates a simple exemplar of this class to test serialization.
    void
    set(int row, int col, Number value)
    Sets the value at the given row and column to the given Number.
    viewSelection(int[] rows, int[] cols)
    viewSelection.

    Methods inherited from class java.lang.Object

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

    • MixedDataBox

      public MixedDataBox(List<Node> variables, int numRows)
      The variables here are used only to determine which columns are discrete and which are continuous; bounds checking is not done.
      Parameters:
      variables - a List object
      numRows - a int
    • MixedDataBox

      public MixedDataBox(List<Node> variables, int numRows, double[][] continuousData, int[][] discreteData)
      This constructor allows other data readers to populate the fields directly.
      Parameters:
      variables - list of discrete and continuous variables
      numRows - number of cases in the dataset
      continuousData - continuous data
      discreteData - discrete data
  • Method Details

    • serializableInstance

      public static BoxDataSet serializableInstance()
      Generates a simple exemplar of this class to test serialization.
      Returns:
      a BoxDataSet object
    • numRows

      public int numRows()

      numRows.

      Specified by:
      numRows in interface DataBox
      Returns:
      the (fixed) number of rows of the dataset.
    • numCols

      public int numCols()

      numCols.

      Specified by:
      numCols in interface DataBox
      Returns:
      the (fixed) number of columns of the dataset.
    • set

      public void set(int row, int col, Number value)
      Sets the value at the given row and column to the given Number. This number may be interpreted differently depending on how values are stored. A value of null is interpreted as a missing value.

      Sets the value at the given row/column to the given Number value. The value used is number.doubleValue().

      Specified by:
      set in interface DataBox
      Parameters:
      row - the row index.
      col - the column index.
      value - the value to store.
    • get

      public Number get(int row, int col)

      get.

      Specified by:
      get in interface DataBox
      Parameters:
      row - the row index.
      col - the column index.
      Returns:
      the value at the given row and column as a Number. If the value is missing, null is uniformly returned.
    • copy

      public DataBox copy()

      copy.

      Specified by:
      copy in interface DataBox
      Returns:
      a copy of this data box.
    • like

      public DataBox like()
      Returns a data box of the same dimensions as this one, without setting any values.
      Specified by:
      like in interface DataBox
      Returns:
      a new data box.
    • addVariable

      public void addVariable(Node variable)

      addVariable.

      Parameters:
      variable - a Node object
    • viewSelection

      public DataBox viewSelection(int[] rows, int[] cols)

      viewSelection.

      Specified by:
      viewSelection in interface DataBox
      Parameters:
      rows - the row indices.
      cols - the column indices.
      Returns:
      this data box, restricted to the given rows and columns.
    • getContinuousData

      public double[][] getContinuousData()

      Getter for the field continuousData.

      Returns:
      an array of double objects
    • getDiscreteData

      public int[][] getDiscreteData()

      Getter for the field discreteData.

      Returns:
      an array of int objects