# Understanding numerical example of expectation maximization

I was trying to understand Expectation maximization algorithm. This is how it is defined in Andrew Ng's Stanford CS229 course:

\text{Repeat until convergence \{}\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad \\ \text{(E-step) For each i, set} \quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\\ Q_{i}\left(z^{(i)}\right):=p\left(z^{(i)} \mid x^{(i)} ; \theta\right) \\ \text{(M-step) Set} \quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad \\ \begin{aligned} \theta &:=\arg \max _{\theta} \sum_{i=1}^{n} \operatorname{ELBO}\left(x^{(i)} ; Q_{i}, \theta\right) \\ &=\arg \max _{\theta} \sum_{i} \sum_{z^{(i)}} Q_{i}\left(z^{(i)}\right) \log \frac{p\left(x^{(i)}, z^{(i)} ; \theta\right)}{Q_{i}\left(z^{(i)}\right)} \end{aligned}\\ \}\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad

Then I searched for the example and found this coin flip example. It explains the end part of E-step and M-step as follows:

Though I followed both sources individually, I am unable to see how above calculations for $$\theta_a^1$$ and $$\theta_b^1$$ in M-step map to Andrew's M-step. Are these steps map-able / similarly done in both sources?

PS: I tried mapping various equations in both sources:

• Example's $$E=HTH...HT$$ is Andrew's $$x$$
• $$\theta$$ is coin bias
• Example's $$Z_i$$ is Andrew's $$Z^{(i)}$$ and is event that we chose coin $$i$$
• $$Q$$ is distribution of $$Z$$, that is probabilities with which coins will be chosen
• Example's $$P(E|Z_A)$$ is Andrew's p(x,z;\theta)
• Example's $$P(Z_A|E)$$ is Andrew's $$Q_i(z^{(i)})=p(z^{(i)}|x^{(i)};\theta)$$