code from John K Kruschke's Doing Bayesian Data Analysis