Added EM algorithm for maximising the posterior