First attempt to port code from MCMC