这个题目有两种解法,一种是通过采样来估计,另一种是理论求解。这里,我通过将贝叶斯网络转化为一个无向图,深度优先搜索(DFS)得到所有潜在的从X集到Y集的路径,然后观察Z集中的元素。通过检查每一条路径是否在观测Z集的情况下activated,可以得出条件独立性的最终判断。
2. Apply DFS algorithm to find all paths from X to Y.
3. Save the current traversed path when algorithm meet Y.
Block Y in case of going trough Y
Stop current finding and keep going to the next node.
4. For each path, check their Activation, default True, which equal to the conditionally independence of X⊥Y|Z
* (in 4.2)If the path is X-Y without any other node (len = 2), then False.
4.1 Pick out the first two nodes, with a dummy node in front (trick).
4.2 Pick out the next node in path and release the oldest node which picked.
If there is no next node, then set path to False.
(We check the path node by node, checking 3 of them each time.)
4.2.1 When tail-to-tail (A <- B -> C)
4.2.1.1 If B ∈ Z, then the path is BLOCKED, X⊥Y|Z is ture. True, Continue to next path. go 4
4.2.1.2 If B ∉ Z, then continue to next group of node. go 4.2
4.2.2 When head-to-tail (A -> B -> C)
4.2.2.1 If B ∈ Z, then the path is BLOCKED, X⊥Y|Z is ture. True, Continue to next path. go 4
4.2.2.2 If B ∉ Z, then continue to next group of node. go 4.2
4.2.3 When head-to-tail (A -> B -> C)
4.2.3.1 If B ∈ Z, then the path is BLOCKED, X⊥Y|Z is ture. True, Continue to next path. go 4
4.2.3.2 If B ∉ Z, then continue to next group of node. go 4.2
4.2.4 When head-to-head (A -> B <- C)
4.2.4.1 If B ∈ Z, then continue to next group of node. go 4.2
4.2.4.2 If B ∉ Z, for all node S of B.succeed
4.2.4.2.1 If there is no S ∈ Z, True, continue to next path. go 4
4.2.4.2.2 If there exist S ∈ Z, continue to next group of node. go 4.2
* If S ∈ Z continue to next group of node
* If S ∉ Z continue to next succeed node. go 4.2.3.1
5. If all path is True, then the conditionally independence of X⊥Y|Z is True.