   bayes nets problem
  Hi,Given tha classical alarm, earthquake, burglary, marycalls and johncalls. earthquake----->Alarm<-------burglaryjohncalls<------Alarm--------->marycallsthe alarm node is duplicated in order to get a proper view.My problem is that i want to calculate P(A|M).I use bayes rule to get ;P(A|M) = P(M|A)*P(A)/P(M). Because i dont know P(A) i get a problem. I dont know p(M), but this i could have avoided if i had known P(A). The first thing on my mind was to calculate P(A) as:sum P(A,M,J,B,E) where i use all the combinations of(negatet or positive) of M,J,B,E.Then i found one solution where P(A) was calculated asp(A) = p(A | ~B, ~E) p(~B, ~E) + p(A | ~B, E) p(~B, E) + p(A | B, ~E) p(B, ~E) + p(A | B, E) p(B, E)My big question is why?It seems like P(A) is calculated as P(A,E,B)+P(A,-B,-E)+P(A,-B,E)+.......just what i would have done except that i belived that i had to use P(J) and P(M) also.How is it that this is true ?Tommy Strømhaug   
  Given the network you should first write down the form of the distribution foreach node (as this will help guide you in your solution).(1) Neither Earthquake (E) nor Burglary (B) have parents, so we require a prior distribution for each: p(E) and p(B).(2) Alarm (A) has two parents, so it must be expressed by the conditional distribution: p(A|E,B).(3) Both JohnCalls (J) and MaryCalls (M) have alarm as a parent, so both must be expressed by conditional distributions: p(J|A) and p(M|A).Now, since A is expressed by a conditional distribution, to obtain the marginal distribution p(A) we need to sum (integrate) over the set of parent variable values, taken in all possible combinations. Hence,p(A) = Σi,jp(A|ei,bj)p(ei,bj)where ei and bj range over the possible values for the variables E and B (in this case, since they are binary, we have e1=true and e2=false and similarly for Burglary).Now, as to why you don't need p(J) and p(M) in this computation. Simply because A does not depend on them. This is evidenced by the direction of the arcs in the graph. They show statistical dependency. That is not to say that you couldn't find a statistically equivalent graph where A depended on one or both of J and M, but simply that in this graph, the dependency is from A to J and A to M. Make sense?If you want to read a very good book that covers this entire topic (and then some), read "Bayesian Artificial Intelligence" by Korb & Nicholson.Cheers,Timkin   ;  Thank you very much for an understandable response.I do know that a bayes net is based on the fact that a node is conditionally independent of its non descendants given its parents. But, marycalls and johncalls are descendants of alarm. Thats what confused me. But again the CPT are only showing probabilities conditionally its parents, so i accept what you say(and believe you). But, could you Timkin please comment my assumption given above?Tommy,;Quote:Original post by stromhauBut, could you Timkin please comment my assumption given above?Which assumption is that? That you could compute p(A) by marginalising the joint probability distribution p(M,J,A,E,B)? If you had this joint, then yes, you could obtain the marginal distribution p(A) from it.If you don't have the joint initially, then as you probably know it can be computed from p(M,J,A,E,B) = p(M|A)p(J|A)p(A|E,B)p(E,B). So, an example entry in the joint would be p(m,j,a,~e,b) = p(m|a)p(j|a)p(a|~e,b)p(~e,b), where m => mary calls is true, b => burglary is true (and so on) and ~e => earthquake is not true. I hope my notation makes sense.Did you try computing the joint in this way and if so, did you get the same answer for p(A) as you did by using the conditional independance?Cheers,Timkin   