Class CptMapProbs

java.lang.Object
edu.cmu.tetrad.bayes.CptMapProbs
All Implemented Interfaces:
CptMap, TetradSerializable, Serializable

public class CptMapProbs extends Object implements CptMap
Represents a conditional probability table (CPT) in a Bayes net. This represents the CPT as a map from a unique integer index for a particular node to the probability of that node taking on that value, where NaN's are not stored.
Author:
josephramsey
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    CptMapProbs(double[][] probMatrix)
    Constructs a new probability map based on the given 2-dimensional array.
    CptMapProbs(int numRows, int numColumns)
    Constructs a new probability map, a map from a unique integer index for a particular node to the probability of that node taking on that value, where NaN's are not stored.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    assignRow(int rowIndex, Vector vector)
    Assigns the values in the provided vector to a specific row in the probability map.
    double
    get(int row, int column)
    Returns the probability of the node taking on the value specified by the given row and column.
    int
    Returns the number of columns in the probability map.
    int
    Returns the number of rows in the probability map.
    void
    set(int row, int column, double value)
    Sets the probability of the node taking on the value specified by the given row and column to the given value.

    Methods inherited from class java.lang.Object

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

    • CptMapProbs

      public CptMapProbs(int numRows, int numColumns)
      Constructs a new probability map, a map from a unique integer index for a particular node to the probability of that node taking on that value, where NaN's are not stored. This probability map assumes that there is a certain number of rows and a certain number of columns in the table.
      Parameters:
      numRows - the number of rows in the table
      numColumns - the number of columns in the table
    • CptMapProbs

      public CptMapProbs(double[][] probMatrix)
      Constructs a new probability map based on the given 2-dimensional array.
      Parameters:
      probMatrix - the 2-dimensional array representing the probability matrix
      Throws:
      IllegalArgumentException - if the number of columns in any row is different
  • Method Details

    • get

      public double get(int row, int column)
      Returns the probability of the node taking on the value specified by the given row and column.
      Specified by:
      get in interface CptMap
      Parameters:
      row - the row of the node
      column - the column of the node
      Returns:
      the probability of the node taking on the value specified by the given row and column
    • set

      public void set(int row, int column, double value)
      Sets the probability of the node taking on the value specified by the given row and column to the given value.
      Parameters:
      row - the row of the node
      column - the column of the node
      value - the probability of the node taking on the value specified by the given row and column (NaN to remove the value)
    • getNumRows

      public int getNumRows()
      Returns the number of rows in the probability map.
      Specified by:
      getNumRows in interface CptMap
      Returns:
      the number of rows in the probability map.
    • getNumColumns

      public int getNumColumns()
      Returns the number of columns in the probability map.
      Specified by:
      getNumColumns in interface CptMap
      Returns:
      the number of columns in the probability map.
    • assignRow

      public void assignRow(int rowIndex, Vector vector)
      Assigns the values in the provided vector to a specific row in the probability map.
      Parameters:
      rowIndex - the index of the row to be assigned
      vector - the vector containing the values to be assigned to the row
      Throws:
      IllegalArgumentException - if the size of the vector is not equal to the number of columns in the probability map