corrected a small mistake in the algorithm and some mistakes in the examples
Update functions for EM