cpquery
估计event
给定 a的条件概率evidence
。但是,bnlearn
文档指出:
如果 event 或 evidence 设置为 TRUE,则针对该参数执行无条件概率查询。
例如,对于 asia 数据集:
library(bnlearn)
data(asia)
bn.dag <- model2network("[A][S][T|A][L|S][B|S][D|B:E][E|T:L][X|E]")
bn.fitted <- bn.fit(bn.dag, asia)
for (i in c(1:1000)) {
prob[i] <- cpquery(bn.fitted,
event = (A == "no") & (S == "no") & (T == "no") & (L == "no") &
(B == "no") & (E == "no") & (X == "no") & (D == "no"),
evidence = TRUE)
}
summary(prob)
# Result:
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.2714 0.2864 0.2908 0.2909 0.2954 0.3132