Package edu.cmu.tetrad.bayes
Class BayesImProbs
java.lang.Object
edu.cmu.tetrad.bayes.BayesImProbs
- All Implemented Interfaces:
TetradSerializable
,Serializable
Calculates cell probabilities from conditional BayesIm probabilities on the fly without constructing the entire
table. (To force the entire table to be constructed, use StoredCellProbs.)
- Version:
- $Id: $Id
- Author:
- josephramsey
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionBayesImProbs
(BayesIm bayesIm) Constructs a BayesImProbs object from the given BayesIm. -
Method Summary
Modifier and TypeMethodDescriptiondouble
getCellProb
(int[] variableValues) Calculates the probability in the given cell from the conditional probabilities in the BayesIm.double
getConditionalProb
(Proposition assertion, Proposition condition) Calculates the conditional probability of an assertion given a condition.double
getProb
(Proposition assertion) Calculates the probability of a given proposition.Getter for the fieldvariables
.static BayesImProbs
Generates a simple exemplar of this class to test serialization.
-
Constructor Details
-
BayesImProbs
Constructs a BayesImProbs object from the given BayesIm.- Parameters:
bayesIm
- Ibid.
-
-
Method Details
-
serializableInstance
Generates a simple exemplar of this class to test serialization.- Returns:
- a simple exemplar of this class to test serialization.
-
getCellProb
public double getCellProb(int[] variableValues) Calculates the probability in the given cell from the conditional probabilities in the BayesIm. It's the product of the probabilities that each variable takes on the value it does given that the other variables take on the values they do in that cell. The returned value will be undefined (Double.NaN) if any of the conditional probabilities being multiplied together is undefined.- Parameters:
variableValues
- the values of the variables in the cell- Returns:
- the cell probability, or NaN if this probability is undefined.
-
getProb
Calculates the probability of a given proposition.- Parameters:
assertion
- the proposition for which we want to calculate the probability- Returns:
- the probability of the given proposition
-
getConditionalProb
Calculates the conditional probability of an assertion given a condition.- Parameters:
assertion
- the proposition representing the assertioncondition
- the proposition representing the condition- Returns:
- the conditional probability of the assertion given the condition
- Throws:
IllegalArgumentException
- if the assertion and condition are not for the same Bayes IM
-
getVariables
-