def likelihood_weighting(X, e, bn, N):
W = dict((x, <NUM_LIT:0>) for x in bn.variable_values(X))<EOL>for j in range(N):<EOL><INDENT>sample, weight = weighted_sample(bn, e) <EOL>W[sample[X]] += weight<EOL><DEDENT>return ProbDist(X, W)<EOL>
Estimate the probability distribution of variable X given
    evidence e in BayesNet bn.  [Fig. 14.15]
    >>> seed(1017)
    >>> likelihood_weighting('Burglary', dict(JohnCalls=T, MaryCalls=T),
    ...   burglary, 10000).show_approx()
    'False: 0.702, True: 0.298'