begin Bayes functions