# How do you calculate unconditional probabilities in a Bayes Network?

For instance, given the alarm example, how would you compute P(alarm), not given anything? What about P(JohnCalls)? I also don't really understand how you would compute a parent given a child -- how would you compute P(Earthquake | alarm), etc?

In principle, you can compute the joint probability distribution of all events from the network structure and the tables. Then each individual probability is a suitable sum.

Of course, in some cases this is not necessary, e.g. P(Burglary) is already given.

And to compute P(Alarm) in this way, you would only need the joint distribution of Burglary, Earthquake and Alarm. E.g. $$P(A, \,\neg E, \, B) = P(A|B,\neg E) \cdot P(B,\neg E) = P(A|B,\neg E)P(B)P(\neg E) = .01\cdot.995 \cdot .95 \, .$$ This can be done for the other three cases as well, namely $P(A, \, E, \, B), \, P(A, \,E, \, \neg B), \, P(A, \,\neg E, \,\neg B)$. Then sum these four probabilities. This is essentially the same as the Law of Total Probability (see the answer by Graham Kemp).

To get something like P(E|A), use the definition $P(E|A) = P(A, \, E)/P(A)$ and compute the terms in this formula from the joint distribution as before.

This will always work, bu it will quickly become infeasible if the network has 20 or more nodes. Thus part of the computational challenge is to find shortcuts.

A student who starts learning about Bayes networks and is looking for these shortcuts right away will always be confused.

By the Law of Total Probability:

\begin{align}\mathsf P(A)&={\mathsf P(A\mid B,E)\mathsf P(B)\mathsf P(E)+\mathsf P(A\mid B,\neg E)\mathsf P(B)\mathsf P(\neg E)+\mathsf P(A\mid \neg B,E)\mathsf P(\neg B)\mathsf P(E)+\mathsf P(A\mid \neg B,\neg E)\mathsf P(\neg B)\mathsf P(\neg E)}\\&={0.97\cdotp 0.01\cdotp 0.005+0.95\cdotp 0.01\cdotp 0.995+0.23\cdotp 0.99\cdotp 0.005+0.001\cdotp 0.99\cdotp 0.995}\end{align}

Then use that to evaluate:

$$\mathsf P(J)={\mathsf P(J\mid A)\mathsf P(A)+\mathsf P(J\mid \neg A)\mathsf P(\neg A)}$$

And by Bayes': $$\mathsf P(E\mid A)=\dfrac{\big(\mathsf P(A\mid B,E)\mathsf P(B)+\mathsf P(A\mid \neg B,E)\mathsf P(\neg B)\big)~\mathsf P(E)}{\mathsf P(A)}$$