# How do you differentiate a function in the em-algorithm?

I am conducting the EM algorithm. I understand the algorithm and my question is more related to the differentiation procedure within the algorithm more than the algorithm itself. Through using the algorithm I have got to this function;

$Q(\pi,\pi^{m}) = (159 - \frac{250}{2+\pi^{m}})log(\pi) + 38log(1-\pi)$

Then for the M-Step in the algorithm;

$\frac{dQ(\pi,\pi^{m})}{d\pi} = 0$

So my lecturer showed me that $\pi^{{m+1}}=(\frac{159\pi^{m}+68}{197\pi^{m}+144})$. Can anyone show me how my lecturer differentiatied $Q(\pi,\pi^{m})$ and rearranged to find $\pi^{m+1} please?$

• Is the $m$ in $\pi^m$ an exponent or an index? Is $\pi^m$ held constant during the differentiation?, your notation suggests that it is. May 16, 2015 at 15:39

Initial differentiation:

$0 = \frac{dQ}{d\pi} = (159 - \frac{250}{2+\pi^m}) (\frac{1}{\pi}) - 38 (\frac{1}{1-\pi})$

Multiplying both sides by $\pi (1 - \pi)$:

$0 = (159 - \frac{250}{2 + \pi^m}) (1 - \pi) - 38 \pi \\ 0 = 159 - 197 \pi - (1 - \pi) (\frac{250}{2 + \pi^m})$

Multiplying both sides by $2 + \pi^m$:

$0 = (159 - 197 \pi) (2 + \pi^m) - 250 + 250 \pi \\ 0 = -\pi (197 \pi^m + 144) + 159 \pi^m + 68$

Moving $\pi$ to the left-hand side:

$\pi (197 \pi^m + 144) = 159 \pi^m + 68 \\ \pi = \frac{159 \pi^m + 68}{197 \pi^m +144}$

Which yields your parameter for the next iteration.