Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1cae59f

Browse files
committed
Document enumerate_all(). Fix a couple of figure refs missed before.
1 parent 9bde96d commit 1cae59f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

probability.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def variable_node(self, var):
242242
raise Exception("No such variable: %s" % var)
243243

244244
def variables(self):
245-
"""List all the variables in the net.
245+
"""List all of the net's variables, parents before children.
246246
>>> burglary.variables()
247247
['Burglary', 'Earthquake', 'Alarm', 'JohnCalls', 'MaryCalls']"""
248248
return [n.variable for n in self.nodes]
@@ -287,8 +287,10 @@ def enumeration_ask(X, e, bn):
287287
return Q.normalize()
288288

289289
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."""
292294
if not vars:
293295
return 1.0
294296

@@ -324,7 +326,7 @@ def sum_out(var, factors):
324326

325327
#______________________________________________________________________________
326328

327-
# Fig. 14.11a: sprinkler network
329+
# Fig. 14.12a: sprinkler network
328330

329331
sprinkler = BayesNet([
330332
node('Cloudy', '', 0.5),
@@ -419,7 +421,7 @@ def weighted_sample(bn, e):
419421
>>> P['rain'] #doctest:+ELLIPSIS
420422
0.2...
421423
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):
423425
>>> P = JointProbDist(['Toothache', 'Cavity', 'Catch'])
424426
>>> T, F = True, False
425427
>>> 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

Comments
 (0)