bayesian updating function