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.
- Version:
- $Id: $Id
- Author:
- josephramsey
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionRowSummingExactUpdater(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 SummaryModifier 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.The BayesIm that this updater bases its update on.Getter for the fieldevidence.doublegetJointMarginal(int[] variables, int[] values) getJointMarginal.Getter for the fieldmanipulatedBayesIm.getManipulatedGraph.doublegetMarginal(int variable, int value) Returns the marginal probability of the given variable taking the given value, given the evidence.The updated BayesIm.booleanisJointMarginalSupported.static RowSummingExactUpdaterGenerates a simple exemplar of this class to test serialization.voidsetEvidence(Evidence evidence) Sets new evidence for the updater.toString()Prints out the most recent marginal.
- 
Constructor Details
- 
Method Details- 
serializableInstanceGenerates a simple exemplar of this class to test serialization.- Returns:
- a RowSummingExactUpdaterobject
 
- 
getBayesImThe BayesIm that this updater bases its update on. This BayesIm is not modified; rather, a new BayesIm is created and updated.- Specified by:
- getBayesImin interface- BayesUpdater
- Returns:
- a BayesImobject
 
- 
getManipulatedBayesImGetter for the field manipulatedBayesIm.- Specified by:
- getManipulatedBayesImin interface- ManipulatingBayesUpdater
- Returns:
- the updated BayesIm.
 
- 
getManipulatedGraphgetManipulatedGraph. - Specified by:
- getManipulatedGraphin interface- ManipulatingBayesUpdater
- Returns:
- a Graphobject
 
- 
getUpdatedBayesImThe updated BayesIm. This is a different object from the source BayesIm.- Specified by:
- getUpdatedBayesImin interface- ManipulatingBayesUpdater
- Returns:
- a BayesImobject
- See Also:
 
- 
getEvidenceGetter for the field evidence.- Specified by:
- getEvidencein interface- ManipulatingBayesUpdater
- Returns:
- a defensive copy of the evidence.
 
- 
setEvidenceSets 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:
- setEvidencein interface- BayesUpdater
- Specified by:
- setEvidencein interface- ManipulatingBayesUpdater
- Parameters:
- evidence- evidence
 
- 
isJointMarginalSupportedpublic boolean isJointMarginalSupported()isJointMarginalSupported. - Specified by:
- isJointMarginalSupportedin interface- BayesUpdater
- Returns:
- a boolean
 
- 
getJointMarginalpublic double getJointMarginal(int[] variables, int[] values) getJointMarginal. - Specified by:
- getJointMarginalin interface- BayesUpdater
- Parameters:
- variables- an array of objects
- values- an array of objects
- Returns:
- a double
 
- 
getMarginalpublic 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:
- getMarginalin interface- BayesUpdater
- Specified by:
- getMarginalin interface- ManipulatingBayesUpdater
- Parameters:
- variable- variable index
- value- category index
- Returns:
- P(variable = value | evidence), where evidence is getEvidence().
 
- 
calculatePriorMarginalspublic double[] calculatePriorMarginals(int nodeIndex) Calculates the prior marginal probabilities of the given node.- Specified by:
- calculatePriorMarginalsin interface- BayesUpdater
- Parameters:
- nodeIndex- node index
- Returns:
- P(node = value), where value is the value of the node in the Bayes net.
 
- 
calculateUpdatedMarginalspublic double[] calculateUpdatedMarginals(int nodeIndex) Calculates the updated marginal probabilities of the given node, given the evidence.- Specified by:
- calculateUpdatedMarginalsin interface- BayesUpdater
- Parameters:
- nodeIndex- node index
- Returns:
- P(node = value | evidence), where value is the value of the node in the Bayes net.
 
- 
toStringPrints out the most recent marginal.
 
-