Você está na página 1de 3

Hw5

Q1. DAG representation is:

B C E

D
Q1 b.
P(a,b ,c ,d ,e) = P(a) P(b|a) P(c|a ,b) P(d|a,b,c) P(e|a,b,c, d)
= P(a) P(b|a) P(c|a) P(d | b,c) P(e | c)
= P(a) P(b|a) P(c|a) (1 P(d|b,c)) P(e | c)
= 0.2 0.8 0.2 0.2 0.8=0.00512
2. P(a,b ,c ,d ,e)
= P(a) P(b | a) (1 P(c | a)) (1 P(d | b,c)) P(e | c)
= 0.2 0.8 0.8 0.2 0.6=0.01536
3. P(a ,b,c ,d ,e) = P(a) (1 P(b | a)) P(c | a) (1 P(d | b,c)) P(e | c)
= 0.2 0.2 0.2 0.2 0.8=0.00128
4. P(a ,b,c,d,e) = P(a) (1 P(b | a)) (1 P(c | a)) (1 P(d | b,c)) P(e | c)
= 0.2 0.2 0.8 0.95 0.6=0.01824
5. P(a,b,c,d,e) = (1 P(a)) P(b | a) P(c | a) (1 P(d | b,c)) P(e | c)
= 0.8 0.2 0.05 0.2 0.8=0.00128
6. P(a, b,c ,d, e) = (1 P(a)) P(b | a) (1 P(c | a)) (1 P(d | b,c)) P(e | c)
= 0.8 0.2 0.95 0.2 0.6=0.01824
7. P(a ,b, c, d,e) = (1 P(a)) (1 P(b | a)) P(c | a) (1 P(d | b,c)) P(e | c)
= 0.8 0.8 0.05 0.2 0.8=0.00512
8. P(a ,b, c ,d , e) = (1 P(a)) (1 P(b | a)) (1 P(c | a)) (1 P(d | b. c)) P(e |
c) = 0.8 0.8 0.95 0.95 0.6=0.34656.
Q1c. Given that patient has patient has metastatic cancer is with probability 0.2. We have two
scenarios to check that if this information makes it more probable that patient has cancer under
given conditions in the problem or not.
So we have find out whether P(a |d,e) is greater or smaller than P(a)
Using Bayes condition probability formulae, we have:
P(a|d,e) = P(a,d,e)/P(d,e)
Now P(a,d,e) = P(a,b,c,d,e) + P(a,b,c,d,e) + P(a,b,c,d,e) + P(a,b,c,d,e)
P(a,d,e)=0.04 ,
P(d,e) = 0.00512+0.01536+0.00128+0.01824+0.00128+0.01824+0.00512+0.34656 = 0.4112.
P(a |d,e)=0.04/0.4112 which is approximately 0.1 which is less than 0.2.So we are less inclined to
believe that the patient has cancer.
3.
P Q R P v Q P v R QvR Q v R
1 0 0 False False False False
1 1 0 True False True True
0 1 0 True True True True

It is given that in start only P is true. After that in second step we choose Q as true since it does
satisfy maximum number of clause. Again after that we flip P, in If clause of WALK-SAT to reach the
complete solution which makes the assignment satisfy the expression.
Then we return the solution.

4.
a. The normalized weight is: e1.5 * e1.5 * e1.1 * e1.1 * e1.1 * e1.1 *e1.1
b. The normalized weight is: e0 * e0 * e1.1 * e1.1 * e1.1 * e1.1 *e1.1
c. The normalized weight is: e1.5 * e1.5 * e1.1 * e1.1 * e1.1 * e1.1 *e1.1
d. The normalized weight is: e1.5 * e0 * e1.1 * e1.1 * e1.1 * e1.1 *e1.1

5.
The solution.mln file is same for every program run only change is in evidence.db file
person ={A,B,C}
//Predicate Declaration
Friends(person,person)
Smokes(person)
Cancer(person)
//Rules
1.5 Smokes(x) => Cancer(x)
1.1 Friends(x,y) => (Smokes(x) <=> Smokes(y))
a. evidence.db
Friends(A,B)
Friends(B,C)
Command : infer -i 5a.mln -r out -e evidence.db -q Cancer; more out
Output : Cancer(A) 0.615988
Cancer(B) 0.588991
Cancer(C) 0.610989
b. evidence.db
Smokes(A)
Friends(A,B)
Friends(B,C)
Command : infer -i 5a.mln -r out -e evidenceb.db -q Cancer; more out
Output: Cancer(A) 0.79597
Cancer(B) 0.522998
Cancer(C) 0.506999
c . evidence.db:
Smokes(A)
Smokes(B)
Friends(A,B)
Friends(B,C)
Command: infer -i 5a.mln -r out -e evidencec.db -q Cancer; more out
Output : Cancer(A) 0.790971
Cancer(B) 0.838966
Cancer(C) 0.508999

c. evidence.db
Smokes(A)
Smokes(B)
Smokes(C)
Friends(A,B)
Friends(B,C)

Command: infer -i 5a.mln -r out -e evidenced.db -q Cancer; more out


Output: Cancer(A) 0.785971
Cancer(B) 0.825967
Cancer(C) 0.825967

Você também pode gostar