I'm a little bit lost with probability and using Bayes theorem in practise.
Here's and exercise, I'm trying to figure out if I'm going in the right direction and if I read the exercise correctly (if i'm calculating the right thing)
Calculate the probability of a person having a disease D given that they are
showing both symptoms S1 and S2 shown on bayes network
Given values:
P(D) = 0.005
P(S1|D) = 0.4
P(S1|-D) = 0.02
P(S2|D) = 0.5
P(S2|-D) = 0.06
my interpretation of the excercise – P(D|S1,S2)
P(D|S1, S2) =
P(S1,S2|D).P(D)/P(S1,S2) =
Now I'm calculating needed variables
P(-D) = 1-0.005 = 0.995
P(S1) = P(S1|D).P(D) + P(S1|-D).P(-D) = 0.4*0.005+0.02*0.995= 0.02189
P(S2) = P(S2|D).P(D) + P(S2|-D).P(-D) = 0.5*0.005+0.06*0.995=0.0621875
P(S1,S2) = 0.02189 * 0.0621875 = 0.001361284375
P(S1,S2|D) = P(S1|D) * P(S2|D) = 0.4*0.5 = 0.2
and now finally
P(S1,S2|D).P(D)/P(S1,S2) =
0.2*0.005/0.001361284375=
0.7346003659228073
Does any of this make sense?
Best Answer
I think, given that the diagram suggests conditional independence for the symptoms, you have
$$P(S_1,S_2 \mid D) = P(S_1 \mid D) \,P(S_2 \mid D)$$ so $$P(S_1,S_2, D) = P(S_1 \mid D) \,P(S_2 \mid D) \, P(D)$$ and similarly $$P(S_1,S_2, \lnot D) = P(S_1 \mid \lnot D) \,P(S_2 \mid\lnot D) \, P(\lnot D)$$ giving $$P(S_1,S_2) = P(S_1,S_2, D) + P(S_1,S_2, \lnot D)$$ so $$P(D \mid S_1,S_2) = \dfrac{P(S_1,S_2, D)}{P(S_1,S_2)} = \dfrac{P(S_1 \mid D) \,P(S_2 \mid D) \, P(D)}{P(S_1 \mid D) \,P(S_2 \mid D) \, P(D) + P(S_1 \mid \lnot D) \,P(S_2 \mid\lnot D) \, P(\lnot D)}$$