Modified exact inference engine that decomposes the summation over the hidden variables