public class EliminationAsk extends java.lang.Object implements BayesInference
function ELIMINATION-ASK(X, e, bn) returns a distribution over X
inputs: X, the query variable
e, observed values for variables E
bn, a Bayesian network specifying joint distribution P(X1, ..., Xn)
factors <- []
for each var in ORDER(bn.VARS) do
factors <- [MAKE-FACTOR(var, e) | factors]
if var is hidden variable the factors <- SUM-OUT(var, factors)
return NORMALIZE(POINTWISE-PRODUCT(factors))
Figure 14.11 The variable elimination algorithm for inference in Bayesian
networks. | Constructor and Description |
|---|
EliminationAsk() |
| Modifier and Type | Method and Description |
|---|---|
CategoricalDistribution |
ask(RandomVariable[] X,
AssignmentProposition[] observedEvidence,
BayesianNetwork bn) |
protected void |
calculateVariables(RandomVariable[] X,
AssignmentProposition[] e,
BayesianNetwork bn,
java.util.Set<RandomVariable> hidden,
java.util.Collection<RandomVariable> bnVARS)
Note:Override this method for a more efficient implementation as
outlined in AIMA3e pgs.
|
CategoricalDistribution |
eliminationAsk(RandomVariable[] X,
AssignmentProposition[] e,
BayesianNetwork bn)
The ELIMINATION-ASK algorithm in Figure 14.11.
|
protected java.util.List<RandomVariable> |
order(BayesianNetwork bn,
java.util.Collection<RandomVariable> vars)
Note:Override this method for a more efficient implementation as
outlined in AIMA3e pgs.
|
public CategoricalDistribution eliminationAsk(RandomVariable[] X, AssignmentProposition[] e, BayesianNetwork bn)
X - the query variables.e - observed values for variables E.bn - a Bayes net with variables {X} ∪ E ∪ Y /* Y = hidden
variables //public CategoricalDistribution ask(RandomVariable[] X, AssignmentProposition[] observedEvidence, BayesianNetwork bn)
ask in interface BayesInferenceX - the query variables.observedEvidence - observed values for variables E.bn - a Bayes net with variables {X} ∪ E ∪ Y /* Y = hidden
variablesprotected void calculateVariables(RandomVariable[] X, AssignmentProposition[] e, BayesianNetwork bn, java.util.Set<RandomVariable> hidden, java.util.Collection<RandomVariable> bnVARS)
X - the query variables.e - observed values for variables E.bn - a Bayes net with variables {X} ∪ E ∪ Y /* Y = hidden
variables //hidden - to be populated with the relevant hidden variables Y.bnVARS - to be populated with the subset of the random variables
comprising the Bayesian Network with any irrelevant hidden
variables removed.protected java.util.List<RandomVariable> order(BayesianNetwork bn, java.util.Collection<RandomVariable> vars)
bn - the Bayesian Network over which the query is being made. Note,
is necessary to provide this in order to be able to determine
the dependencies between variables.vars - a subset of the RandomVariables making up the Bayesian
Network, with any irrelevant hidden variables alreay removed.