Bayesian inference as iterated random functions with applications to sequential inference in graphical models