Code for hierarchical Dirichlet model (MacKay and Peto)