Variable elimination is an exact inference technique for
First, we need some elimination ordering
- Min-neighbors orders by fewest dependencies.
- Min-weight orders by minimizing the product of cardinalities of dependencies.
- Min-fill orders by minimizing the size of the next marginalized factor
.
Now, to perform elimination, we perform the following for each variable
- Take the product of all factors
containing . - Marginalize out
to obtain . - Replace factors
with .
Pushing Sums
A more intuitive alternative explanation is that weโre essentially โpushing inโ our summations from the original naive solution. Consider a โ๏ธ Markov Chainโs probability distribution
Our naive calculation is for
However, note that these variables arenโt dependent on most of the summations. For example,
Now, we can calculate the innermost sum,
which we can eliminate again using the same procedure. In this illustration, โpushingโ the summation is equivalent to choosing which factors to multiply and marginalizing over them.
Complexity
In our Markov chain example, if each random variable has
However, not all distributions have such an ideal structure. In most cases, the ordering of our variables significantly affects our runtime: if we combine too many factors and need to marginalize out a big factor, the summation size grows by a factor of
Thus, the complexity of variable elimination ifs