Q:

Bayesian networks problem

Attempting to understand Exercise 20 (pdf page 44) in this book: 

The party animal problem corresponds to the network in g(3.14). The boss is angry and the worker has a headache - what is the probability  the worker has been to a party? All variables are binary and 
$p(U =tr|P =tr,D=tr)=0.999$, $p(U =tr|P =fa,D=tr)=0.9$, $p(U =tr|P =tr,D=fa)=0.9$, $p(U =tr|P =fa,D=fa)=0.01$. 
$\begin{matrix} & & D \\ & & \downarrow \\ P & \rightarrow & U \\ \downarrow & & \downarrow \\ (H) & & (A)\end{matrix} $

I'm unsure of how to solve this problem given only the above information, and help greatly appreciated. Can this even be solved with the information given in the question?

A:

First up, you're referring to an old edition of the book, where this exercise is incomplete. Here's the latest edition, where the same exercise specifies all necessary probabilities (p.57, ex. 3.1):

$p(U = tr|P = tr, D = tr) = 0.999$  
$p(U = tr|P = fa, D = tr) = 0.9$ 
$p(U = tr|P = tr, D = fa) = 0.9$  
$p(U = tr|P = fa, D = fa) = 0.01$ 
$p(H = tr|P = tr) = 0.9$ 
$p(H = tr|P = fa) = 0.2$ 
$p(A = tr|U = tr) = 0.95$  
$p(A = tr|U = fa) = 0.5$  
$p(P = tr) = 0.2$ 
$p(D = tr) = 0.4$

As you can see, the edges $P \rightarrow U$ and $D \rightarrow U$ aren't defined explicitly, so the step one is compute them using the Law of total probability (I use $!X$ notation to denote $X = false$):
$$p(U | P) = p(U | P, D)p(D) + p(U | P, !D)p(!D) = 0.999\cdot0.4 + 0.9\cdot0.6 = 0.9396$$
$$p(U | !P) = p(U | !P, D)p(D) + p(U | !P, !D)p(!D) = 0.9\cdot0.4 + 0.01\cdot0.6 = 0.366$$
and similarly
$$p(U | D) = 0.9198$$
$$p(U | !D) = 0.188$$
At this point, you can forget the first four given equations, because you have all probabilities of all edges in the network, and can compute any joint or conditional probability.
Step two: the end goal is to compute
$$p(P | H, A) = \frac{p(P, H, A)}{p(H, A)}$$
This is where things get a bit hairy, because $p(P, H, A)$ is a sum of four terms (marginilize over $D$ and $U$):
$$p(P, H, A) = p(P, H, A, D, U)p(D, U) + ... + p(P, H, A, !D, !U)p(!D, !U)$$
...and $p(H, A)$ is sum of eight terms (marginilizing over $D$, $U$ and $P$). I'll just show how to compute any of these terms and leave the rest to you as an arithmetic exercise.
The joint probability over Bayesian (sub-)network can be computed using Bayesian rule, e.g. 
$$p(P, H, A, D, U) = p(H|P)p(A|U)p(U|P)p(U|D) = 0.9\cdot0.95\cdot0.9396\cdot0.9198 = 0.7389286884$$
$$p(D,U) = p(U|D)p(D) = 0.9198\cdot0.4 = 0.36792$$
$$p(!D,!U) = p(!U|!D)p(!D) = (1 - p(U|!D))p(!D) = (1 - 0.188)\cdot0.6 = 0.4872$$
And so on until you have $p(P, H, A)$ and $p(H, A)$, which will give you $p(P|H,A)$.

