# taken and arranged from CPSBayes