return rVal;
}
public CategoricalDistribution jointDistribution(
Proposition... propositions) {
ProbabilityTable d = null;
final Proposition conjProp = ProbUtil
.constructConjunction(propositions);
final LinkedHashSet<RandomVariable> vars = new LinkedHashSet<RandomVariable>(
conjProp.getUnboundScope());
if (vars.size() > 0) {
RandomVariable[] distVars = new RandomVariable[vars.size()];
int i = 0;
for (RandomVariable rv : vars) {
distVars[i] = rv;
i++;
}
final ProbabilityTable ud = new ProbabilityTable(distVars);
final Object[] values = new Object[vars.size()];
ProbabilityTable.Iterator di = new ProbabilityTable.Iterator() {
public void iterate(Map<RandomVariable, Object> possibleWorld,
double probability) {
if (conjProp.holds(possibleWorld)) {
int i = 0;
for (RandomVariable rv : vars) {
values[i] = possibleWorld.get(rv);
i++;
}
int dIdx = ud.getIndex(values);
ud.setValue(dIdx, ud.getValues()[dIdx] + probability);
}
}
public Object getPostIterateValue() {
return null; // N/A
}
};
RandomVariable[] X = conjProp.getScope().toArray(
new RandomVariable[conjProp.getScope().size()]);
((ProbabilityTable) bayesInference.ask(X,
new AssignmentProposition[0], bayesNet))
.iterateOverTable(di);
d = ud;
} else {
// No Unbound Variables, therefore just return
// the singular probability related to the proposition.
d = new ProbabilityTable();
d.setValue(0, prior(propositions));
}
return d;
}