@@ -242,7 +242,7 @@ def variable_node(self, var):
242
242
raise Exception ("No such variable: %s" % var )
243
243
244
244
def variables (self ):
245
- """List all the variables in the net .
245
+ """List all of the net's variables, parents before children .
246
246
>>> burglary.variables()
247
247
['Burglary', 'Earthquake', 'Alarm', 'JohnCalls', 'MaryCalls']"""
248
248
return [n .variable for n in self .nodes ]
@@ -287,8 +287,10 @@ def enumeration_ask(X, e, bn):
287
287
return Q .normalize ()
288
288
289
289
def enumerate_all (vars , e , bn ):
290
- """ XXX rewrite this doc comment
291
- Precondition: no variable in vars precedes its parents."""
290
+ """Return the sum of those entries in P(vars | e{others})
291
+ consistent with e, where P is the joint distribution represented
292
+ by bn, and e{others} means e restricted to bn's other variables
293
+ (the ones other than vars). Parents must precede children in vars."""
292
294
if not vars :
293
295
return 1.0
294
296
@@ -324,7 +326,7 @@ def sum_out(var, factors):
324
326
325
327
#______________________________________________________________________________
326
328
327
- # Fig. 14.11a : sprinkler network
329
+ # Fig. 14.12a : sprinkler network
328
330
329
331
sprinkler = BayesNet ([
330
332
node ('Cloudy' , '' , 0.5 ),
@@ -419,7 +421,7 @@ def weighted_sample(bn, e):
419
421
>>> P['rain'] #doctest:+ELLIPSIS
420
422
0.2...
421
423
422
- ## A Joint Probability Distribution is dealt with like this (p. 475 ):
424
+ ## A Joint Probability Distribution is dealt with like this (Fig. 13.3 ):
423
425
>>> P = JointProbDist(['Toothache', 'Cavity', 'Catch'])
424
426
>>> T, F = True, False
425
427
>>> P[T, T, T] = 0.108; P[T, T, F] = 0.012; P[F, T, T] = 0.072; P[F, T, F] = 0.008
0 commit comments