[Math] Expectation and Variance of Conditional Sum (using formal definition of conditional expectation)

conditional probabilityprobabilityprobability theory

Given a finite set of i.i.d random variables $X_i, 1 \le i \le N$, and a positive-integer valued random variable $N$, find the expectation and variance of the new random variable defined as:

$Z = \sum\limits_{i=1}^N X_i$

Now, I know how to do this with the "intuitive" understanding of expectation and variance, simply by using the "double expectation" formula, conditioning on N and then replacing N with a fixed n, and then going from there. However, the question is asking us to do this with the formal definition of conditional expectation (i.e by conditioning on the sigma algebra generated by $N$, for example). I am not sure how to properly justify replacing N with a fixed n and then using normal expectation rules though. Can anyone help?

Edit: Sorry I forgot the assumption that all the variables in the question are independent and that the Xi are i.i.d.

Best Answer

Maybe I'm not as pedagogic as Stefan, since I'll just post the answer straight forward. If there's anything you need clarified, please let me know.

For the sake of clarity, I will denote $Z = Z_N = \sum\limits_{i=1}^N X_i$. Thus $Z_n$ is just the sum of the $X_i$'s, $i=1,..,n$ where $n$ is a real number.

$$E[Z_N]= \sum\limits_{n=0}^{\infty} E[Z_n |N=n] \cdot P(N=n)\\=\sum\limits_{n=0}^{\infty} E[Z_n] \cdot P(N=n)\\=\sum\limits_{n=0}^{\infty} nE[X_i] \cdot P(N=n)\\ E[X_i]\sum\limits_{n=0}^{\infty} n \cdot P(N=n)\\=E[X_i]\cdot E[N]$$

I guess it's necessary to assume (or show) that the expected value of N is actually finite.

This can also be quite easily shown using the probability generating function.

The variance can be computed using a the law total of variance (sometimes called Decomposition), instead of the total law of expectation.

The law of total variance gives the following: for the random variables $X$ and $Y$, $$Var(X) = E[Var(X|Y)] + Var(E[X|Y])$$

For $X=Z_N$ and $Y=N$ we obtain the following,

$$Var(Z_N) = E[Var(Z_N|N)]+Var(E[Z_N|N])$$

After some computations (I'll leave that for you), similarly to when the expectation was calculated, it can be shown that $E[Var(Z_N|N)]=E[N]\cdot Var(X)$.

Knowing that $E[Z_N|N=n]=nE[X]$, it follows that $$Var(E[Z_N|N])=Var(N \cdot E[X]) = E[X]^2 \cdot Var(N)$$

Finally we get that $$Var(Z_N) = E[N]\cdot Var(X)+E[X]^2 \cdot Var(N)$$

Related Question