= Solution
For the <binomial distribution>, the <binomial theorem> gives
$$
G_X(s)=\sum_{k=0}^n\binom nkp^k(1-p)^{n-k}s^k=(1-p+ps)^n.
$$
Differentiation of the <probability generating function> recovers the first <expected value> and second <factorial moment>:
$$
G_X'(1)=np,\qquad G_X''(1)=n(n-1)p^2=\mathbb E[X(X-1)].
$$
Since $X^2=X(X-1)+X$, the <variance> is
$$
G_X''(1)+G_X'(1)-G_X'(1)^2=n(n-1)p^2+np-n^2p^2=np(1-p).
$$
Thus
$$
\boxed{G_X(s)=(1-p+ps)^n,\qquad\mathbb E[X]=np,\qquad\operatorname{var}(X)=np(1-p).}
$$
The formulas also hold for $n=0,1$ and the degenerate choices $p=0,1$, with derivatives read directly from the resulting <polynomial>.
Back to article page