;; Here is a simple Bayesian network consisting of five nodes, one of which;; depends on two parents, both of which depend on a single ancestor.  This;; forms an undirected loop.  The example is originally from Cooper, and;; models consequences of a brain tumor.  For binary variables, the #f value;; comes before the #t value.(define mcbn1  (define-bnet 'mcbn1    '((a () (0.8 0.2))                  ;; P(A) = 0.2      (b (a) ((0.9 0.1) (0.3 0.7)))     ;; P(B|~A) = 0.1, P(B|A) = 0.7      (c (a) ((0.7 0.3) (0.4 0.6)))     ;; ...      (d (b c) (((0.9 0.1) (0.7 0.3)) ((0.6 0.4) (0.2 0.8))))       ;; P(D|~B,~C) = 0.1, P(D|~B,C) = 0.3, P(D|B,~C) = 0.4, P(D|B,C) = 0.8      (e (c) ((0.9 0.1) (0.6 0.4))))));; Here are a few simple example calculations to try:;;;; (infer mcbn1 '((a #t)));; (infer mcbn1 '((a #f) (e #t)));; (infer mcbn1 '((a #t) (b #f) (c #t) (d #t) (e #t)));;;; A conditional probability, say P(e=#t|a=#f) is P(e=#t,a=#f)/P(a=#f);; Thus,;; (/ (infer mcbn1 '((a #f) (e #t))) (infer mcbn1 '((a #f))))(define mcbn2  (define-bnet 'mcbn2    '((a () (0.8 0.2))      (b (a) (noisy-or 0.1 0.9))      (c (a) (noisy-or 0.05 0.8))      (d (b c) (noisy-or 0.0 0.9 0.75))      (e (c) (noisy-or 0.1 0.6)))))