Class DirichletBayesIm

java.lang.Object
edu.cmu.tetrad.bayes.DirichletBayesIm
All Implemented Interfaces:
BayesIm, Simulator, VariableSource, Im, TetradSerializable, Serializable

public final class DirichletBayesIm extends Object implements BayesIm

Stores Dirichlet pseudocounts for the distributions of each variable conditional on particular combinations of its parent values and, together with Bayes Pm and Dag, provides methods to manipulate these tables. The division of labor is as follows. The Dag is responsible for manipulating the basic graphical structure of the Dirichlet Bayes net. Dag also stores and manipulates the names of the nodes in the graph; there are no method in either BayesPm or DiriculetBayesIm to do this. BayesPm stores and manipulates the *values* of each node in a DAG, considered as a variable in a Bayes net. The number of values for a variable can be changed there as well as the names for those values. This class, DirichletBayesIm, stores the actual tables of parameter pseudocounts whose structures are implied by the structures in the other two classes. The implied parameters take the form of conditional probabilities--e.g., P(V=v0|P1=v1, P2=v2, ...), for all nodes and all combinations of their parent values. The set of all such probabilities is organized in this class as a three-dimensional table of double values. The first dimension corresponds to the nodes in the DAG. For each such node, the second dimension corresponds to a flat list of combinations of parent values for that node. The third dimension corresponds to the list of pseudocounts for each node/row combination. Two methods in this class allow these values to be set and retrieved:

  • getPseudocount(int nodeIndex, int rowIndex, int colIndex); and,
  • setPseudocount(int nodeIndex, int rowIndex, int colIndex, int pValue).
A third method, getRowPseudocount, calculates the total pseudocount in a given row on the fly. Maximum likelihood probabilities may be computed on the fly using the method getWordRatio. In order to use these methods, one needs to know the index of the node in question and the index of the row in question. (The index of the column is the same as the index of the node value.) To determine the index of the node in question, use the method
  • getNodeIndex(Node node).
To determine the index of the row in question, use the method
  • getRowIndex(int[] parentVals).
To determine the order of the parent values for a given node so that you can build the parentVals[] array, use the method
  • getParents(int nodeIndex)
To determine the index of a value, use the method
  • getCategoryIndex(Node node)
in BayesPm. The rest of the methods in this class are easily understood as variants of the methods above.

Thanks to Bill Taysom for an earlier version.

Version:
$Id: $Id
Author:
josephramsey
See Also: