made the m file for the EM algorithm