this is an homework but i really tried hard before surrender, and i think that or I'm very close to the end or I'm as far as possibile.. That's the text:
Let $X_1, X_2, ..., X_n$ be independent and identically distributed random variables. And N is a nonnegative integer valued random variable (indipendent to any $X_i$).
Let $Z = \Sigma_{i=1}^NX_i$ calculate $Cov(N,Z)$.
What I have done:
I know that $Cov(N,Z) = E[NZ] -E[N]E[Z]$
What i've done is try to get $E[NZ] = E[\Sigma_{i=1}^N X_i N] =$
$= \Sigma_{n=0}^{\infty} E[\Sigma_{i=1}^N X_i N | N=n] P(N=n)$ =
$= \Sigma_{n=0}^{\infty} E[n\Sigma_{i=1}^n X_i]P(N=n) = $
$= \Sigma_{n=0}^{\infty} n E[\Sigma_{i=1}^n X_i]P(N=n) = $
As $X_i$ is iid with any other $X_j$ i use only $X_1$
$=\Sigma_{n=0}^{\infty} nE[\Sigma_{i=1}^n X_1]P(N=n) = $
$=\Sigma_{n=0}^{\infty} n^2 X_1 P(N=n) = X_1\Sigma_{n=0}^{\infty} n^2 P(N=n)$
I know that $\Sigma_{n=0}^{\infty} n P(N=n) = E[N]$ but what about $=\Sigma_{n=0}^{\infty} n^2 P(N=n)$.
Thank you