Specifying the Non-Decoder/Encoder Parameters of the Model
How to get the conditional probability values ?
DAG using bnlearn
library(bnlearn)
## Create the dag
game_net <- model2network("[AC][RC][AT|AC][RT|RC][AS|AT:AC][AD|AT:AC][AA|AT:AC][RS|RT:RC][RD|RT:RC][RA|RT:RC][AACT|AS:AD:AA][RRCT|RS:RD:RA:AACT]")
# Character Nodes (Actor and Reactor)
cptAC = matrix(c(0.5, 0.5), ncol = 2, dimnames = list(NULL, c("Satyr", "Golem")))
cptRC = matrix(c(0.5, 0.5), ncol = 2, dimnames = list(NULL, c("Satyr", "Golem")))
# Type nodes conditioned on Character (Actor and Reactor)
cptAT = c(0.33, 0.34, 0.33, 0.33, 0.34, 0.33)
dim(cptAT) <- c(3,2)
dimnames(cptAT) <- list("AT"=c("Type1", "Type2", "Type3"), "AC" = c("Satyr", "Golem"))
cptRT = c(0.33, 0.34, 0.33, 0.33, 0.34, 0.33)
dim(cptRT) <- c(3,2)
dimnames(cptRT) <- list("RT"=c("Type1", "Type2", "Type3"), "RC" = c("Satyr", "Golem"))
# Attack, strength and defense conditioned on Type and Character (Actor and Reactor)
cptAA <- c(0.2, 0.8, 0.6, 0.4, 0.8, 0.2, 0.75, 0.25, 0.4, 0.6, 0.9, 0.1)
dim(cptAA) <- c(2,3,2)
dimnames(cptAA) <- list("AA"= c("LOW", "HIGH"), "AT"= c("Type1", "Type2", "Type3"), "AC"= c("Satyr", "Golem"))
cptAD <- c(0.9, 0.1, 0.3, 0.7, 0.6, 0.4, 0.5, 0.5, 0.4, 0.6, 0.6, 0.4)
dim(cptAD) <- c(2,3,2)
dimnames(cptAD) <- list("AD"= c("LOW", "HIGH"), "AT"= c("Type1", "Type2", "Type3"), "AC"= c("Satyr", "Golem"))
cptAS <- c(0.4, 0.6, 0.2, 0.8, 0.5, 0.5, 0.6, 0.4, 0.5, 0.5, 0.8, 0.2)
dim(cptAS) <- c(2,3,2)
dimnames(cptAS) <- list("AS"= c("LOW", "HIGH"), "AT"= c("Type1", "Type2", "Type3"), "AC"= c("Satyr", "Golem"))
cptRA <- c(0.2, 0.8, 0.6, 0.4, 0.8, 0.2, 0.75, 0.25, 0.4, 0.6, 0.9, 0.1)
dim(cptRA) <- c(2,3,2)
dimnames(cptRA) <- list("RA"= c("LOW", "HIGH"), "RT"= c("Type1", "Type2", "Type3"), "RC"= c("Satyr", "Golem"))
cptRD <- c(0.9, 0.1, 0.3, 0.7, 0.6, 0.4, 0.5, 0.5, 0.4, 0.6, 0.6, 0.4)
dim(cptRD) <- c(2,3,2)
dimnames(cptRD) <- list("RD"= c("LOW", "HIGH"), "RT"= c("Type1", "Type2", "Type3"), "RC"= c("Satyr", "Golem"))
cptRS <- c(0.4, 0.6, 0.2, 0.8, 0.5, 0.5, 0.6, 0.4, 0.5, 0.5, 0.8, 0.2)
dim(cptRS) <- c(2,3,2)
dimnames(cptRS) <- list("RS"= c("LOW", "HIGH"), "RT"= c("Type1", "Type2", "Type3"), "RC"=c("Satyr", "Golem"))
# Action conditioned on Actor Strength, Attack and defense
cptAACT <- c(0.1, 0.3, 0.6, 0.3, 0.5, 0.2, 0.3, 0.3, 0.4, 0.5,0.4,0.1,0.1, 0.2, 0.7, 0.4,0.3,0.3, 0.2, 0.4, 0.4, 0.6, 0.3, 0.1)
dim(cptAACT)<- c(3,2,2,2)
dimnames(cptAACT)<- list("AACT"= c("Attack", "Taunt", "Walk"), "AA"= c("LOW", "HIGH"), "AD"= c("LOW", "HIGH"), "AS"= c("LOW", "HIGH"))
cptRRCT <- c(0.5, 0.4, 0.05, 0.05, 0.2, 0.6, 0.1, 0.1, 0.001, 0.001, 0.997, 0.001,0.4, 0.3,0.1, 0.2, 0.1, 0.5, 0.2, 0.2, 0.001, 0.001, 0.99, 0.008,0.1, 0.3, 0.55, 0.05, 0.1, 0.2, 0.65, 0.05, 0.001, 0.001, 0.997, 0.001, 0.3, 0.2, 0.3, 0.2,0.1, 0.3, 0.4, 0.2,0.001, 0.001, 0.99, 0.008,0.3, 0.3, 0.399, 0.001,0.2, 0.4, 0.399, 0.001,0.001, 0.001, 0.997, 0.001, 0.3, 0.4, 0.1, 0.2,0.3, 0.3, 0.1, 0.3,0.001, 0.001, 0.99, 0.008, 0.2, 0.3, 0.49, 0.01,0.2, 0.2, 0.59, 0.01,0.001, 0.001, 0.997, 0.001, 0.2, 0.2, 0.4, 0.2,0.1, 0.1, 0.4, 0.4,0.001, 0.001, 0.99, 0.008)
dim(cptRRCT)<- c(4,2,2,2,3)
dimnames(cptRRCT)<- list("RRCT"=c("Dying", "Hurt", "Idle", "Attack"), "RA"= c("LOW", "HIGH"), "RD"= c("LOW", "HIGH"), "RS"= c("LOW", "HIGH"), "AACT"= c("Attack", "Taunt", "Walk"))
dfit <- custom.fit(game_net, dist = list(AC = cptAC, RC=cptRC, AT= cptAT, RT=cptRT, AA=cptAA, AD=cptAD, AS=cptAS, RA=cptRA, RS=cptRS, RD=cptRD, AACT=cptAACT, RRCT=cptRRCT))Conditional probability queries using gRain
Last updated