I'm taking a course on machine learning and came across a model answer which I can't wrap my head around.
The whole model answer is the 2nd exercise here: https://noppa.tkk.fi/noppa/kurssi/t-61.3050/viikkoharjoitukset/T-61_3050_proposed_solutions.pdf
The part I'm specifically having trouble understanding is the last 2 lines of the 2nd page, ie this: http://i.stack.imgur.com/SZEPC.png
How does the left side of the upper equation become just the sum of indicator variables? How does the right side simplify to just lambda*p_i?
Any help is appreciated.