# Conditional Expectation: How do you get the first line in this solution?

I understand how you get from 1st to 2nd line but i don't get how the two terms are generated in the first line. I looked up Conditional Expectations but i still couldn't make sense of this. Thank you.

provenance...

-
What are the definitions of $A_{0}$ and $S(n)$? –  madprob Feb 14 '13 at 0:45

It seems that the order of the items being equated is not the best for understanding. It might be better to follow as $$\mathrm{E}\{A_0\mid S(n)=1\}=\frac{\mathrm{P}\{A_0=1,S(n)=1\}}{\mathrm{P}\{S(n)=1\}}$$ by the definition of conditional probability. $$\frac{\mathrm{P}\{A_0=1,S(n)=1\}}{\mathrm{P}\{S(n)=1\}}=\frac{\mathrm{E}\{A_0\cdot S(n)\}}{\mathrm{E}\{S(n)\}}$$ which follows if $A_0$ and $S(n)$ are independent and take values in $\{0,1\}$. $$\frac{\mathrm{E}\{A_0\cdot S(n)\}}{\mathrm{E}\{S(n)\}}=\mathrm{E}\{A_0\}+\frac{\mathrm{E}\{A_0\cdot S(n)\}-\mathrm{E}\{A_0\}\cdot\mathrm{E}\{S(n)\}}{\mathrm{E}\{S(n)\}}$$ which is, of course, simply algebra.

If your question was why the items were ordered as they are, I don't know. Perhaps the important equation that will be used later is $$\mathrm{E}\{A_0\mid S(n)=1\}=\mathrm{E}\{A_0\}+\frac{\mathrm{E}\{A_0\cdot S(n)\}-\mathrm{E}\{A_0\}\cdot\mathrm{E}\{S(n)\}}{\mathrm{E}\{S(n)\}}$$ and so they wanted that to appear together.

-
that's what i was asking: why are the items ordered that way. Thank you –  val Feb 15 '13 at 3:06
If $\mathbb P(Y\in\{0,1\})=1$ and $X$ is integrable, then $\mathbb E(X\mid Y=1)=\mathbb E(XY)/\mathbb P(Y=1)$ and $\mathbb P(Y=1)=\mathbb E(Y)$ hence, for every real number $a$, $$\mathbb E(X\mid Y=1)=\frac{\mathbb E(X;Y=1)}{\mathbb P(Y=1)}=\frac{\mathbb E(XY)}{\mathbb E(Y)}=a+\frac{\mathbb E(XY)-a\cdot\mathbb E(Y)}{\mathbb E(Y)}.$$ Apply this to $X=A_0$, $Y=S(n)$, and $a=E(A_0)$.
I really do not know what you are asking... Anyway, you might start by noticing that the RHS of the identity in my answer does not depend on $a$. –  Did Feb 14 '13 at 20:25