# 10.3: Generating Functions for Continuous Densities

- Page ID
- 3170

In the previous section, we introduced the concepts of moments and moment generating functions for discrete random variables. These concepts have natural analogues for continuous random variables, provided some care is taken in arguments involving convergence.

## Moments

If \(X\) is a continuous random variable defined on the probability space \(\Omega\), with density function \(f_X\), then we define the \(n\)th moment of \(X\) by the formula

\[\mu_n = E(X^n) = \int_{-\infty}^{+\infty} x^n f_X(x)\, dx\ ,\]

provided the integral

\[\mu_n = E(X^n) = \int_{-\infty}^{+\infty} |x|^n f_X(x)\, dx\ ,\]

is finite. Then, just as in the discrete case, we see that \(\mu_0 = 1\), \(\mu_1 = \mu\), and \(\mu_2 - \mu_1^2 = \sigma^2\).

## Moment Generating Functions

Now we define the \(g(t)\) for \(X\) by the formula

\[\begin{aligned} g(t) &=& \sum_{k = 0}^\infty \frac{\mu_k t^k}{k!} = \sum_{k = 0}^\infty \frac{E(X^k) t^k}{k!} \\ &=& E(e^{tX}) = \int_{-\infty}^{+\infty} e^{tx} f_X(x)\, dx\ ,\end{aligned}\]

provided this series converges. Then, as before, we have

\[\mu_n = g^{(n)}(0)\ .\]

## Examples

Let \(X\) be a continuous random variable with range \([0,1]\) and density function \(f_X(x) = 1\) for \(0 \leq x \leq 1\) (uniform density). Then

\[\mu_n = \int_0^1 x^n\, dx = \frac1{n + 1}\ ,\]

and

\[\begin{aligned} g(t) &=& \sum_{k = 0}^\infty \frac{t^k}{(k+1)!}\\ &=& \frac{e^t - 1}t\ .\end{aligned}\]

Here the series converges for all \(t\). Alternatively, we have

\[\begin{aligned} g(t) &=& \int_{-\infty}^{+\infty} e^{tx} f_X(x)\, dx \\ &=& \int_0^1 e^{tx}\, dx = \frac{e^t - 1}t\ .\end{aligned}\]

Then (by L’Hôpital’s rule)

\[\begin{aligned} \mu_0 &=& g(0) = \lim_{t \to 0} \frac{e^t - 1}t = 1\ , \\ \mu_1 &=& g'(0) = \lim_{t \to 0} \frac{te^t - e^t + 1}{t^2} = \frac12\ , \\ \mu_2 &=& g''(0) = \lim_{t \to 0} \frac{t^3e^t - 2t^2e^t + 2te^t - 2t}{t^4} = \frac13\ .\end{aligned}\]

In particular, we verify that \(\mu = g'(0) = 1/2\) and

\[\sigma^2 = g''(0) - (g'(0))^2 = \frac13 - \frac14 = \frac1{12}\]

as before (see Example 6.1.5]).

Let \(X\) have range \([\,0,\infty)\) and density function \(f_X(x) = \lambda e^{-\lambda x}\) (exponential density with parameter \(\lambda\)). In this case

\[\begin{aligned} \mu_n &=& \int_0^\infty x^n \lambda e^{-\lambda x}\, dx = \lambda(-1)^n \frac{d^n}{d\lambda^n} \int_0^\infty e^{-\lambda x}\, dx \\ &=& \lambda(-1)^n \frac{d^n}{d\lambda^n} [\frac1\lambda] = \frac{n!} {\lambda^n}\ ,\end{aligned}\]

and

\[\begin{aligned} g(t) &=& \sum_{k = 0}^\infty \frac{\mu_k t^k}{k!} \\ &=& \sum_{k = 0}^\infty [\frac t\lambda]^k = \frac\lambda{\lambda - t}\ .\end{aligned}\]

Here the series converges only for \(|t| < \lambda\). Alternatively, we have

\[\begin{aligned} g(t) &=& \int_0^\infty e^{tx} \lambda e^{-\lambda x}\, dx \\ &=& \left.\frac{\lambda e^{(t - \lambda)x}}{t - \lambda}\right|_0^\infty = \frac\lambda{\lambda - t}\ .\end{aligned}\]

Now we can verify directly that \[\mu_n = g^{(n)}(0) = \left.\frac{\lambda n!}{(\lambda - t)^{n + 1}}\right|_{t = 0} = \frac{n!}{\lambda^n}\ .\]

Let \(X\) have range \((-\infty,+\infty)\) and density function

\[f_X(x) = \frac1{\sqrt{2\pi}} e^{-x^2/2}\] (normal density).

In this case we have

\[\begin{aligned} \mu_n &=& \frac1{\sqrt{2\pi}} \int_{-\infty}^{+\infty} x^n e^{-x^2/2}\, dx \\ &=& \left \{ \begin{array}{ll} \frac{(2m)!}{2^{m} m!}, & \mbox{if $ n = 2m$,}\cr 0, & \mbox{if $ n = 2m+1$.}\end{array}\right.\end{aligned}\]

(These moments are calculated by integrating once by parts to show that \(\mu_n = (n - 1)\mu_{n - 2}\), and observing that \(\mu_0 = 1\) and \(\mu_1 = 0\).) Hence,

\[\begin{aligned} g(t) &=& \sum_{n = 0}^\infty \frac{\mu_n t^n}{n!} \\ &=& \sum_{m = 0}^\infty \frac{t^{2m}}{2^{m} m!} = e^{t^2/2}\ .\end{aligned}\] This series converges for all values of \(t\). Again we can verify that \(g^{(n)}(0) = \mu_n\).

Let \(X\) be a normal random variable with parameters \(\mu\) and \(\sigma\). It is easy to show that the moment generating function of \(X\) is given by \[e^{t\mu + (\sigma^2/2)t^2}\ .\] Now suppose that \(X\) and \(Y\) are two independent normal random variables with parameters \(\mu_1\), \(\sigma_1\), and \(\mu_2\), \(\sigma_2\), respectively. Then, the product of the moment generating functions of \(X\) and \(Y\) is

\[e^{t(\mu_1 + \mu_2) + ((\sigma_1^2 + \sigma_2^2)/2)t^2}\ .\]

This is the moment generating function for a normal random variable with mean \(\mu_1 + \mu_2\) and variance \(\sigma_1^2 + \sigma_2^2\). Thus, the sum of two independent normal random variables is again normal. (This was proved for the special case that both summands are standard normal in Example 7.1.5.)

In general, the series defining \(g(t)\) will not converge for all \(t\). But in the important special case where \(X\) is bounded (i.e., where the range of \(X\) is contained in a finite interval), we can show that the series does converge for all \(t\).

Suppose \(X\) is a continuous random variable with range contained in the interval \([-M,M]\). Then the series

\[g(t) = \sum_{k = 0}^\infty \frac{\mu_k t^k}{k!}\]

converges for all \(t\) to an infinitely differentiable function \(g(t)\), and \(g^{(n)}(0) = \mu_n\).

**Proof**. We have

\[\mu_k = \int_{-M}^{+M} x^k f_X(x)\, dx\ ,\] so \[\begin{aligned} |\mu_k| &\leq& \int_{-M}^{+M} |x|^k f_X(x)\, dx \\ &\leq& M^k \int_{-M}^{+M} f_X(x)\, dx = M^k\ .\end{aligned}\]

Hence, for all \(N\) we have

\[\sum_{k = 0}^N \left|\frac{\mu_k t^k}{k!}\right| \leq \sum_{k = 0}^N \frac{(M|t|)^k}{k!} \leq e^{M|t|}\ ,\]

which shows that the power series converges for all \(t\). We know that the sum of a convergent power series is always differentiable.

## Moment Problem

*If \(X\) is a bounded random variable, then the moment generating function \(g_X(t)\) of \(x\) determines the density function \(f_X(x)\) uniquely.*

* Sketch of the Proof.* We know that

\[\begin{aligned} g_X(t) &=& \sum_{k = 0}^\infty \frac{\mu_k t^k}{k!} \\ &=& \int_{-\infty}^{+\infty} e^{tx} f(x)\, dx\ .\end{aligned}\]

If we replace \(t\) by \(i\tau\), where \(\tau\) is real and \(i = \sqrt{-1}\), then the series converges for all \(\tau\), and we can define the function

\[k_X(\tau) = g_X(i\tau) = \int_{-\infty}^{+\infty} e^{i\tau x} f_X(x)\, dx\ .\]

The function \(k_X(\tau)\) is called the of \(X\), and is defined by the above equation even when the series for \(g_X\) does not converge. This equation says that \(k_X\) is the of \(f_X\). It is known that the Fourier transform has an inverse, given by the formula

\[f_X(x) = \frac1{2\pi} \int_{-\infty}^{+\infty} e^{-i\tau x} k_X(\tau)\, d\tau\ ,\]

suitably interpreted.^{9} Here we see that the characteristic function \(k_X\), and hence the moment generating function \(g_X\), determines the density function \(f_X\) uniquely under our hypotheses.

## Sketch of the Proof of the Central Limit Theorem

With the above result in mind, we can now sketch a proof of the Central Limit Theorem for bounded continuous random variables (see Theorem 9.4.7). To this end, let \(X\) be a continuous random variable with density function \(f_X\), mean \(\mu = 0\) and variance \(\sigma^2 = 1\), and moment generating function \(g(t)\) defined by its series for all \(t\). Let \(X_1\), \(X_2\), …, \(X_n\) be an independent trials process with each \(X_i\) having density \(f_X\), and let \(S_n = X_1 + X_2 +\cdots+ X_n\), and \(S_n^* = (S_n - n\mu)/\sqrt{n\sigma^2} = S_n/\sqrt n\). Then each \(X_i\) has moment generating function \(g(t)\), and since the \(X_i\) are independent, the sum \(S_n\), just as in the discrete case (see Section 10.1), has moment generating function

\[g_n(t) = (g(t))^n\ ,\]

and the standardized sum \(S_n^*\) has moment generating function

\[g_n^*(t) = \left(g\left(\frac t{\sqrt n}\right)\right)^n\ .\]

We now show that, as \(n \to \infty\), \(g_n^*(t) \to e^{t^2/2}\), where \(e^{t^2/2}\) is the moment generating function of the normal density \(n(x) = (1/\sqrt{2\pi}) e^{-x^2/2}\) (see Example \(\PageIndex{3}\)]).

To show this, we set \(u(t) = \log g(t)\), and

\[\begin{aligned} u_n^*(t) &=& \log g_n^*(t) \\ &=& n\log g\left(\frac t{\sqrt n}\right) = nu\left(\frac t{\sqrt n}\right)\ ,\end{aligned}\]

and show that \(u_n^*(t) \to t^2/2\) as \(n \to \infty\). First we note that

\[\begin{aligned} u(0) &=& \log g_n(0) = 0\ , \\ u'(0) &=& \frac{g'(0)}{g(0)} = \frac{\mu_1}1 = 0\ , \\ u''(0) &=& \frac{g''(0)g(0) - (g'(0))^2}{(g(0))^2} \\ &=& \frac{\mu_2 - \mu_1^2}1 = \sigma^2 = 1\ .\end{aligned}\]

Now by using L’Hôpital’s rule twice, we get

\[\begin{aligned} \lim_{n \to \infty} u_n^*(t) &=& \lim_{s \to \infty} \frac{u(t/\sqrt s)}{s^{-1}}\\ &=& \lim_{s \to \infty} \frac{u'(t/\sqrt s) t}{2s^{-1/2}} \\ &=& \lim_{s \to \infty} u''\left(\frac t{\sqrt s}\right) \frac{t^2}2 = \sigma^2 \frac{t^2}2 = \frac{t^2}2\ .\end{aligned}\]

Hence, \(g_n^*(t) \to e^{t^2/2}\) as \(n \to \infty\). Now to complete the proof of the Central Limit Theorem, we must show that if \(g_n^*(t) \to e^{t^2/2}\), then under our hypotheses the distribution functions \(F_n^*(x)\) of the \(S_n^*\) must converge to the distribution function \(F_N^*(x)\) of the normal variable \(N\); that is, that

\[F_n^*(a) = P(S_n^* \leq a) \to \frac1{\sqrt{2\pi}} \int_{-\infty}^a e^{-x^2/2}\, dx\ ,\]

and furthermore, that the density functions \(f_n^*(x)\) of the \(S_n^*\) must converge to the density function for \(N\); that is, that

\[f_n^*(x) \to \frac1{\sqrt{2\pi}} e^{-x^2/2}\ ,\] as \(n \rightarrow \infty\).

Since the densities, and hence the distributions, of the \(S_n^*\) are uniquely determined by their moment generating functions under our hypotheses, these conclusions are certainly plausible, but their proofs involve a detailed examination of characteristic functions and Fourier transforms, and we shall not attempt them here.

In the same way, we can prove the Central Limit Theorem for bounded discrete random variables with integer values (see Theorem 9.3.6). Let \(X\) be a discrete random variable with density function \(p(j)\), mean \(\mu = 0\), variance \(\sigma^2 = 1\), and moment generating function \(g(t)\), and let \(X_1\), \(X_2\), …, \(X_n\) form an independent trials process with common density \(p\). Let \(S_n = X_1 + X_2 +\cdots+ X_n\) and \(S_n^* = S_n/\sqrt n\), with densities \(p_n\) and \(p_n^*\), and moment generating functions \(g_n(t)\) and \(g_n^*(t) = \left(g(\frac t{\sqrt n})\right)^n.\) Then we have

\[g_n^*(t) \to e^{t^2/2}\ ,\]

just as in the continuous case, and this implies in the same way that the distribution functions \(F_n^*(x)\) converge to the normal distribution; that is, that

\[F_n^*(a) = P(S_n^* \leq a) \to \frac1{\sqrt{2\pi}} \int_{-\infty}^a e^{-x^2/2}\, dx\ ,\] as \(n \rightarrow \infty\).

The corresponding statement about the distribution functions \(p_n^*\), however, requires a little extra care (see Theorem 9.3.5). The trouble arises because the distribution \(p(x)\) is not defined for all \(x\), but only for integer \(x\). It follows that the distribution \(p_n^*(x)\) is defined only for \(x\) of the form \(j/\sqrt n\), and these values change as \(n\) changes.

We can fix this, however, by introducing the function \(\bar p(x)\), defined by the formula

\[\bar p(x) = \left \{ \begin{array}{ll} p(j), & \mbox{if $j - 1/2 \leq x < j + 1/2$,} \cr 0\ , & \mbox{otherwise}.\end{array}\right.\]

Then \(\bar p(x)\) is defined for all \(x\), \(\bar p(j) = p(j)\), and the graph of \(\bar p(x)\) is the step function for the distribution \(p(j)\) (see Figure 3 of Section 9.1).

In the same way we introduce the step function \(\bar p_n(x)\) and \(\bar p_n^*(x)\) associated with the distributions \(p_n\) and \(p_n^*\), and their moment generating functions \(\bar g_n(t)\) and \(\bar g_n^*(t)\). If we can show that \(\bar g_n^*(t) \to e^{t^2/2}\), then we can conclude that

\[\bar p_n^*(x) \to \frac1{\sqrt{2\pi}} e^{t^2/2}\ ,\]

as \(n \rightarrow \infty\), for all \(x\), a conclusion strongly suggested by Figure 9.1.2.

Now \(\bar g(t)\) is given by

\[\begin{aligned} \bar g(t) &=& \int_{-\infty}^{+\infty} e^{tx} \bar p(x)\, dx \\ &=& \sum_{j = -N}^{+N} \int_{j - 1/2}^{j + 1/2} e^{tx} p(j)\, dx\\ &=& \sum_{j = -N}^{+N} p(j) e^{tj} \frac{e^{t/2} - e^{-t/2}} {2t/2} \\ &=& g(t) \frac{\sinh(t/2)}{t/2}\ ,\end{aligned}\]

where we have put \[\sinh(t/2) = \frac{e^{t/2} - e^{-t/2}}2\ .\]

In the same way, we find that

\[\begin{aligned} \bar g_n(t) &=& g_n(t) \frac{\sinh(t/2)}{t/2}\ , \\ \bar g_n^*(t) &=& g_n^*(t) \frac{\sinh(t/2\sqrt n)}{t/2\sqrt n}\ .\end{aligned}\]

Now, as \(n \to \infty\), we know that \(g_n^*(t) \to e^{t^2/2}\), and, by L’Hôpital’s rule,

\[\lim_{n \to \infty} \frac{\sinh(t/2\sqrt n)}{t/2\sqrt n} = 1\ .\]

It follows that \[\bar g_n^*(t) \to e^{t^2/2}\ ,\] and hence that

\[\bar p_n^*(x) \to \frac1{\sqrt{2\pi}} e^{-x^2/2}\ ,\] as \(n \rightarrow \infty\).

The astute reader will note that in this sketch of the proof of Theorem [thm 9.3.5], we never made use of the hypothesis that the greatest common divisor of the differences of all the values that the \(X_i\) can take on is 1. This is a technical point that we choose to ignore. A complete proof may be found in Gnedenko and Kolmogorov.^{10}

## Cauchy Density

The characteristic function of a continuous density is a useful tool even in cases when the moment series does not converge, or even in cases when the moments themselves are not finite. As an example, consider the Cauchy density with parameter \(a = 1\) (see Example 5.20)

\[f(x) = \frac1{\pi(1 + x^2)}\ .\]

If \(X\) and \(Y\) are independent random variables with Cauchy density \(f(x)\), then the average \(Z = (X + Y)/2\) also has Cauchy density \(f(x)\), that is,

\[f_Z(x) = f(x)\ .\]

This is hard to check directly, but easy to check by using characteristic functions. Note first that

\[\mu_2 = E(X^2) = \int_{-\infty}^{+\infty} \frac{x^2}{\pi(1 + x^2)}\, dx = \infty\]

so that \(\mu_2\) is infinite. Nevertheless, we can define the characteristic function \(k_X(\tau)\) of \(x\) by the formula

\[k_X(\tau) = \int_{-\infty}^{+\infty} e^{i\tau x}\frac1{\pi(1 + x^2)}\, dx\ .\]

This integral is easy to do by contour methods, and gives us

\[k_X(\tau) = k_Y(\tau) = e^{-|\tau|}\ .\] Hence, \[k_{X + Y}(\tau) = (e^{-|\tau|})^2 = e^{-2|\tau|}\ ,\]

and since

\[k_Z(\tau) = k_{X + Y}(\tau/2)\ ,\]

we have

\[k_Z(\tau) = e^{-2|\tau/2|} = e^{-|\tau|}\ .\]

This shows that \(k_Z = k_X = k_Y\), and leads to the conclusions that \(f_Z = f_X = f_Y\).

It follows from this that if \(X_1\), \(X_2\), …, \(X_n\) is an independent trials process with common Cauchy density, and if

\[A_n = \frac{X_1 + X_2 + \cdots+ X_n}n\]

is the average of the \(X_i\), then \(A_n\) has the same density as do the \(X_i\). This means that the Law of Large Numbers fails for this process; the distribution of the average \(A_n\) is exactly the same as for the individual terms. Our proof of the Law of Large Numbers fails in this case because the variance of \(X_i\) is not finite.

Exercises

### Exercise \(\PageIndex{1}\)

Let \(X\) be a continuous random variable with values in \([\,0,2]\) and density \(f_X\). Find the moment generating function \(g(t)\) for \(X\) if

- \(f_X(x) = 1/2\).
- \(f_X(x) = (1/2)x\).
- \(f_X(x) = 1 - (1/2)x\).
- \(f_X(x) = |1 - x|\).
- \(f_X(x) = (3/8)x^2\).

: Use the integral definition, as in Examples [exam 10.3.1] and [exam 10.3.2].

### Exercise \(\PageIndex{2}\)

For each of the densities in Exercise [exer 10.3.1] calculate the first and second moments, \(\mu_1\) and \(\mu_2\), directly from their definition and verify that \(g(0) = 1\), \(g'(0) = \mu_1\), and \(g''(0) = \mu_2\).

### Exercise \(\PageIndex{3}\)

Let \(X\) be a continuous random variable with values in \([\,0,\infty)\) and density \(f_X\). Find the moment generating functions for \(X\) if

- \(f_X(x) = 2e^{-2x}\).
- \(f_X(x) = e^{-2x} + (1/2)e^{-x}\).
- \(f_X(x) = 4xe^{-2x}\).
- \(f_X(x) = \lambda(\lambda x)^{n - 1} e^{-\lambda x}/(n - 1)!\).

### Exercise \(\PageIndex{4}\)

For each of the densities in Exercise [exer 10.3.3], calculate the first and second moments, \(\mu_1\) and \(\mu_2\), directly from their definition and verify that \(g(0) = 1\), \(g'(0) = \mu_1\), and \(g''(0) = \mu_2\).

### Exercise \(\PageIndex{5}\)

Find the characteristic function \(k_X(\tau)\) for each of the random variables \(X\) of Exercise [exer 10.3.1].

### Exercise \(\PageIndex{6}\)

Let \(X\) be a continuous random variable whose characteristic function \(k_X(\tau)\) is \[k_X(\tau) = e^{-|\tau|}, \qquad -\infty < \tau < +\infty\ .\] Show directly that the density \(f_X\) of \(X\) is \[f_X(x) = \frac1{\pi(1 + x^2)}\ .\]

### Exercise \(\PageIndex{7}\)

Let \(X\) be a continuous random variable with values in \([\,0,1]\), uniform density function \(f_X(x) \equiv 1\) and moment generating function \(g(t) = (e^t - 1)/t\). Find in terms of \(g(t)\) the moment generating function for

- \(-X\).
- \(1 + X\).
- \(3X\).
- \(aX + b\).

### Exercise \(\PageIndex{8}\)

Let \(X_1\), \(X_2\), …, \(X_n\) be an independent trials process with uniform density. Find the moment generating function for

- \(X_1\).
- \(S_2 = X_1 + X_2\).
- \(S_n = X_1 + X_2 +\cdots+ X_n\).
- \(A_n = S_n/n\).
- \(S_n^* = (S_n - n\mu)/\sqrt{n\sigma^2}\).

### Exercise \(\PageIndex{9}\)

Let \(X_1\), \(X_2\), …, \(X_n\) be an independent trials process with normal density of mean 1 and variance 2. Find the moment generating function for

- \(X_1\).
- \(S_2 = X_1 + X_2\).
- \(S_n = X_1 + X_2 +\cdots+ X_n\).
- \(A_n = S_n/n\).
- \(S_n^* = (S_n - n\mu)/\sqrt{n\sigma^2}\).

### Exercise \(\PageIndex{10}\)

Let \(X_1\), \(X_2\), …, \(X_n\) be an independent trials process with density \[f(x) = \frac12 e^{-|x|}, \qquad -\infty < x < +\infty\ .\]

- Find the mean and variance of \(f(x)\).
- Find the moment generating function for \(X_1\), \(S_n\), \(A_n\), and \(S_n^*\).
- What can you say about the moment generating function of \(S_n^*\) as \(n \to \infty\)?
- What can you say about the moment generating function of \(A_n\) as \(n \to \infty\)?