Class JunctionTreeUpdater

java.lang.Object
edu.cmu.tetrad.bayes.JunctionTreeUpdater
All Implemented Interfaces:
BayesUpdater, ManipulatingBayesUpdater, TetradSerializable, Serializable

public class JunctionTreeUpdater extends Object implements ManipulatingBayesUpdater
Jan 21, 2020 11:03:09 AM
Version:
$Id: $Id
Author:
Kevin V. Bui (kvb2@pitt.edu)
See Also:
  • Constructor Details

    • JunctionTreeUpdater

      public JunctionTreeUpdater(BayesIm bayesIm)

      Constructor for JunctionTreeUpdater.

      Parameters:
      bayesIm - a BayesIm object
    • JunctionTreeUpdater

      public JunctionTreeUpdater(BayesIm bayesIm, Evidence evidence)

      Constructor for JunctionTreeUpdater.

      Parameters:
      bayesIm - a BayesIm object
      evidence - a Evidence object
  • Method Details

    • getManipulatedBayesIm

      public BayesIm getManipulatedBayesIm()
      Returns the manipulated Bayes IM. This is the Bayes IM in which the variables in the manipulation have been removed from the graph.
      Specified by:
      getManipulatedBayesIm in interface ManipulatingBayesUpdater
      Returns:
      the Bayes instantiated model after manipulations have been applied.
    • getManipulatedGraph

      public Graph getManipulatedGraph()
      Returns the manipulated graph. This is the graph in which the variables in the manipulation have been removed from the graph.
      Specified by:
      getManipulatedGraph in interface ManipulatingBayesUpdater
      Returns:
      the graph for the manipulated BayesIm.
    • getEvidence

      public Evidence getEvidence()
      Returns the manipulation that was used to manipulate the Bayes IM.
      Specified by:
      getEvidence in interface ManipulatingBayesUpdater
      Returns:
      a defensive copy of the evidence.
    • setEvidence

      public void setEvidence(Evidence evidence)
      Sets new evidence for the updater. Once this is called, old updating results should not longer be available.

      Sets new evidence for the updater. Once this is called, old updating results should not longer be available.

      Specified by:
      setEvidence in interface BayesUpdater
      Specified by:
      setEvidence in interface ManipulatingBayesUpdater
      Parameters:
      evidence - evidence
    • getUpdatedBayesIm

      public BayesIm getUpdatedBayesIm()
      Returns the updated Bayes IM. This is the Bayes IM in which all probabilities of variables conditional on their parents have been updated.
      Specified by:
      getUpdatedBayesIm in interface ManipulatingBayesUpdater
      Returns:
      the updated Bayes IM--that is, the Bayes IM in which all probabilities of variables conditional on their parents have been updated.
    • getMarginal

      public double getMarginal(int variable, int category)
      Returns the marginal probability of the given variable taking the given value, given the evidence.

      Returns the updated graph. This is the graph in which all probabilities of variables conditional on their parents have been updated.

      Specified by:
      getMarginal in interface BayesUpdater
      Specified by:
      getMarginal in interface ManipulatingBayesUpdater
      Parameters:
      variable - variable index
      category - category index
      Returns:
      P(variable = value | evidence), where evidence is getEvidence().
    • isJointMarginalSupported

      public boolean isJointMarginalSupported()
      Returns the joint marginal probability of the given variables taking the given values, given the evidence.
      Specified by:
      isJointMarginalSupported in interface BayesUpdater
      Returns:
      true if the getJointMarginal() method is supported.
    • getJointMarginal

      public double getJointMarginal(int[] variables, int[] values)
      Returns the joint marginal probability of the given variables taking the given values, given the evidence.
      Specified by:
      getJointMarginal in interface BayesUpdater
      Parameters:
      variables - variable indices
      values - category indices
      Returns:
      P(variables[i] = values[i] | evidence), where evidence is getEvidence().
    • getBayesIm

      public BayesIm getBayesIm()
      Returns the evidence for the updater.
      Specified by:
      getBayesIm in interface BayesUpdater
      Returns:
      the Bayes instantiated model that is being updated.
    • calculatePriorMarginals

      public double[] calculatePriorMarginals(int nodeIndex)
      Calculates the prior marginal probabilities of the given node.
      Specified by:
      calculatePriorMarginals in interface BayesUpdater
      Parameters:
      nodeIndex - node index
      Returns:
      P(node = value), where value is the value of the node in the Bayes net.
    • calculateUpdatedMarginals

      public double[] calculateUpdatedMarginals(int nodeIndex)
      Calculates the updated marginal probabilities of the given node, given the evidence.
      Specified by:
      calculateUpdatedMarginals in interface BayesUpdater
      Parameters:
      nodeIndex - node index
      Returns:
      P(node = value | evidence), where value is the value of the node in the Bayes net.
    • toString

      public String toString()
      Overrides:
      toString in class Object