# Show that the moment generating function of $W$ is $M_W(t) = (qe^t+p)^n$

If $Y$ is a random variable with moment-generating function $M_Y(t)$ and if $W$ is given by $W=aY+b$, then the moment generating function of $W$ is $e^{tb}M_Y(at)$

Suppose that $Y$ is a binomial random variable based on $n$ trials with success probability of $p$ and let $W = n - Y$. Show that the moment generating function of $W$ is $M_W(t) = (qe^t+p)^n$ using the fact that $M_W(t) =e^{tb}M_Y(at)$.

If $W$ is a binomial random variable, then the moment generating function in the open form is given by

$$M_W(t) = e^{tb}M_Y(at) = e^{tb}E(e^{atY})$$

$$M_W(t) = e^{tb}\sum\limits_{y=0}^ne^{aty}\binom{n}{y}p^yq^{n-y}.$$

We are provided with the information that $W = n -Y$.

$$M_W(t) = e^{tb}\sum\limits_{n-w=0}^ne^{at(n-w)}\binom{n}{n-w}p^{n-w}q^{w}.$$

I know that we seek to manipulate this summation in such a way that

$$M_W(t) = \sum\limits_{n-w=0}^n\binom{n}{n-w}p^{n-w}(e^tq)^{w}.$$

I have now idea where to begin.

Let $X_i=1$ if we have a success on the $i$-trial, and $0$ otherwise. Then $Y=X_1+\cdots +X_n$, and the $X_i$ are independent.

Each $X_i$ has mgf $pe^t+q$, so their sum $Y$ has mgf $(pe^t+q)^n$.

Now we use the formula we were asked to use. We have $W=aY+b$, where $a=-1$ and $b=n$. Thus $W$ has mgf $e^{tb}(pe^{at}+q)^n$, which is $e^{tn}(pe^{-t}+q)^n$. Finally, $$M_W(t)=e^{tn}(pe^{-t}+q)^n=[e^t(pe^{-t}+q)]^n=(p+qe^t)^n,$$ which is what we were asked to show.

Remark: We found the mgf of $Y$ by using a fact about the mgf of a sum of independent random variables. But we can also find the mgf of $Y$ by aa direct calculation. Note that $$M_Y(t)=\sum_{k=0}^n e^{tk}\binom{n}{k}p^kq^{n-k}.$$ This can be rewritten as $$M_Y(t)=\sum_{k=0}^n \binom{n}{k}(pe^t)^kq^{n-k},$$ and we recognize the sum on the right as the binomial theorem expansion of $(pe^t+q)^n$.