# Finding the Moment Generating function of a Binomial Distribution

Suppose $X$ has a $Binomial(n,p)$ distribution. Then its moment generating function is

$$M(t) = \sum_{x=0}^x {n \choose x}p^x(1-p)^{n-x} \\ =\sum_{x=0}^{n} {n \choose x}(pe^t)^x(1-p)^{n-x}\\ =(pe^t+1-p)^n$$

Can someone please explain how the sum is obtained from lines (2) to (3)?

-
This is the Binomial formula. –  Stefan Hansen Nov 13 '12 at 19:53
It makes sense to me that the Binomial Theorem would be applied to this, I'm just having a hard time working out how they get to the final result using it :\ –  TopGunCpp Nov 13 '12 at 21:02
It all makes sense now, it "is" a syntactically simplified way to write the Binomial Theorem. Thanks for the clarification –  TopGunCpp Nov 13 '12 at 21:07
Call $l=pe^t$ and $j=1-p$, then the second line is $\sum_{x=0}^n {n \choose x} l^x j^{n-x} = (l+j)^n$ by the binomial formula. –  Stefan Hansen Nov 13 '12 at 21:07
this video explains how to find the mgf of a binomial distribution: youtube.com/watch?v=XEm3lzquu5c –  Alejandra Oct 27 '13 at 2:04