Package edu.cmu.tetrad.bayes
Class RowSummingExactUpdater
java.lang.Object
edu.cmu.tetrad.bayes.RowSummingExactUpdater
- All Implemented Interfaces:
BayesUpdater
,ManipulatingBayesUpdater
,TetradSerializable
,Serializable
Performs updating operations on a BayesIm by summing over cells in the joint probability table for the BayesIm. Quite
flexible and fast if almost all of the variables in the Bayes net are in evidence. Can be excruciatingly slow if
numVars - numVarsInEvidence is more than 15.
- Author:
- josephramsey
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionRowSummingExactUpdater
(BayesIm bayesIm) Constructs a new updater for the given Bayes net.RowSummingExactUpdater
(BayesIm bayesIm, Evidence evidence) Constructs a new updater for the given Bayes net. -
Method Summary
Modifier and TypeMethodDescriptiondouble[]
calculatePriorMarginals
(int nodeIndex) double[]
calculateUpdatedMarginals
(int nodeIndex) The BayesIm that this updater bases its update on.double
getJointMarginal
(int[] variables, int[] values) double
getMarginal
(int variable, int value) The updated BayesIm.boolean
static RowSummingExactUpdater
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
-
RowSummingExactUpdater
Constructs a new updater for the given Bayes net. -
RowSummingExactUpdater
Constructs a new updater for the given Bayes net.
-
-
Method Details
-
serializableInstance
Generates a simple exemplar of this class to test serialization. -
getBayesIm
The BayesIm that this updater bases its update on. This BayesIm is not modified; rather, a new BayesIm is created and updated.- Specified by:
getBayesIm
in interfaceBayesUpdater
- Returns:
- the Bayes instantiated model that is being updated.
-
getManipulatedBayesIm
- Specified by:
getManipulatedBayesIm
in interfaceManipulatingBayesUpdater
- Returns:
- the updated BayesIm.
-
getManipulatedGraph
- Specified by:
getManipulatedGraph
in interfaceManipulatingBayesUpdater
- Returns:
- the graph for the manipulated BayesIm.
-
getUpdatedBayesIm
The updated BayesIm. This is a different object from the source BayesIm.- Specified by:
getUpdatedBayesIm
in interfaceManipulatingBayesUpdater
- Returns:
- the updated Bayes IM--that is, the Bayes IM in which all probabilities of variables conditional on their parents have been updated.
- See Also:
-
getEvidence
- Specified by:
getEvidence
in interfaceManipulatingBayesUpdater
- Returns:
- a defensive copy of the evidence.
-
setEvidence
Description copied from interface:ManipulatingBayesUpdater
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
-
isJointMarginalSupported
public boolean isJointMarginalSupported()- Specified by:
isJointMarginalSupported
in interfaceBayesUpdater
- Returns:
- true if the getJointMarginal() method is supported.
-
getJointMarginal
public double getJointMarginal(int[] variables, int[] values) - Specified by:
getJointMarginal
in interfaceBayesUpdater
- Returns:
- P(variables[i] = values[i] | evidence), where evidence is getEvidence().
-
getMarginal
public double getMarginal(int variable, int value) - Specified by:
getMarginal
in interfaceBayesUpdater
- Specified by:
getMarginal
in interfaceManipulatingBayesUpdater
- Returns:
- P(variable = value | evidence) where evidence is getEvidence().
-
calculatePriorMarginals
public double[] calculatePriorMarginals(int nodeIndex) - Specified by:
calculatePriorMarginals
in interfaceBayesUpdater
-
calculateUpdatedMarginals
public double[] calculateUpdatedMarginals(int nodeIndex) - Specified by:
calculateUpdatedMarginals
in interfaceBayesUpdater
-
toString
Prints out the most recent marginal.
-