Generating Functions

The moment-generating function of a random variable is an alternative specification of its probability distribution. Thus, it provides the basis of an alternative route to analytical results compared with working directly with probability density functions or cumulative distribution functions. There are particularly simple results for the moment-generating functions of distributions defined by the weighted sums of random variables. Note, however, that not all random variables have moment-generating functions.

In addition to univariate distributions, moment-generating functions can be defined for vector- or matrix-valued random variables, and can even be extended to more general cases.

The moment-generating function does not always exist even for real-valued arguments, unlike the characteristic function. There are relations between the behavior of the moment-generating function of a distribution and properties of the distribution, such as the existence of moments.

The probability generating function of a discrete random variable is a power series representation (the generating function) of the probability mass functionof the random variable. Probability generating functions are often employed for their succinct description of the sequence of probabilities [math]\operatorname{P}(X=i)[/math] in the probability mass function for a random variable [math]X[/math], and to make available the well-developed theory of power series with non-negative coefficients.

The Moment Generating Function


In probability theory and statistics, the moment-generating function of a random variable [math]X[/math] is

[[math]] M_X(t) := \operatorname{E}\!\left[e^{tX}\right], \quad t \in \mathbb{R}, [[/math]]

wherever this expectation exists. In other terms, the moment-generating function can be interpreted as the expectation of the random variable [math] e^{tX}[/math].

A key problem with moment-generating functions is that moments and the moment-generating function may not exist, as the integrals need not converge absolutely. By contrast, the characteristic function always exists and thus may be used instead.

The reason for defining this function is that it can be used to find all the moments of the distribution.[1] The series expansion of [math]e^{tX}[/math] is:

[[math]] e^{t\,X} = 1 + t\,X + \frac{t^2\,X^2}{2!} + \cdots +\frac{t^n\,X^n}{n!} + \cdots. [[/math]]


[[math]] \begin{align*} M_X(t) = \operatorname{E}\left[e^{t\,X}\right] = \sum_{n=0}^\infty \frac{\operatorname{E}[X^n]}{n!} = \sum_{n=0}^\infty \frac{t^nm_n}{n!} \end{align*} [[/math]]

where [math]m_n[/math] is the [math]n[/math]th moment. Differentiating [math]M_X(t)[/math] [math]i[/math] times with respect to [math]t[/math] and setting [math]t=0[/math] we obtain the [math]i[/math]th moment about the origin, [math]m_i[/math], see Calculations of moments below.


The moment-generating function is the expectation of a function of the random variable, it can be written as:

Case Calculation
General [math]M_X(t) = \int_{-\infty}^\infty e^{tx}\,dF(x)[/math], using the Riemann–Stieltjes integral, and where [math]F[/math] is the cumulative distribution function
Discrete probability mass function [math]M_X(t)=\sum_{i=1}^\infty e^{tx_i}\, p_i[/math]
Continuous probability density function [math] M_X(t) = \int_{-\infty}^\infty e^{tx} f(x)\,dx [/math]

Sum of independent random variables

If [math]S_n = \sum_{i=1}^{n} a_i X_i[/math], where the [math]X_i[/math] are independent random variables and the [math]a_i[/math] are constants, then the probability density function for [math]S_n[/math] is the convolution of the probability density functions of each of the [math]X_i[/math], and the moment-generating function for [math]S_n[/math] is given by

[[math]] M_{S_n}(t)=M_{X_1}(a_1t)M_{X_2}(a_2t)\cdots M_{X_n}(a_nt) \, . [[/math]]

Calculations of moments

The moment-generating function is so called because if it exists on an open interval around [math]t=0[/math] then it is the exponential generating function of the moments of the probability distribution:

[[math]]m_n = E \left( X^n \right) = M_X^{(n)}(0) = \frac{d^n M_X}{dt^n}(0).[[/math]]

Here [math]n[/math] must be a nonnegative integer.

Relation to other functions

Related to the moment-generating function are a number of other transforms that are common in probability theory:

Function Description
Characteristic function The characteristic function [math]\varphi_X(t)[/math] is related to the moment-generating function via [math]\varphi_X(t) = M_{iX}(t) = M_X(it):[/math] the characteristic function is the moment-generating function of iX or the moment generating function of [math]X[/math] evaluated on the imaginary axis. This function can also be viewed as the Fourier transform of the probability density function, which can therefore be deduced from it by inverse Fourier transform.
Cumulant-generating function The cumulant-generating function is defined as the logarithm of the moment-generating function; some instead define the cumulant-generating function as the logarithm of the characteristic function, while others call this latter the second cumulant-generating function.
Probability generating functions The probability-generating function is defined as [math]G(z) = E[z^X].\,[/math] This immediately implies that [math]G(e^t) = E[e^{tX}] = M_X(t).\,[/math]


Here are some examples of the moment generating function and the characteristic function for comparison. It can be seen that the characteristic function is a Wick rotation of the moment generating function Mx(t) when the latter exists.

Distribution Moment-generating function M[math]X[/math]([math]t[/math]) Characteristic function φ(t)
Bernoulli [math]\, \operatorname{P}(X=1)=p[/math]   [math]\, 1-p+pe^t[/math]   [math]\, 1-p+pe^{it}[/math]
Geometric [math](1 - p)^{k-1}\,p\![/math]   [math]\frac{p e^t}{1-(1-p) e^t}\![/math]
 [math]\forall t\lt-\ln(1-p)\![/math]
  [math]\frac{p e^{it}}{1-(1-p)\,e^{it}}\![/math]
Binomial [math]B(n, p)[/math]   [math]\, (1-p+pe^t)^n[/math]   [math]\, (1-p+pe^{it})^n[/math]
Poisson Pois([math]λ[/math])   [math]\, e^{\lambda(e^t-1)}[/math]   [math]\, e^{\lambda(e^{it}-1)}[/math]
Uniform (continuous) [math]U(a, b)[/math]   [math]\, \frac{e^{tb} - e^{ta}}{t(b-a)}[/math]   [math]\, \frac{e^{itb} - e^{ita}}{it(b-a)}[/math]
Uniform (discrete) [math]U(a, b)[/math]   [math]\, \frac{e^{at} - e^{(b+1)t}}{(b-a+1)(1-e^{t})}[/math]   [math]\, \frac{e^{ait} - e^{(b+1)it}}{(b-a+1)(1-e^{it})}[/math]
Normal [math]N(\mu, \sigma^2)[/math]   [math]\, e^{t\mu + \frac{1}{2}\sigma^2t^2}[/math]   [math]\, e^{it\mu - \frac{1}{2}\sigma^2t^2}[/math]
Chi-squared [math]\chi^2_k[/math]   [math]\, (1 - 2t)^{-k/2}[/math]   [math]\, (1 - 2it)^{-k/2}[/math]
Gamma [math]\Gamma(k, \theta)[/math]   [math]\, (1 - t\theta)^{-k}[/math]   [math]\, (1 - it\theta)^{-k}[/math]
Exponential Exp([math]λ[/math])   [math]\, (1-t\lambda^{-1})^{-1}, \, (t\lt\lambda) [/math]   [math]\, (1 - it\lambda^{-1})^{-1}[/math]
Multivariate normal [math]N(\mu, \Sigma)[/math]   [math]\, e^{t^\mathrm{T} \mu + \frac{1}{2} t^\mathrm{T} \Sigma t}[/math]   [math]\, e^{i t^\mathrm{T} \mu - \frac{1}{2} t^\mathrm{T} \Sigma t}[/math]
Degenerate δa   [math]\, e^{ta}[/math]   [math]\, e^{ita}[/math]
Laplace [math]L(μ, b)[/math]   [math]\, \frac{e^{t\mu}}{1 - b^2t^2}[/math]   [math]\, \frac{e^{it\mu}}{1 + b^2t^2}[/math]
Negative Binomial [math]NB(r, p)[/math]   [math]\, \frac{(1-p)^r}{(1-pe^t)^r}[/math]   [math]\, \frac{(1-p)^r}{(1-pe^{it})^r}[/math]
Cauchy Cauchy([math]μ, θ[/math]) does not exist   [math]\, e^{it\mu -\theta|t|}[/math]

The Probability Generating Function


If [math]X[/math] is a discrete random variable taking values in the non-negative integers {0,1, ...}, then the probability generating function of [math]X[/math] is defined as [2]

[[math]]G(z) = \operatorname{E} (z^X) = \sum_{x=0}^{\infty}p(x)z^x,[[/math]]

where [math]p[/math] is the probability mass function of [math]X[/math]. Note that the subscripted notations [math]G_X[/math] and [math]p_X[/math] are often used to emphasize that these pertain to a particular random variable [math]X[/math], and to its distribution. The power series converges absolutely at least for all complex numbers [math]z \leq 1[/math]; in many examples the radius of convergence is larger.


Power series

Probability generating functions obey all the rules of power series with non-negative coefficients. In particular, [math]G(1^{-})=1[/math], where

[[math]] \lim_{z \uparrow 1} G(z) = G(z^{-}) [[/math]]

, since the probabilities must sum to one. So the radius of convergence of any probability generating function must be at least 1, by Abel's theorem for power series with non-negative coefficients.

Probabilities and expectations

The following properties allow the derivation of various basic quantities related to [math]X[/math]:

1. The probability mass function of [math]X[/math] is recovered by taking derivatives of [math]G[/math]:

[[math]] p(k) = \operatorname{P}(X = k) = \frac{G^{(k)}(0)}{k!}.[[/math]]

2. It follows from Property 1 that if [math]X[/math] and [math]Y[/math] have identical probability generating functions, then they have identical distributions.

3. The normalization of the probability density function can be expressed in terms of the generating function by

[[math]]\operatorname{E}(1)=G(1^-)=\sum_{i=0}^\infty f(i)=1.[[/math]]

The expectation of [math]X[/math] is given by

[[math]] \operatorname{E}\left(X\right) = G'(1^-).[[/math]]

More generally, the [math]k[/math]th factorial moment, [math]\textrm{E}(X(X - 1) \cdots (X - k + 1))[/math] of [math]X[/math] is given by

[[math]]\textrm{E}\left(\frac{X!}{(X-k)!}\right) = G^{(k)}(1^-), \quad k \geq 0.[[/math]]

So the variance of [math]X[/math] is given by

[[math]]\operatorname{Var}(X)=G''(1^-) + G'(1^-) - \left [G'(1^-)\right ]^2.[[/math]]

4. [math]G_X(e^{t}) = M_X(t)[/math] where [math]X[/math] is a random variable, [math]G_X(t)[/math] is the probability generating function (of [math]X[/math]) and [math]M_X(t)[/math] is the moment generating function (of [math]X[/math]) .

Functions of independent random variables

Probability generating functions are particularly useful for dealing with functions of independent random variables. For example:

  • If [math]X_1, X_2, \ldots, X_n[/math] is a sequence of independent (and not necessarily identically distributed) random variables, and

[[math]]S_n = \sum_{i=1}^n a_i X_i,[[/math]]

where the [math]a_i[/math] are constants, then the probability generating function is given by

[[math]] G_{S_n}(z) = \operatorname{E}(z^{S_n}) = \operatorname{E}(z^{\sum_{i=1}^n a_i X_i,}) = G_{X_1}(z^{a_1})G_{X_2}(z^{a_2})\cdots G_{X_n}(z^{a_n}). [[/math]]

For example, if [math]S_n = \sum_{i=1}^n X_i,[/math] then the probability generating function, GSn(z), is given by

[[math]]G_{S_n}(z) = G_{X_1}(z)G_{X_2}(z)\cdots G_{X_n}(z).[[/math]]

It also follows that the probability generating function of the difference of two independent random variables [math]S[/math] = [math]X[/math]1[math]X[/math]2 is

[[math]]G_S(z) = G_{X_1}(z)G_{X_2}(1/z).[[/math]]

  • Suppose that [math]n[/math] is also an independent, discrete random variable taking values on the non-negative integers, with probability generating function [math]G_n[/math]. If the [math]X_1,X_2, \ldots, X_N[/math] are independent and identically distributed with common probability generating function [math]G_X[/math], then [math]G_{S_N}(z) = G_N(G_X(z)).[/math] This can be seen, using the law of total expectation, as follows:

[[math]] \begin{align*} G_{S_N}(z) = \operatorname{E}(z^{S_N})&= \operatorname{E}(z^{\sum_{i=1}^N X_i}) \\ &= \operatorname{E}\big(\operatorname{E}(z^{\sum_{i=1}^N X_i}| N) \big) \\ &= \operatorname{E}\big( (G_X(z))^N\big) =G_N(G_X(z)). \end{align*} [[/math]]

This last fact is useful in the study of Galton–Watson processes.

  • Suppose again that [math]N[/math] is also an independent, discrete random variable taking values on the non-negative integers, with probability generating function [math]G_N[/math] and probability density [math]f_i = \operatorname{P}(N = i)[/math]. If the [math]X_1, \ldots, X_N [/math] are independent, but not identically distributed random variables, where [math]G_{X_i}[/math] denotes the probability generating function of [math]X_i[/math], then

[[math]]G_{S_N}(z) = \sum_{i \ge 1} f_i \prod_{k=1}^i G_{X_i}(z).[[/math]]

For identically distributed [math]X_i[/math] this simplifies to the identity stated before. The general case is sometimes useful to obtain a decomposition of [math]S_N[/math] by means of generating functions.


The table below gives the probability generating function for some well known discrete distributions.

Distribution PGF
Degenerate [math]\delta_a[/math] [math]G(z) = \left(z^a\right)[/math]
Bernoulli [math]\, \operatorname{P}(X=1)=p[/math] [math]G(z) = 1/2 + z/2 [/math]
Binomial [math]\operatorname{B}(n, p)[/math] [math]G(z) = \left[(1-p) + pz\right]^n [/math]
Negative Binomial [math]\operatorname{NB}(r,p)[/math] [math]G(z) = \left(\frac{pz}{1 - (1-p)z}\right)^r[/math]
Poisson [math]\textrm{Pois}(\lambda) [/math] [math]G(z) = \textrm{e}^{\lambda(z - 1)}[/math]


  1. Bulmer, M.G., Principles of Statistics, Dover, 1979, pp. 75–79


  • Casella, George; Berger, Roger. Statistical Inference (2nd ed.). pp. 59–68. ISBN 978-0-534-24312-8.
  • Grimmett, Geoffrey; Welsh, Dominic. Probability - An Introduction (1st ed.). pp. 101 ff. ISBN 978-0-19-853264-4.
  • Wikipedia contributors. "Moment-generating function". Wikipedia. Wikipedia. Retrieved 28 January 2022.
  • Wikipedia contributors. "Probability-generating function". Wikipedia. Wikipedia. Retrieved 28 January 2022.