Class BayesPm

java.lang.Object
edu.cmu.tetrad.bayes.BayesPm
All Implemented Interfaces:
VariableSource, Pm, TetradSerializable, Serializable

public final class BayesPm extends Object implements Pm, VariableSource
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 Details

    • BayesPm

      public BayesPm(Graph graph)
      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

      public BayesPm(Graph graph, BayesPm oldBayesPm)
      Constructs a new BayesPm using a given DAG, using as much information from the old BayesPm as possible.
      Parameters:
      graph - Ibid.
      oldBayesPm - Ibid.
    • BayesPm

      public BayesPm(Graph graph, int lowerBound, int upperBound)
      Constructs a new BayesPm from the given DAG, assigning each variable a random number of values between lowerBound and upperBound. Uses a fixed number of values if lowerBound == upperBound. The values are named "value1" ... "valuen".
      Parameters:
      graph - Ibid.
      lowerBound - Ibid.
      upperBound - Ibid.
    • BayesPm

      public BayesPm(Graph graph, BayesPm oldBayesPm, int lowerBound, int upperBound)
      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 between lowerBound and upperBound. 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

      public BayesPm(BayesPm bayesPm)
      Copy constructor.
      Parameters:
      bayesPm - Ibid.
  • Method Details

    • serializableInstance

      public static BayesPm serializableInstance()
      Generates a simple exemplar of this class to test serialization.
      Returns:
      Ibid.
    • getParameterNames

      public static List<String> getParameterNames()
      Returns the parameter names.
      Returns:
      Ibid.
    • getDag

      public Graph getDag()
      Returns the DAG.
      Returns:
      the DAG as a Graph.
    • getNumCategories

      public int getNumCategories(Node node)
      Returns the number of values for the given node.
      Parameters:
      node - Ibid.
      Returns:
      the number of values for the given node.
    • getCategory

      public String getCategory(Node node, int index)
      Returns the index'th value for the given node.
      Parameters:
      node - Ibid.
      index - Ibid.
      Returns:
      the index'th value for the given node.
    • getCategoryIndex

      public int getCategoryIndex(Node node, String category)
      Returns the index of the given category for the given node.
      Parameters:
      node - Ibid.
      category - Ibid.
      Returns:
      the index of the given category for the given node.
    • setNumCategories

      public void setNumCategories(Node node, int numCategories)
      Sets the number of values for the given node to the given number.
      Parameters:
      node - Ibid.
      numCategories - Ibid.
    • equals

      public boolean equals(Object o)

      Will return true if the argument is a BayesPm with the same graph and variables.

      Overrides:
      equals in class Object
    • setCategories

      public void setCategories(Node node, List<String> categories)
      Sets the number of values for the given node to the given number.
      Parameters:
      node - Ibid.
      categories - Ibid.
    • getVariables

      public List<Node> getVariables()

      getVariables.

      Specified by:
      getVariables in interface VariableSource
      Returns:
      a List object
    • getVariableNames

      public List<String> getVariableNames()
      Returns the variable names.
      Specified by:
      getVariableNames in interface VariableSource
      Returns:
      Ibid.
    • getVariable

      public Node getVariable(Node node)
      Returns the variable for the given node.
      Parameters:
      node - Ibid.
      Returns:
      Ibid.
    • getMeasuredNodes

      public List<Node> getMeasuredNodes()
      Returns the measured nodes.
      Returns:
      the list of measured variableNodes.
    • toString

      public String toString()
      Prints out the list of values for each node.
      Overrides:
      toString in class Object
      Returns:
      Ibid.
    • getNode

      public Node getNode(String nodeName)
      Returns the node by the given name.
      Parameters:
      nodeName - Ibid.
      Returns:
      Ibid.
    • getNode

      public Node getNode(int index)
      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.