# How to calculate joint probabilities from conditional probabilities in a Bayesian Network?

This question is about Bayesian Networks. I want to calculate the probability for certain events to be in a certain state knowing all conditional probabilities.

Consider that I am totally new to Bayesian Networks.

# The problem

Consider a Bayesian Network. For all variables $A_i,B_i \dots Z_i$ in the network I know the potentials in the form $P\{ A_i | par(A_i) \}=P\{A_i | B_1 \dots B_n\}$ for all possible states $a_i,b_1 \dots b_n$. These potentials are calculated using subjective probabilities.

# Calculating single probabilities

What I know are just potentials. For example, for variable $A_i$ I do not know $P\{A_i = a_i\}$ but I know $P\{A_i = a_i | B_1=b_1 \dots B_n=b_n\}$. Where $B_1, B_2 \dots B_n$ are parents of $A_i$.

I want to calculate $P\{A_i = a_i\}$. Consider that No restrictions are considered so this variable $A_i$ can have parents and children. As well as $B_1 \dots B_n$.

It does not seem too complicated. Having potentials I can use the total probability law and:

$$P\{ A_i = a_i \} = \sum_{\forall b_1 \dots b_n} P\{ A_i = a_i | B_1=b_1 \dots B_n=b_n \} \cdot P\{B_1=b_1 \dots B_n=b_n \}$$

In the sum, the first part: $P\{ A_i = a_i | B_1=b_1 \dots B_n=b_n \}$ can be calculated using potentials.

What about $P\{B_1=b_1 \dots B_n=b_n \}$. That is, How can I calculate the probability that some variables have some state contemporarly? Please note that $B_1 \dots B_n$ are not one parent of the other, they are on the same level of the network, they are peers, meaning they have no parent relationship. They are parents of $A_i$.

# The question

Generally speaking, how to calculate the probability that some variables are in some state contemporarly? When they have no parent relationships? Preconditions are: I know the conditional probabilites (potentials).

Do $A_i$ have no children? Do $B$ have no parents?
In general, you can't know $P(B_i)$ without also evaluating $P(A_i)$ because diagnostic evidence from below $A$ can affect $A$, which affects $B$.
I think the efficient solution is to calculate lambda and pi messages, which are the predictive and diagnostic evidence from the parent and child nodes of $A$.