Let SN=X1+X2+⋯+XN, where the Xi's are independent random variables with common distribution having generating function f(z). Assume that N is an integer valued random variable independent of all of the Xj and having generating function g(z). Show that the generating function for SN is h(z)=g(f(z)). Hint: Use the fact that
h(z)=E(zSN)=k∑E(zSN∣N=k)P(N=k).