001 /* 002 * Created on Dec 28, 2004 003 * 004 */ 005 package aima.probability; 006 007 import java.util.Hashtable; 008 009 import aima.util.Util; 010 011 /** 012 * @author Ravi Mohan 013 * 014 */ 015 016 public class EnumerateJointAsk { 017 018 public static double[] ask(Query q, ProbabilityDistribution pd) { 019 double[] probDist = new double[2]; 020 Hashtable<String, Boolean> h = q.getEvidenceVariables(); 021 022 // true probability 023 h.put(q.getQueryVariable(), new Boolean(true)); 024 probDist[0] = pd.probabilityOf(h); 025 // false probability 026 h.put(q.getQueryVariable(), new Boolean(false)); 027 probDist[1] = pd.probabilityOf(h); 028 return Util.normalize(probDist); 029 030 } 031 032 }