Package edu.cmu.tetrad.bayes
Class CptInvariantUpdater
java.lang.Object
edu.cmu.tetrad.bayes.CptInvariantUpdater
- All Implemented Interfaces:
BayesUpdater
,ManipulatingBayesUpdater
,TetradSerializable
,Serializable
Calculates updated probabilities for variables conditional on their parents as well as single-variable updated
marginals for a Bayes IM using an algorithm that restricts expensive updating summations only to conditional
probabilities of variables with respect to their parents that change from non-updated to updated values.
- Version:
- $Id: $Id
- Author:
- josephramsey
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCptInvariantUpdater
(BayesIm bayesIm) Constructor for CptInvariantUpdater.CptInvariantUpdater
(BayesIm bayesIm, Evidence evidence) Constructs a new updater for the given Bayes net. -
Method Summary
Modifier and TypeMethodDescriptiondouble[]
calculatePriorMarginals
(int nodeIndex) Calculates the prior marginal probabilities of the given node.double[]
calculateUpdatedMarginals
(int nodeIndex) Calculates the updated marginal probabilities of the given node, given the evidence.Getter for the fieldbayesIm
.Getter for the fieldevidence
.double
getJointMarginal
(int[] variables, int[] values) getJointMarginal.Getter for the fieldmanipulatedBayesIm
.getManipulatedGraph.double
getMarginal
(int variable, int value) Returns the marginal probability of the given variable taking the given value, given the evidence.Getter for the fieldupdatedBayesIm
.boolean
isJointMarginalSupported.static CptInvariantUpdater
Generates a simple exemplar of this class to test serialization.void
setEvidence
(Evidence evidence) Sets new evidence for the updater.toString()
Prints out the most recent marginal.
-
Constructor Details
-
CptInvariantUpdater
-
CptInvariantUpdater
-
-
Method Details
-
serializableInstance
Generates a simple exemplar of this class to test serialization.- Returns:
- a
CptInvariantUpdater
object
-
getBayesIm
Getter for the field
bayesIm
.- Specified by:
getBayesIm
in interfaceBayesUpdater
- Returns:
- a
BayesIm
object
-
getManipulatedBayesIm
Getter for the field
manipulatedBayesIm
.- Specified by:
getManipulatedBayesIm
in interfaceManipulatingBayesUpdater
- Returns:
- a
BayesIm
object
-
getManipulatedGraph
getManipulatedGraph.
- Specified by:
getManipulatedGraph
in interfaceManipulatingBayesUpdater
- Returns:
- a
Graph
object
-
getUpdatedBayesIm
Getter for the field
updatedBayesIm
.- Specified by:
getUpdatedBayesIm
in interfaceManipulatingBayesUpdater
- Returns:
- a
BayesIm
object
-
getEvidence
Getter for the field
evidence
.- Specified by:
getEvidence
in interfaceManipulatingBayesUpdater
- Returns:
- a
Evidence
object
-
setEvidence
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 interfaceBayesUpdater
- Specified by:
setEvidence
in interfaceManipulatingBayesUpdater
- Parameters:
evidence
- evidence
-
getMarginal
public double getMarginal(int variable, int value) 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 interfaceBayesUpdater
- Specified by:
getMarginal
in interfaceManipulatingBayesUpdater
- Parameters:
variable
- variable indexvalue
- category index- Returns:
- P(variable = value | evidence), where evidence is getEvidence().
-
isJointMarginalSupported
public boolean isJointMarginalSupported()isJointMarginalSupported.
- Specified by:
isJointMarginalSupported
in interfaceBayesUpdater
- Returns:
- a boolean
-
getJointMarginal
public double getJointMarginal(int[] variables, int[] values) getJointMarginal.
- Specified by:
getJointMarginal
in interfaceBayesUpdater
- Parameters:
variables
- an array of objectsvalues
- an array of objects- Returns:
- a double
-
calculatePriorMarginals
public double[] calculatePriorMarginals(int nodeIndex) Calculates the prior marginal probabilities of the given node.- Specified by:
calculatePriorMarginals
in interfaceBayesUpdater
- 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 interfaceBayesUpdater
- Parameters:
nodeIndex
- node index- Returns:
- P(node = value | evidence), where value is the value of the node in the Bayes net.
-
toString
-