Solution (source code)

= Solution

The observed-data <likelihood function> integrates out the <latent variable>:
$$
L(x\mid\theta)=\int f(x,z;\theta)\,dz.
$$
Choose an initial parameter $\theta^{(0)}$ with positive <likelihood>. At iteration $t$, the E-step of the <EM algorithm> forms the entire expected complete-data <log-likelihood>
$$
Q(\theta\mid\theta^{(t)})=\int h_t(z)\log f(x,z;\theta)\,dz,\qquad h_t(z)=\frac{f(x,z;\theta^{(t)})}{L(x\mid\theta^{(t)})}.
$$
The expectation is under the conditional missing-data law at the old parameter, while the argument $\theta$ remains free. The M-step then chooses
$$
\boxed{\theta^{(t+1)}\in\operatorname*{arg\,max}_{\theta}Q(\theta\mid\theta^{(t)}).}
$$
The observed data $x$ stay fixed throughout. This is not obtained merely by substituting the conditional mean of $z$ into a nonlinear <log-likelihood>: the expectation of all required complete-data terms must be taken. A generalized EM step only requires $Q(\theta^{(t+1)}\mid\theta^{(t)})\ge Q(\theta^{(t)}\mid\theta^{(t)})$, which suffices for the monotonicity proved next. Exact maximization assumes that an admissible maximizer exists.