蠏碁1 覦殊 30螳 豐貊貎 10螳螳 れ伎螻, 蠏碁2 覦殊れ 豐貊貎り 螳螳 20螳 れ . 襦 貎るゼ 讌 覦 貎れ. 蠏碁1 螳レ煙?
- P(蠏碁1|覦殊) = P(覦殊|蠏碁1)P(蠏碁1) / P(覦殊) = 0.75 * 0.5 / 0.625 = 0.6
- P(覦殊) = 50/80
- P(蠏碁1) = 40/80
- P(覦殊|蠏碁1) = 30/40
R code
prior <- c(0.5, 0.5)
names(prior) <- c("Bowl1", "Bowl2")
Bowl1 <- c(30, 10)
Bowl2 <- c(20, 20)
names(Bowl1) <- c("B", "C")
names(Bowl2) <- c("B", "C")
Lik <- c(Bowl1["B"]/sum(Bowl1), Bowl2["B"]/sum(Bowl2))
names(Lik) <- c("Bowl1", "Bowl2")
p1 <- (Lik["Bowl1"] * prior["Bowl1"]) / ((Bowl1["B"] + Bowl2["B"]) / sum(Bowl1 + Bowl2))
p2 <- (Lik["Bowl2"] * prior["Bowl2"]) / ((Bowl1["B"] + Bowl2["B"]) / sum(Bowl1 + Bowl2))
posterior <- c(p1, p2)
names(posterior) <- c("Bowl1", "Bowl2")
print(posterior)