Solution (source code)

= Solution

Write $m_X=\mathbb E X_1$ and $v_X=\operatorname{Var}(X_1)$. For the <random sum of independent claims>, conditioning on $N$ gives
$$
\mathbb E[S\mid N]=Nm_X,\qquad \operatorname{Var}(S\mid N)=Nv_X.
$$
The <law of total expectation> and the <law of total variance> therefore give \b[the aggregate moments]
$$
\boxed{\mathbb ES=(\mathbb EN)m_X,\qquad
\operatorname{Var}(S)=(\mathbb EN)v_X+\operatorname{Var}(N)m_X^2.}
$$
The first term in the <variance> measures variation of the individual claims at a fixed count; the second measures variation of the count itself. These formulas require the indicated moments to be finite.

For the <moment-generating function>, <independent random variables> give
$$
\mathbb E[e^{tS}\mid N]=M_X(t)^N,
\qquad
\boxed{M_S(t)=G_N(M_X(t)),}
$$
where $G_N(z)=\mathbb E[z^N]$ is the <probability generating function>. This identity holds wherever the expectations are finite; in particular a <moment-generating function> need not exist for positive $t$ for an arbitrary positive claim distribution. The empty sum for $N=0$ is zero.