Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27,...
Transcript of Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27,...
![Page 1: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/1.jpg)
1
Solutions homework #2Carlos Cotrini
October 27, 2017
Probabilistic foundations of artificial intelligence
![Page 2: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/2.jpg)
2
1. Bayesian Networks: d-separation● Solutions task 1
A
B
C
D
F
E
G
H
I
J
B indep. I given F?
![Page 3: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/3.jpg)
3
Principle of d-separation● Given a set of observed variables, if there is no
active trail between two variables, then they are independent.
B
A
C
D
B
A
C
D
B indep from C | A Unclear if B indep from C | A, D
![Page 4: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/4.jpg)
4
1. Bayesian Networks: d-separation● Recap on active trails. Case 1. (Mountain)
Observed variable
Hidden variable
Observed orhidden variable
Inactive!
![Page 5: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/5.jpg)
5
1. Bayesian Networks: d-separation● Recap on active trails. Case 2a. (Downhill)
Inactive!
![Page 6: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/6.jpg)
6
1. Bayesian Networks: d-separation● Recap on active trails. Case 2b. (Uphill)
Inactive!
![Page 7: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/7.jpg)
7
1. Bayesian Networks: d-separation● Recap on active trails. Case 3. (Valley)
Inactive!
trail
![Page 8: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/8.jpg)
8
1. Bayesian Networks: d-separation● Recap on active trails. Case 3.
Inactive!
trail
![Page 9: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/9.jpg)
9
1. Bayesian Networks: d-separation● Recap on active trails. Case 3.
Inactive!
trail
![Page 10: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/10.jpg)
10
1. Bayesian Networks: d-separation● Recap on active trails. Case 3.
Inactive!
trail
![Page 11: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/11.jpg)
11
1. Bayesian Networks: d-separation● Solutions task 1
A
B
C
D
F
E
G
H
I
J
![Page 12: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/12.jpg)
12
1. Bayesian Networks: d-separation● Solutions task 1
A
B
C
D
F
E
G
H
I
J
A indep. F?
![Page 13: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/13.jpg)
13
1. Bayesian Networks: d-separation● Solutions task 1
A
B
C
D
F
E
G
H
I
J
A indep. F?
![Page 14: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/14.jpg)
14
1. Bayesian Networks: d-separation● Solutions task 1
A
B
C
D
F
E
G
H
I
J
A indep. F?
![Page 15: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/15.jpg)
15
1. Bayesian Networks: d-separation● Solutions task 1
A
B
C
D
F
E
G
H
I
J
A indep. F?
INCONCLUSIVE
![Page 16: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/16.jpg)
16
1. Bayesian Networks: d-separation● Solutions task 1
A
B
C
D
F
E
G
H
I
J
A indep. G?
![Page 17: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/17.jpg)
17
1. Bayesian Networks: d-separation● Solutions task 1
A
B
C
D
F
E
G
H
I
J
A indep. G?
![Page 18: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/18.jpg)
18
1. Bayesian Networks: d-separation● Solutions task 1
A
B
C
D
F
E
G
H
I
J
A indep. G?
![Page 19: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/19.jpg)
19
1. Bayesian Networks: d-separation● Solutions task 1
A
B
C
D
F
E
G
H
I
J
A indep. G?
YES!
![Page 20: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/20.jpg)
20
1. Bayesian Networks: d-separation● Solutions task 1
A
B
C
D
F
E
G
H
I
J
B indep. I given F?
![Page 21: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/21.jpg)
21
1. Bayesian Networks: d-separation● Solutions task 1
A
B
C
D
F
E
G
H
I
J
B indep. I given F?
![Page 22: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/22.jpg)
22
1. Bayesian Networks: d-separation● Solutions task 1
A
B
C
D
F
E
G
H
I
J
B indep. I given F?
INCONCLUSIVE
![Page 23: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/23.jpg)
23
1. Bayesian Networks: d-separation● Solutions task 1
A
B
C
D
F
E
G
H
I
J
D indep. J given G, H?
![Page 24: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/24.jpg)
24
1. Bayesian Networks: d-separation● Solutions task 1
A
B
C
D
F
E
G
H
I
J
D indep. J given G, H?
![Page 25: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/25.jpg)
25
1. Bayesian Networks: d-separation● Solutions task 1
A
B
C
D
F
E
G
H
I
J
D indep. J given G, H?
![Page 26: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/26.jpg)
26
1. Bayesian Networks: d-separation● Solutions task 1
A
B
C
D
F
E
G
H
I
J
D indep. J given G, H?
YES!
![Page 27: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/27.jpg)
27
1. Bayesian Networks: d-separation● Solutions task 1
A
B
C
D
F
E
G
H
I
J
I indep. B given H?
![Page 28: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/28.jpg)
28
1. Bayesian Networks: d-separation● Solutions task 1
A
B
C
D
F
E
G
H
I
J
I indep. B given H?
YES!
![Page 29: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/29.jpg)
29
1. Bayesian Networks: d-separation● Solutions task 1
A
B
C
D
F
E
G
H
I
J
D indep. J?
![Page 30: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/30.jpg)
30
1. Bayesian Networks: d-separation● Solutions task 1
A
B
C
D
F
E
G
H
I
J
D indep. J?
INCONCLUSIVE
![Page 31: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/31.jpg)
31
1. Bayesian Networks: d-separation● Solutions task 1
A
B
C
D
F
E
G
H
I
J
I indep. C given H, F?
![Page 32: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/32.jpg)
32
1. Bayesian Networks: d-separation● Solutions task 1
A
B
C
D
F
E
G
H
I
J
I indep. C given H, F?
INCONCLUSIVE
![Page 33: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/33.jpg)
33
Be careful with the direction of the arrows!
B
A
C
D
B indep from C ?
![Page 34: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/34.jpg)
34
Be careful with the direction of the arrows!
B
A
C
D
A indep from D ?
![Page 35: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/35.jpg)
35
2. Variable elimination● Compute
P(J = j)
AB
C
D
F
E
G
H
I
J
![Page 36: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/36.jpg)
36
2. Variable elimination● Compute
P(J = j)
AB
C
D
F
E
G
H
I
J
![Page 37: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/37.jpg)
37
2. Variable elimination● Compute
P(J = j)
AB
C
D
F
E
G
H
I
J
![Page 38: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/38.jpg)
38
2. Variable elimination● Compute
P(J = j)
AB
C
D
F
E
G
H
I
J
![Page 39: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/39.jpg)
39
2. Variable elimination● Compute
P(J = j)
AB
C
D
F
E
G
H
I
J
![Page 40: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/40.jpg)
40
2. Variable elimination● Compute
P(J = j)
AB
C
D
F
E
G
H
I
J
![Page 41: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/41.jpg)
41
2. Variable elimination● Compute
P(J = j)
AB
C
D
F
E
G
H
I
J
![Page 42: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/42.jpg)
1
3. An algorithm for d-separation● Given a Bayesian Network, a variable X, and a
set of variables E with observed values e, compute all variables Z that are indep. from X given E.
![Page 43: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/43.jpg)
2
3. Algorithm for d-separation
W
S
U
X
I
A
P
Q
EB
R
K
XXXX
![Page 44: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/44.jpg)
3
3. Algorithm for d-separation
W
S
U
X
I
A
P
Q
EB
R
K
XXXX
D-reachable: if it can be reached with an active trail from X
d-reachable
![Page 45: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/45.jpg)
4
3. Algorithm for d-separation
W
S
U
X
I
A
P
Q
EB
R
K
XXXX
![Page 46: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/46.jpg)
5
3. Algorithm for d-separation
W
S
U
X
I
A
P
Q
EB
R
K
XXXX
![Page 47: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/47.jpg)
6
3. Algorithm for d-separation
Key insight: Subtrails of active trails are also active!
![Page 48: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/48.jpg)
7
3. Algorithm for d-separation
Key insight: Subtrails of active trails are also active!
Compute d-reachable variables with a depth-first (or breadth-first) search.
![Page 49: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/49.jpg)
8
3. Algorithm for d-separation
W
S
U
Y
I
A
P
Q
EB
R
KtoVisit = [X]
X
d-reachable = {}
![Page 50: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/50.jpg)
9
3. Algorithm for d-separation
W
S
U
Y
I
A
P
Q
EB
R
KtoVisit = []
X
d-reachable = {X}
![Page 51: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/51.jpg)
10
3. Algorithm for d-separation
W
S
U
Y
I
A
P
Q
EB
R
KtoVisit = [A]
X
d-reachable = {X}
![Page 52: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/52.jpg)
11
3. Algorithm for d-separation
W
S
U
Y
I
A
P
Q
EB
R
KtoVisit = [S, A]
X
d-reachable = {X}
![Page 53: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/53.jpg)
12
3. Algorithm for d-separation
W
S
U
Y
I
A
P
Q
EB
R
KtoVisit = [I, S, A]
X
d-reachable = {X}
![Page 54: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/54.jpg)
13
3. Algorithm for d-separation
W
S
U
Y
I
A
P
Q
EB
R
KtoVisit = [S, A]
YX
d-reachable = {X}
![Page 55: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/55.jpg)
14
3. Algorithm for d-separation
W
S
U
Y
I
A
P
Q
EB
R
KtoVisit = [S, A]
YX
d-reachable = {X}
![Page 56: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/56.jpg)
15
3. Algorithm for d-separation
W
S
U
I
A
P
Q
B
R
KtoVisit = [A]
Y
E
YX
d-reachable = {X, S}
![Page 57: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/57.jpg)
16
3. Algorithm for d-separation
W
S
U
I
A
P
Q
B
R
KtoVisit = [W, A]
Y
E
YX
d-reachable = {X, S}
![Page 58: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/58.jpg)
17
3. Algorithm for d-separation
W
S
U
I
A
P
Q
B
R
KtoVisit = [B, W, A]
Y
E
YX
d-reachable = {X, S}
![Page 59: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/59.jpg)
18
3. Algorithm for d-separation
W
S
U
I
A
P
Q
B
R
KtoVisit = [U, B, W, A]
Y
E
YX
d-reachable = {X, S}
![Page 60: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/60.jpg)
19
3. Algorithm for d-separation
W
S
U
I
A
P
Q
B
R
KtoVisit = [W, B, A]
E
YYX
d-reachable = {X, S, U}
![Page 61: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/61.jpg)
20
3. Algorithm for d-separation
W
S
U
I
A
P
Q
B
R
KtoVisit = [B, A]
E
YYX
d-reachable = {X, S, U}
![Page 62: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/62.jpg)
21
3. Algorithm for d-separation
W
S
U
I
A
P
Q
B
R
KtoVisit = [B, A]
E
YYX
d-reachable = {X, S, U}
![Page 63: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/63.jpg)
22
3. Algorithm for d-separation
W
S
U
I
A
P
Q
B
R
KtoVisit = [A]
E
YYX
d-reachable = {X, S, U}
![Page 64: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/64.jpg)
23
3. Algorithm for d-separation
W
S
U
I
A
P
Q
B
R
KtoVisit = [R, A]
E
YYX
d-reachable = {X, S, U}
![Page 65: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/65.jpg)
24
3. Algorithm for d-separation
W
S
U
I
A
P
Q
B
R
KtoVisit = [A]
E
YYX
d-reachable = {X, S, U, R}
![Page 66: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/66.jpg)
25
3. Algorithm for d-separation
W
S
U
E
I
A
P
Q
B
R
KtoVisit = []
E
YX
d-reachable = {X, S, U, R, A}
![Page 67: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/67.jpg)
26
3. Algorithm for d-separation
W
S
U
E
I
A
P
Q
B
R
KtoVisit = []
E
YX
d-reachable = {X, S, U, R, A}
![Page 68: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/68.jpg)
27
3. Algorithm for d-separation
W
S
U
E
I
A
P
Q
B
R
KtoVisit = [K]
E
YX
d-reachable = {X, S, U, R, A}
![Page 69: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/69.jpg)
28
3. Algorithm for d-separation
W
S
U
E
I
A
P
Q
B
R
KtoVisit = []
E
YX
d-reachable = {X, S, U, R, A, K}
![Page 70: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/70.jpg)
29
3. Algorithm for d-separation
def get_reachable(X, E):toVisit = [X], visited = {}
while toVisit != []:V = toVisit.pop()
“visit V”
add V to visited
for Y an unvisited neighbor of V:if …. then push Y
Loop’s invariant: Z is in toVisit iff there is an active trail from X to Z
![Page 71: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/71.jpg)
30
3. Algorithm for d-separation
def get_reachable(X, E):toVisit = [X], visited = {}, reachable = {}
while toVisit != []:V = toVisit.pop()
if V is not obs then add V to reachable
add V to visited
for Y an unvisited neighbor of V:if …. then push Y
Loop’s invariant: Z is in toVisit iff there is an active trail from X to Z
![Page 72: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/72.jpg)
31
What neighbors to append?● Let V be the node currently visited and Y be an
unvisited neighbor.● By our invariant, there is an active trail t from X
to V.● What we need to decide if t.append(Y) active...
![Page 73: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/73.jpg)
32
What neighbors to append?● Let V be the node currently visited and Y be an
unvisited neighbor.● By our invariant, there is an active trail t from X
to V.● What we need to decide if t.append(Y) active...
– V - -> Y or V <- - Y?
![Page 74: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/74.jpg)
33
What neighbors to append?● Let V be the node currently visited and Y be an
unvisited neighbor.● By our invariant, there is an active trail t from X
to V.● What we need to decide if t.append(Y) active...
– V - -> Y or V <- - Y?
– Is V or any of its descendants observed?
![Page 75: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/75.jpg)
34
What neighbors to append?● Let V be the node currently visited and Y be an
unvisited neighbor.● By our invariant, there is an active trail t from X
to V.● What we need to decide if t.append(Y) active...
– V - -> Y or V <- - Y?
– Is V or any of its descendants observed?
– W - -> V or W <- - V? (W is V’s predecesor in t)
![Page 76: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/76.jpg)
35
What neighbors to append?● Let V be the node currently visited and Y be an
unvisited neighbor.● By our invariant, there is an active trail t from X
to V.● What we need to decide if t.append(Y) active...
– V - -> Y or V <- - Y?
Easy to check
– Is V or any of its descendants observed?
– W - -> V or W <- - V? (W is V’s predecesor in t)
![Page 77: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/77.jpg)
36
What neighbors to append?● Let V be the node currently visited and Y be an
unvisited neighbor.● By our invariant, there is an active trail t from X
to V.● What we need to decide if t.append(Y) active...
– V - -> Y or V <- - Y?
Easy to check
– Is V or any of its descendants observed?
Compute in advance the ancestors of all observed variables
– W - -> V or W <- - V? (W is V’s predecesor in t)
![Page 78: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/78.jpg)
37
What neighbors to append?● Let V be the node currently visited and Y be an
unvisited neighbor.● By our invariant, there is an active trail t from X
to V.● What we need to decide if t.append(Y) active...
– V - -> Y or V <- - Y?
Easy to check
– Is V or any of its descendants observed?
Compute in advance the ancestors of all observed variables
– W - -> V or W <- - V? (W is V’s predecesor in t)
Keep track how you reached V
![Page 79: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/79.jpg)
38
3. Algorithm for d-separation
def get_reachable(X, E):toVisit = [X], visited = {}, reachable = {}
while toVisit != []:V = toVisit.pop()
if V is not obs then add V to reachable
add V to visited
for Y an unvisited neighbor of V:if …. then push Y
Loop’s invariant: Z is in toVisit iff there is an active trail from X to Z
![Page 80: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/80.jpg)
39
3. Algorithm for d-separation
def get_reachable(X, E):toVisit = [X], visited = {}, reachable = {}
ancestors_E = computeAncestors(E)
while toVisit != []:V = toVisit.pop()
if V is not obs then add V to reachable
add V to visited
for Y an unvisited neighbor of V:if …. then push Y
Loop’s invariant: Z is in toVisit iff there is an active trail from X to Z
![Page 81: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/81.jpg)
40
3. Algorithm for d-separation
def get_reachable(X, E):toVisit = [(<--,X)], visited = {}, reachable = {}
ancestors_E = computeAncestors(E)
while toVisit != []:(dir, V) = toVisit.pop()
if V is not obs then add V to reachable
add V to visited
for Y an unvisited neighbor of V:if …. then push Y
Loop’s invariant: Z is in toVisit iff there is an active trail from X to Z
![Page 82: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/82.jpg)
41
for Y an unvisited neighbor of V:● If dir == <-- :
● If dir == --> :
![Page 83: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/83.jpg)
42
for Y an unvisited neighbor of V:● If dir == <-- :
–
● If dir == --> :– If V --> Y:
●
– If V <-- Y:●
![Page 84: Solutions homework #2 - ETH Z · PDF file1 Solutions homework #2 Carlos Cotrini October 27, 2017 Probabilistic foundations of artificial intelligence](https://reader031.fdocuments.in/reader031/viewer/2022030417/5aa36d6a7f8b9a46238e4f18/html5/thumbnails/84.jpg)
43
for Y an unvisited neighbor of V:● If dir == <-- :
– If V is not observed, then push (dir’, Y)
● If dir == --> :– If V --> Y:
● If V is not observed, then push (-->, Y)
– If V <-- Y:● If V is in ancestors_E, then push (<--, Y)