程序代写代做代考 chain Bayesian Bayesian network CM3112 Artificial Intelligence Knowledge and reasoning:

CM3112 Artificial Intelligence Knowledge and reasoning:
Inference in Bayesian networks

Steven Schockaert
SchockaertS1@cardiff.ac.uk
School of Computer Science & Informatics Cardiff University


P (burglary|¬earthquake) = P (burglary) Joint probability distribution
P (earthquake|burglary) = P (earthquake)
Consider a Bayesian network with nodes corresponding to the random
P (¬maryCalls|¬alarm, ¬earthquake, johnCalls) variables X1,…,Xn
= P (¬maryCalls|¬alarm)
Let parents(Xi) denote the set of parents of Xi
P (earthquake|burglary, alarm) 6= P (earthquake|alarm)
Assume that parents(Xi) ⊆ {X1,…,Xi-1}
P (¬e|a, ¬c, d, f, ¬g, ¬i, b, ¬h)
= P(¬e|a,¬c,d,f,¬g,¬i,b)
Note: we can always find an ordering X1,…,Xn of the random variables for which this is satisfied because we assumed the network structure to be acyclic
= P(¬e|a,¬c,d,f,¬g,¬i)
The joint probability distribution encoded by the network is given by
Chain rule
Yn i=1
Yn i=1
P(X1 = x1,…,Xn = xn) = =
P(Xi = xi |X1 = x1,…,Xi1 = xi1)
P(Xi = xi |{Xj = xj |Xj 2 parents(Xi)})
Conditional independence assumptions encoded by the network

0 0162
P (third|AI, programming, ¬probability) = . 0.0706 0.2292
ExampleP(fail|AI,programming,¬probability)= 0.009 0.0392 0.2292
Example contd.
Retrieving the joint distribution:
P(x,…,x) 1 n
Burglary
Earthquake
P(E)
.002
P(B)
.001
BE
n
P(A|B,E)
=⇥ TT
TF
FT
i=1 FF
.95 P(x |
.94 i .29 .001
Alarm i parents(x ))
xi ⇥{xi,¬xi} JohnCalls
MaryCalls
A
P(J|A)
T F
.90 .05
A
P(M|A)
T F
.70 .01
P (john, mary, alarm, ¬burglary, ¬earthquake)
= P (john|alarm) · P (mary|alarm) · P (alarm|¬burglary, ¬earthquake)
· P (¬burglary) · P (¬earthquake) = 0.9 · 0.7 · 0.001 · 0.999 · 0.998
0.00063
Chapter 14.1–3 6

J
J
y
ExerciseSID#: Section:
Fig. 1: A simple Bayes net with Boolean
M = P oliticallyM otivatedP rosecutor, G = F oundGuilty, 6. 6 ) Probabilistic inference
6
BM
P(I)
(1
TT TF
Co
FT FF
pts.
.9 .5
nsider
.5 .1
the Ba net shown in Fig. 1.
(a) (3) Which, if any, of the following are asserted b
yes
P(M)
.1
P(B)
.9
BIM
(i) P(B,I,M) = P(B)P(I)P(M)
(ii) P(J|G) = P(J|G, I)
(iii) P(M|G,B,I) = P(M|G,B,I,J) Calculate the value of
BIM
P(G)
TTT TTF TFT TFF FTT FTF FFT FFF
.9 .8 .0 .0 .2 .1 .0 .0
G
(b) (2) Calculate the value of P (b, i, ¬m, g, j).
G
P(J)
T F
.9 .0
Bayes
net with
(c) (4) Calculate the probability that someone goes t and face a politically motivated prosecutor.
J
Boolean variables B = BrokeElectionLaw, I = Indicted,

P (john, burglary, earthquake)
¬|¬¬¬
Yn i=1
probabilities and derive the marginal distributions as before:
P (john | burglary, earthquake) = P (john, burglary, earthquake) P (burglary, earthquake)
P(X =x ,…,X =x )= 1 1 n n
P(X =x |X =x ,…,X =x ) i i 1 1 i1 i1
Example
Yn i=1
P(Xi = xi |{Yj = yj |Yj 2 parents(Xi)}) From the joint distribution, we can evaluate all other (conditional)
=
To find α we will also evaluate:
P (¬john | burglary, earthquake) = P (¬john, burglary, earthquake)
= ↵ · P (john, burglary, earthquake) 1
P (burglary, earthquake)
= ↵ · P (¬john, burglary, earthquake)

P (¬john | burglary, earthquake) = P (¬john, burglary, earthquake) P (burglary, earthquake)
Example = ↵ · P (¬john, burglary, earthquake) P (john, burglary, earthquake)
definition of marginal distribution
using the conditional independencies from the Bayesian network
X X
=
= X X
=
=
0.001 · 0.002 · X X P (john|Alarm = a) · P (Alarm = a|burglary, earthquake)· a2{T ,F } m2{T ,F }
P (Mary = m|Alarm = a)
0.001 · 0.002 · ⇣P (john|alarm) · P (alarm|burglary, earthquake) · P (mary|alarm)
+ P (john|alarm) · P (alarm|burglary, earthquake) · P (¬mary|alarm)
+P(john|¬alarm)·P(¬alarm|burglary,earthquake)·P(mary|¬alarm) ⌘
+ P (john|¬alarm) · P (¬alarm|burglary, earthquake) · P (¬mary|¬alarm)
0.001·0.002.(0.9·0.95·0.7+0.9·0.95·0.3+0.05·0.05·0.01+0.05·0.05·0.99) 1715 · 109
= =
a2{T ,F } m2{T ,F } a2{T ,F } m2{T ,F }
P (john, burglary, earthquake, Alarm = a, Mary = m)
P (john|Alarm = a) · P (burglary) · P (earthquake)·
P (Alarm = a|burglary, earthquake) · P (Mary = m|Alarm = a)

g 2000 · · 2000
+ P (john|alarm) · P (alarm|burglary, earthquake) · P (¬mary|alarm)
+P(john|¬alarm)·P(¬alarm|burglary,earthquake)·P(mary|¬alarm) ⌘ + P (john|¬alarm) · P (¬alarm|burglary, earthquake) · P (¬mary|¬alarm)
= 0.001 · 0.002.(0.9 · 0.95 · 0.7 + 0.9 · 0.95 · 0.3 + 0.05 · 0.05 · 0.01 + 0.05 · 0.05 · 0.99) = 1715 · 109
In the same way we find:
P (¬john, burglary⇣, earthquake)
= 0.001 · 0.002 · P (¬john|alarm) · P (alarm|burglary, earthquake) · P (mary|alarm)
+ P (¬john|alarm) · P (alarm|burglary, earthquake) · P (¬mary|alarm)
+P(¬john|¬alarm)·P(¬alarm|burglary,earthquake)·P(mary|¬alarm) ⌘
+ P (¬john|¬alarm) · P (¬alarm|burglary, earthquake) · P (¬mary|¬alarm) = 0.001 · 0.002.(0.1 · 0.95 · 0.7 + 0.1 · 0.95 · 0.3 + 0.95 · 0.05 · 0.01 + 0.95 · 0.05 · 0.99)
= 285 · 109 Hence:
109 109 ↵ = 1715 + 285 = 2000
109
lary, earthquake) = 1715
Example
109 109 ↵ = 1715+285 = 2000
2
P (john | burglary, earthquake) = 2000 · 1715 · 10 = 2000
109 91715
9 10 =
1715

Inference from Bayesian networks
This way of obtaining probabilities and conditional probabilities from a Bayesian network is sometimes also called inference by enumeration
It is easy to implement, but still too slow for dealing with complex problems
Implementing inference from Bayesian networks more efficiently is a major research topic in artificial intelligence
Approximate methods, which find a value which is likely to be close to the actual probability, can be particularly efficient