TITLE: Conditional expectation of conditional expectation
QUESTION [5 upvotes]: I have a question about conditional expectation. I have always problem with that... It is a step of a proof that I just don't get...
I appreciate any help!
I have the random variable $$B=S+ \sum\limits_{j=1}^{Z} B_j.$$
The two terms on the rightside are NOT independent.
Now we condition on $S$: $$M_B(s)=\mathbb{E}[e^{sB}]=\mathbb{E}[\ \mathbb{E}[ \ e^{sB}  \vert S] \ ].$$
Then the next step is to calculate $\mathbb{E}[ \ e^{sB}  \vert S]$. Here comes the problem up. We know that conditional on Z, the $B_i$'s are independent. But then I have conditional expectation of conditional expectation... I dont understand how to compute this. Can anybody help me?
$$\mathbb{E}[ \ e^{sB}  \vert S]=\mathbb{E}[  \mathbb{E}[ \ e^{sB}  \vert S] \vert Z].$$
I mean, in words it is the expected mean value of $e^{sB}$ given $S$ and $Z$.
Can I just do this:
$$\mathbb{E}[ \ e^{sB}  \vert S]=\mathbb{E}[  \mathbb{E}[ \ e^{sB}  \vert S,  Z]] ?$$

REPLY [3 votes]: Yes, you've got the right idea. I'm assuming you intend the $B_i$ to be iid
$$ \begin{aligned}B^*(s) &= \mathbb E[ e^{sB} ]\\
&= \mathbb E[\mathbb E[e^{sB}|S]]\\
&= \mathbb E[\mathbb E[ \mathbb E[e^{s(S+\sum_{j=1}^Z B_j)}|S,Z]|S]]\\
&= \mathbb E[ e^{sS} \mathbb E[ \mathbb E[ e^{sB}|S,Z]^Z|S]]\\
&= \mathbb E[e^{sS}G(B^*(s))]
\end{aligned}$$
where $G$ is the probability generating function of $Z$ given $S$. (Using $S$ for a random variable and $s$ for the dummy variable is a notation choice that might be worth trying to avoid in the future.)
[Edit: corrected typo involving sign]