Package edu.cmu.tetrad.bayes
Class CptMapCounts
java.lang.Object
edu.cmu.tetrad.bayes.CptMapCounts
- 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 cell count for that node, where 0's are not stored. Row counts are also
 stored, so that the probability of a cell can be calculated. A prior cell count of 0 is assumed for all cells,
 but this may be set by the user to any non-negative count. (A prior count of 0 is equivalent to a maximum
 likelihood estimate.)
- Author:
- josephramsey
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionCptMapCounts(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.CptMapCounts(DataSet data) Constructs a new CptMap based on counts from a given dataset.
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddCounts(int row, int column, int count) Adds the specified count to the cell count at the given row and column.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.doubleRetrieves the prior count for all cells in the CptMapCounts.voidsetPriorCount(double priorCount) Sets the prior count for all cells in the CptMapCounts.
- 
Constructor Details- 
CptMapCountspublic CptMapCounts(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
 
- 
CptMapCountsConstructs a new CptMap based on counts from a given dataset.- Parameters:
- data- the DataSet object representing the probability matrix
- Throws:
- IllegalArgumentException- if the data set is null or not discrete
 
 
- 
- 
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.
- 
addCountspublic void addCounts(int row, int column, int count) Adds the specified count to the cell count at the given row and column.- Parameters:
- row- the row index of the cell count
- column- the column index of the cell count
- count- the count to be added to the cell count
- Throws:
- IllegalArgumentException- if the row or column is out of bounds
 
- 
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.
 
- 
getPriorCountpublic double getPriorCount()Retrieves the prior count for all cells in the CptMapCounts.- Returns:
- the prior count for all cells in the CptMapCounts.
 
- 
setPriorCountpublic void setPriorCount(double priorCount) Sets the prior count for all cells in the CptMapCounts. The prior count is used in parameter estimation for Bayesian networks.- Parameters:
- priorCount- the value to set as the prior count.
 
 
-