(The Variance of a Compound Random Variable) Let X_{1},X_{2},… be independent and identically distributed random variables with distribution F having mean μ and variance σ^{2}, and assume that they are independent of the nonnegative integer valued random variable N. As noted in Example 3.11, where its expected value was determined, the random variable S=\textstyle\sum_{i=1}^{N}X_{i} is called a compound random variable. Find its variance.
Whereas we could obtain E[S^{2}] by conditioning on N, let us instead use the conditional variance formula. Now,
\operatorname{Var}(S|N=n)=\operatorname{Var}\left(\sum_{i=1}^{N}X_{i}|N=n\right)={\mathrm{Var}}\left(\sum_{i=1}^{n}X_{i}|N=n\right)
={\mathrm{Var}}\left(\sum_{i=1}^{n}X_{i}\right)
=n\sigma^{2}
By the same reasoning,
E[S|N = n] = nμ
Therefore,
\operatorname{Var}(S|N)=N\sigma^{2},\quad E[S|N]=N\muand the conditional variance formula gives
\operatorname{Var}(S)=E[N\sigma^{2}]+\operatorname{Var}(N\mu)=\sigma^{2}E[N]+\mu^{2}\operatorname{Var}(N)If N is a Poisson random variable, then S=\textstyle\sum_{i=1}^{N}X_{i} is called a compound Poisson random variable. Because the variance of a Poisson random variable is equal to its mean, it follows that for a compound Poisson random variable having E[N] = λ
\mathrm{Var}(S)=\lambda\sigma^{2}+\lambda\mu^{2}=\lambda E[X^{2}]where X has the distribution F.