We can rearrange the conditional probability formula to get the so-called product rule:
P(A,B) = P(A|B) P(B)
We can extend this for three variables:
P(A,B,C) = P(A|B,C) P(B,C) = P(A|B,C) P(B|C) P(C)
and in general to n variables:
P(A1, A2, …, An) = P(A1| A2, …, An) P(A2| A3, …, An) P(An-1|An) P(An)
In general we refer to this as the chain rule.
This formula is especially significant for Bayesian networks (BNs). It provides a means of calculating the full joint probability distribution; in BNs many of the variables will be conditionally independent which means that the formula can be simplified as below:
where parents(Ai) denotes the set of parents of node Ai in the BN.