Draft implementation of Loopy Belief Propagation (using logarithms to prevent floating underflow)