PGM Assignment 2
Question 3
Now we have four binary variables A, B, C, D, and two cases of their joint distribution.
Notice that in TABLE 2, we only give you an unnormalized probability distribution. But you can transfrom these to a normalized distribution by dividing the sum of all unnormalized Ps.
Check all independent and conditionally independent relations among A, B, C, D. (Hint: do you need a normalized distribution for this problem?)
Table 1: Joint distribution of A, B, C, D.
A | B | C | D | P |
---|---|---|---|---|
0 | 0 | 0 | 0 | 0.0096 |
0 | 0 | 0 | 1 | 0.0144 |
0 | 0 | 1 | 0 | 0.0224 |
0 | 0 | 1 | 1 | 0.0336 |
0 | 1 | 0 | 0 | 0.004 |
0 | 1 | 0 | 1 | 0.004 |
0 | 1 | 1 | 0 | 0.006 |
0 | 1 | 1 | 1 | 0.006 |
1 | 0 | 0 | 0 | 0.216 |
1 | 0 | 0 | 1 | 0.144 |
1 | 0 | 1 | 0 | 0.216 |
1 | 0 | 1 | 1 | 0.144 |
1 | 1 | 0 | 0 | 0.0756 |
1 | 1 | 0 | 1 | 0.0324 |
1 | 1 | 1 | 0 | 0.0504 |
1 | 1 | 1 | 1 | 0.0216 |
Table 2: Joint distribution of A, B, C, D.
A | B | C | D | Unnormalized P |
---|---|---|---|---|
0 | 0 | 0 | 0 | 360000 |
0 | 0 | 0 | 1 | 600 |
0 | 0 | 1 | 0 | 36000 |
0 | 0 | 1 | 1 | 3600 |
0 | 1 | 0 | 0 | 600 |
0 | 1 | 0 | 1 | 100000 |
0 | 1 | 1 | 0 | 60 |
0 | 1 | 1 | 1 | 600000 |
1 | 0 | 0 | 0 | 6000 |
1 | 0 | 0 | 1 | 10 |
1 | 0 | 1 | 0 | 900 |
1 | 0 | 1 | 1 | 90 |
1 | 1 | 0 | 0 | 600 |
1 | 1 | 0 | 1 | 100000 |
1 | 1 | 1 | 0 | 90 |
1 | 1 | 1 | 1 | 900000 |
Solution
关于记号的注解:
\(x0\) 代表 \(x=0\)
\(x0y0\) 代表事件 \((x=0, y=0)\)
Table 1
涉及浮点数的数值比较精确到小数点后4位
1 |
import pandas as pd |
单个事件概率
1 |
prob_dict={} |
1 |
for i in ['a','b','c','d']: |
1 |
P(a=0)=0.1 |
所有组合
1 |
for a in [0.5, 0, 1]: |
1 |
for ele in prob_dict.keys(): |
1 |
P(a0) = 0.1000 |
2个元素独立性
1 |
for ele in prob_dict.keys(): |
1 |
P(a1b1) = P(a1) * P(b1) |
\[ \therefore \ A \ \bot \ B \]
3个元素独立性
1 |
def sort_var_name(_list): |
1 |
for ele in prob_dict.keys(): |
结果
1 |
P(a1b0d1) = P(a1) * P(b0) * P(d1) |
4个元素独立性
1 |
for ele in prob_dict.keys(): |
结果
1 |
P(c1, d1|a1b1) = P(c1|a1b1)*P(d1|a1b1) |
\[ \therefore \ (C\ \bot\ D \ | \ A,\ B)\]
Table 2
1 |
import pandas as pd |
单个事件概率
原始数据经过标准化,涉及浮点数的数值比较精确到小数点后3位
1 |
prob_dict={} |
1 |
for i in ['a','b','c','d']: |
1 |
P(a=0)=0.5 |
所有组合
1 |
for a in [0.5, 0, 1]: |
1 |
for ele in prob_dict.keys(): |
1 |
P(a0) = 0.5221 |
2个元素独立性
1 |
for ele in prob_dict.keys(): |
3个元素独立性
1 |
def sort_var_name(_list): |
1 |
for ele in prob_dict.keys(): |
结果
1 |
P(b0,c0|d0) = P(b0|d0)*P(c0|d0) |
\[ \therefore (B \ \bot \ C \ | \ D ), \quad (\ A \ \bot \ D \ | \ B) \]
4个元素独立性
1 |
for ele in prob_dict.keys(): |
结果
1 |
P(b0,c0|a0d0)=P(b0|a0d0)*P(c0|a0d0) |
\[ \therefore \ (A\ \bot\ D \ | \ B,\ C), \quad (B\ \bot\ C \ | \ A,\ D) \]
Writing Enriches Life.