Package edu.cmu.tetrad.bayes
Class BayesPm
java.lang.Object
edu.cmu.tetrad.bayes.BayesPm
- All Implemented Interfaces:
VariableSource
,Pm
,TetradSerializable
,Serializable
Implements a discrete Bayes parametric model--that is, a DAG together with a map from the nodes in the graph to a set
of discrete variables, specifying the number of categories for each variable and the name of each category for each
variable. This is all the information one needs to know in order to determine the parametric form of a Bayes net up
to actual values of parameters. Specific values for the Bayes net are stored in a BayesIM object (see).
- Version:
- $Id: $Id
- Author:
- josephramsey
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCopy constructor.Construct a new BayesPm using the given DAG, assigning each variable two values named "value1" and "value2" unless nodes are discrete variables with categories already defined.Constructs a new BayesPm from the given DAG, assigning each variable a random number of values betweenlowerBound
andupperBound
.Constructs a new BayesPm using a given DAG, using as much information from the old BayesPm as possible.Constructs a new BayesPm from the given DAG, using as much information from the old BayesPm as possible. -
Method Summary
Modifier and TypeMethodDescriptionboolean
getCategory
(Node node, int index) Returns the index'th value for the given node.int
getCategoryIndex
(Node node, String category) Returns the index of the given category for the given node.getDag()
Returns the DAG.Returns the measured nodes.getNode
(int index) Returns the node at the given index.Returns the node by the given name.int
Returns the node index.int
getNumCategories
(Node node) Returns the number of values for the given node.int
Returns the number of nodes.Returns the parameter names.getVariable
(Node node) Returns the variable for the given node.Returns the variable names.getVariables.static BayesPm
Generates a simple exemplar of this class to test serialization.void
setCategories
(Node node, List<String> categories) Sets the number of values for the given node to the given number.void
setNumCategories
(Node node, int numCategories) Sets the number of values for the given node to the given number.toString()
Prints out the list of values for each node.
-
Constructor Details
-
BayesPm
Construct a new BayesPm using the given DAG, assigning each variable two values named "value1" and "value2" unless nodes are discrete variables with categories already defined.- Parameters:
graph
- Ibid.
-
BayesPm
-
BayesPm
Constructs a new BayesPm from the given DAG, assigning each variable a random number of values betweenlowerBound
andupperBound
. Uses a fixed number of values if lowerBound == upperBound. The values are named "value1" ... "valuen".- Parameters:
graph
- Ibid.lowerBound
- Ibid.upperBound
- Ibid.
-
BayesPm
Constructs a new BayesPm from the given DAG, using as much information from the old BayesPm as possible. For variables not in the old BayesPm, assigns each variable a random number of values betweenlowerBound
andupperBound
. Uses a fixed number of values if lowerBound == upperBound. The values are named "value1" ... "valuen".- Parameters:
graph
- Ibid.oldBayesPm
- Ibid.lowerBound
- Ibid.upperBound
- Ibid.
-
BayesPm
-
-
Method Details
-
serializableInstance
Generates a simple exemplar of this class to test serialization.- Returns:
- Ibid.
-
getParameterNames
-
getDag
-
getNumCategories
Returns the number of values for the given node.- Parameters:
node
- Ibid.- Returns:
- the number of values for the given node.
-
getCategory
-
getCategoryIndex
-
setNumCategories
Sets the number of values for the given node to the given number.- Parameters:
node
- Ibid.numCategories
- Ibid.
-
equals
-
setCategories
-
getVariables
getVariables.
- Specified by:
getVariables
in interfaceVariableSource
- Returns:
- a
List
object
-
getVariableNames
Returns the variable names.- Specified by:
getVariableNames
in interfaceVariableSource
- Returns:
- Ibid.
-
getVariable
-
getMeasuredNodes
-
toString
-
getNode
-
getNode
Returns the node at the given index.- Parameters:
index
- Ibid.- Returns:
- Ibid.
-
getNodeIndex
public int getNodeIndex()Returns the node index.- Returns:
- -1.
-
getNumNodes
public int getNumNodes()Returns the number of nodes.- Returns:
- Ibid.
-