the first optimization problem can be solved explicitly namelyby ( )we have that (targmin (pg(tth( - ) (tth( - that isthe optimal density is the conditional density of the latent variables given the data and the parameter th( - the second optimization problem can be simplified by writing ( (tthq( (the (tln ( ( )where ( (th: (tln (tz this the expected complete-data log-likelihood under (tconsequentlythe maximization of ( (tthwith respect to th is equivalent to finding th(targmax ( (ththth this leads to the following generic em algorithm algorithm generic em algorithm inputdata tinitial guess th( outputapproximation of the maximum likelihood estimate while stopping criterion is not met do expectation stepfind ( ( : ( tth( - and compute the expectation ( (th: (tln (tz th ( maximization steplet th(targmaxthth ( (tht - + return th(ta possible stopping criterion is to stop when ln ( th(tln ( th( - ln ( th(tfor some small tolerance remark (properties of the em algorithmthe identity ( can be used to show that the likelihood ( th(tdoes not decrease with every iteration of the algorithm this property is one of the strengths of the algorithm for exampleit can be used to debug computer implementations of the em algorithmif the likelihood is observed to decrease at any iterationthen one has detected bug in the program the convergence of the sequence {th(tto global maximum (if it existsis highly dependent on the initial value th( andin many casesan appropriate choice of th( may not be clear typicallypractitioners run the algorithm from different random starting points over thto ascertain empirically that suitable optimum is achieved