# By conditioning on $N$, show that the moment generating function of $Y$ is given by $m_Y(t)=m_N(\ln(m_X(t)))$

I am having a difficult time using moment generating function properties to prove this: (any direction or key properties will be very helpful)

Let $X_1$, $X_2$, . . . be independent and identically distributed random variables, each with the same distribution as the random variable $X$, and let $N$ be a random variable on the nonnegative integers independent of the $X_i$’s. Let $m_X$(t) denote the moment generating function of $X$ and let $m_N$ (t) denote the moment generating function of $N$. Finally, let $Y$ denote the random sum:

$$Y = \begin{cases} 0 &\text{if }N = 0 \\ X_1 + X_2 + ... + X_n &\text{if } N ≥ 1 \end{cases}$$

By conditioning on $N$, show that the moment generating function of $Y$ is given by:

$$m_Y(t) = m_N(\ln(m_X(t)))$$

The mgf of $Y$ conditional on $N=n$ is $$M_{Y|N=n}(t)=M_X(t)^n,$$ since $Y$ is a sum of independent random variables each with mgf $M_X(t)$. Using the law of total expectation and the definition of the mgf, the mgf of the unconditional distribution of $Y$ is $$M_Y(t) = E e^{tY} = E E(e^{tY}|N)=E M_X(t)^N = E e^{N\ln M_X(t)} = M_N(\ln M_X(t)).$$