Package edu.cmu.tetrad.bayes
Class CptMapProbs
java.lang.Object
edu.cmu.tetrad.bayes.CptMapProbs
- All Implemented Interfaces:
- CptMap,- TetradSerializable,- Serializable
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 SummaryConstructorsConstructorDescriptionCptMapProbs(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 SummaryModifier and TypeMethodDescriptionvoidAssigns the values in the provided vector to a specific row in the probability map.doubleget(int row, int column) Returns the probability of the node taking on the value specified by the given row and column.intReturns the number of columns in the probability map.intReturns the number of rows in the probability map.voidset(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.
- 
Constructor Details- 
CptMapProbspublic 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
 
- 
CptMapProbspublic 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- 
getpublic double get(int row, int column) Returns the probability of the node taking on the value specified by the given row and column.
- 
setpublic 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)
 
- 
getNumRowspublic int getNumRows()Returns the number of rows in the probability map.- Specified by:
- getNumRowsin interface- CptMap
- Returns:
- the number of rows in the probability map.
 
- 
getNumColumnspublic int getNumColumns()Returns the number of columns in the probability map.- Specified by:
- getNumColumnsin interface- CptMap
- Returns:
- the number of columns in the probability map.
 
- 
assignRowAssigns 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
 
 
-