Module contents
Lesson 13 of 24Core 90 min

Generating functions, cumulants and the characteristic function

Sums of independent variables are convolutions; transforms turn them into products. Study probability, moment and cumulant generating functions, including the convexity behind Chernoff bounds, and the characteristic function, which always exists, determines the law and proves the central limit theorem.

After this lesson you can

  • Calculate PGFs, MGFs, cumulants and characteristic functions for the catalogued distributions.
  • Find laws of independent and random sums using products of transforms.
  • Prove convexity of the cumulant generating function and relate its derivatives to mean and variance.
  • State uniqueness and inversion for characteristic functions and apply inversion numerically using FFT.
  • Explain when an MGF does not exist and when moments do not determine the law.

Before you start

Motivation: turning convolutions into products

Adding independent random variables is the most frequent operation in applied probability: the total error of an ensemble, the aggregate loss of a portfolio, the tokens spent in a multi-turn conversation, or the noise accumulated step by step by a diffusion model (each step of the forward process adds an independent Gaussian to the image). It is also an awkward operation. The law of S=X1+X2S = X_1 + X_2 is not obtained pointwise: it is a convolution,

P(S=s)=∑kP(X1=k)P(X2=s−k),fS(s)=∫f1(x) f2(s−x) ⁣dx,\Pr(S = s) = \sum_k \Pr(X_1 = k)\Pr(X_2 = s - k), \qquad f_S(s) = \int f_1(x)\,f_2(s - x)\dd x,

and with nn summands it must be repeated n−1n - 1 times. The probability that ten dice sum to 3535 comes from nine chained convolutions (it is 0.07270.0727, which we will calculate in two ways). If nn is a parameter, random, or enormous, what you want is a formula rather than an algorithm.

You already know a school-level trick. When two polynomials are multiplied, their coefficients are convolved. If GA(s)=∑kpkskG_A(s) = \sum_k p_k s^k is the polynomial whose coefficients are the probabilities of AA, and GBG_B the one for BB, then the coefficient of sms^m in GA(s) GB(s)G_A(s)\,G_B(s) is ∑kpkqm−k\sum_k p_k q_{m-k}, exactly P(A+B=m)\Pr(A + B = m) when AA and BB are independent. The law of a sum is a product of polynomials. Evaluating the polynomial at s=eits = e^{it} keeps the product valid, and each G(eit)G(e^{it}) is a complex number: multiplying complex numbers multiplies their moduli and adds their angles. The figure makes this visible. Edit the two laws and check that the product of the blue and aqua curves is, for each tt, the magenta curve of the sum.

InteractiveConvolution on the left, product on the right
Law: convolution
0.1000.4010.3020.1030.1045A
0.5000.101230.1040.305B
0.0500.2110.1920.0830.0740.0850.1560.1070.0480.03910A + B = A ∗ B
Transform: product, with t∈[0,2π]t \in [0, 2\pi]
ReIm
  • φA(t)\varphi_A(t)
  • φB(t)\varphi_B(t)
  • φA+B\varphi_{A+B} (from the sum pmf); arrow: φAφB\varphi_A\varphi_B
Examples
1.20
∣φA∣ ∣φB∣\abs{\varphi_A}\,\abs{\varphi_B} = ∣φA+B∣\abs{\varphi_{A+B}}0.435 × 0.838 = 0.365
arg⁡φA+arg⁡φB\arg\varphi_A + \arg\varphi_B97.5° + −6.2° ≡ 91.4°
maximum ∣φA+B−φAφB∣\abs{\varphi_{A+B} - \varphi_A\varphi_B} on [0,2π][0, 2\pi]6.8e−16
E\E of A, B and A + B1.70 + 2.00 = 3.70
Var⁡\Var of A, B and A + B1.21 + 5.20 = 6.41
A and B are laws on {0,…,5}\{0, \dots, 5\} that can be edited by dragging the bars (remaining or missing mass is distributed among the others). Below is the law of A+BA + B, calculated by convolution. On the right, for t∈[0,2π]t \in [0, 2\pi], are the curves φA(t)=∑kpkeitk\varphi_A(t) = \sum_k p_k e^{itk} and φB(t)\varphi_B(t) in the complex plane, and the curve of φA+B\varphi_{A+B}, calculated only from the pmf of the sum. The arrows show the three values at the selected tt: the magenta arrow is the product of the other two, with modulus ∣φA∣∣φB∣\abs{\varphi_A}\abs{\varphi_B} and angle arg⁡φA+arg⁡φB\arg\varphi_A + \arg\varphi_B. The error readout compares φA+B\varphi_{A+B}, calculated from the sum's pmf, with φAφB\varphi_A\varphi_B at 49 values of tt: what remains is floating-point rounding. With “Atom + law”, multiplication by φ=e3it\varphi = e^{3it} rotates the curve.

This lesson turns the trick into a theory. There are four transforms of a law, each with its own strength, and all four send convolution to multiplication:

TransformDefinitionApplies toUse
Probability generatingG(s)=E[sX]G(s) = \E[s^X]X∈{0,1,2,… }X \in \{0, 1, 2, \dots\}counting: random sums, branching
Moment generatingM(λ)=E[eλX]M(\lambda) = \E[e^{\lambda X}]light tailsmoments by differentiation, exponential tilting
Cumulant generatingψ(λ)=log⁡M(λ)\psi(\lambda) = \log M(\lambda)sameadditivity, convexity, Chernoff bounds
Characteristicφ(t)=E[eitX]\varphi(t) = \E[e^{itX}]every random variableuniqueness, inversion, central limit theorem

The first three occur throughout applied probability: ψ\psi is the log-partition function of an exponential family and a tool for Chernoff bounds and large deviations; φ\varphi is used to prove the central limit theorem, and in stable laws and Fourier option pricing. We proceed in increasing order of generality: from the most algebraic to the one that never fails. The last section shows what none of the four guarantees: that moments determine the law.

Probability generating function

For XX taking values in {0,1,2,… }\{0, 1, 2, \dots\}, the series ∑kpksk\sum_k p_k s^k with pk=P(X=k)p_k = \Pr(X = k) is a power series whose coefficients sum to 11, and its value at ss is the expectation of sXs^X (which exists without assumptions on XX, since ∣sX∣≤1\abs{s^X} \le 1 when ∣s∣≤1\abs{s} \le 1).

It converges absolutely for ∣s∣≤1\abs{s} \le 1 because ∑kpk=1\sum_k p_k = 1, so its radius of convergence is at least 11.

Proof

(1) follows from ∑pk=1\sum p_k = 1 and uniform convergence on [0,1][0, 1] of a power series with nonnegative coefficients. (2) A power series with positive radius of convergence can be differentiated term by term, and its coefficients are its derivatives at 00 divided by k!k! (the Taylor polynomial of a power series is the series itself). (3) For s∈[0,1)s \in [0, 1), G(r)(s)=∑k≥rk(k−1)⋯(k−r+1) pk sk−rG^{(r)}(s) = \sum_{k \ge r} k(k-1)\cdots(k-r+1)\,p_k\,s^{k-r}, with all terms nonnegative and increasing in ss; by monotone convergence, the limit as s↑1s \uparrow 1 is ∑kk(k−1)⋯(k−r+1) pk\sum_k k(k-1)\cdots(k-r+1)\,p_k. Taking r=2r = 2 and E[X2]=G′′(1)+G′(1)\E[X^2] = G''(1) + G'(1) gives the variance. (4) If X⊥ ⁣ ⁣ ⁣⊥YX \indep Y, then sX⊥ ⁣ ⁣ ⁣⊥sYs^X \indep s^Y for each fixed ss (measurable functions of independent variables), and the expectation of a product of independent variables is the product of their expectations: E[sX+Y]=E[sX] E[sY]\E[s^{X+Y}] = \E[s^X]\,\E[s^Y].

∎

Uniqueness is proved here in one line using the coefficients of a power series, whereas uniqueness for the characteristic function will require a Fourier analysis argument. This is the advantage of working with coefficients.

Examples that calculate themselves. A Bernoulli variable with parameter pp has G(s)=1−p+psG(s) = 1 - p + ps; by property 4, a sum of nn independent Bernoulli variables has G(s)=(1−p+ps)nG(s) = (1 - p + ps)^n, whose coefficients are binomial by the binomial theorem: the binomial is the law of that sum without calculating a single convolution. For the Poisson,

G(s)=∑ke−μμkk!sk=eμ(s−1),G(s) = \sum_k e^{-\mu}\frac{\mu^k}{k!}s^k = e^{\mu(s - 1)},

and hence, if independent X∼Poisson⁡(μ1)X \sim \operatorname{Poisson}(\mu_1) and Y∼Poisson⁡(μ2)Y \sim \operatorname{Poisson}(\mu_2), then GX+Y(s)=e(μ1+μ2)(s−1)G_{X+Y}(s) = e^{(\mu_1 + \mu_2)(s - 1)}: X+Y∼Poisson⁡(μ1+μ2)X + Y \sim \operatorname{Poisson}(\mu_1 + \mu_2). Differentiation gives G′(1)=μG'(1) = \mu and G′′(1)=μ2G''(1) = \mu^2, so Var⁡(X)=μ2+μ−μ2=μ\Var(X) = \mu^2 + \mu - \mu^2 = \mu.

Random sums

In the conditional expectation lesson you calculated the mean and variance of S=ξ1+⋯+ξNS = \xi_1 + \cdots + \xi_N with random NN. The PGF gives the entire law.

Proof

Condition on NN, as in the previous lesson: E[sS]=∑nP(N=n) E[sξ1+⋯+ξn]=∑nP(N=n) H(s)n=GN(H(s))\E[s^S] = \sum_n \Pr(N = n)\,\E\big[s^{\xi_1 + \cdots + \xi_n}\big] = \sum_n \Pr(N = n)\,H(s)^n = G_N(H(s)), where the second equality uses property 4 nn times.

∎

The chain rule recovers what you already knew: E[S]=GN′(1)H′(1)=E[N] E[ξ]\E[S] = G_N'(1)H'(1) = \E[N]\,\E[\xi] and, differentiating twice, Var⁡(S)=E[N]Var⁡(ξ)+Var⁡(N) E[ξ]2\Var(S) = \E[N]\Var(\xi) + \Var(N)\,\E[\xi]^2. But there is more. If N∼Poisson⁡(λ)N \sim \operatorname{Poisson}(\lambda), then GS(s)=exp⁡ ⁣(λ(H(s)−1))G_S(s) = \exp\!\big(\lambda(H(s) - 1)\big): this is the compound Poisson, the law of aggregate loss from a Poisson number of claims, which reappears as a compound Poisson process. And if each ξi\xi_i is Bernoulli(pp) (each Poisson event is retained with probability pp), H(s)=1−p+psH(s) = 1 - p + ps and GS(s)=exp⁡ ⁣(λp(s−1))G_S(s) = \exp\!\big(\lambda p(s - 1)\big): thinning a Poisson(λ\lambda) with probability pp produces a Poisson(λp\lambda p), the key result of superposition and thinning, in two lines.

Branching processes and extinction

A Galton-Watson process starts with one individual, Z0=1Z_0 = 1, and each individual in generation nn has a number of offspring with law (pk)k≥0(p_k)_{k \ge 0}, independent of one another and of previous generations. It describes surnames becoming extinct, chains of infection, particle cascades and the growth of search trees, measured by the effective branching factor. The natural question is: what is the probability of extinction?

The next generation’s size is a random sum, Zn+1=ξ1+⋯+ξZnZ_{n+1} = \xi_1 + \cdots + \xi_{Z_n}, so if GG is the PGF of the number of offspring and GnG_n that of ZnZ_n, the previous theorem gives Gn+1=Gn∘GG_{n+1} = G_n \circ G, that is, Gn=G∘G∘⋯∘GG_n = G \circ G \circ \cdots \circ G (nn times). The probability of extinction by generation nn is P(Zn=0)=Gn(0)\Pr(Z_n = 0) = G_n(0), and the probability of eventual extinction is q=lim⁡nGn(0)q = \lim_n G_n(0), the limit of an increasing sequence of events.

Proof

Let sn=Gn(0)=P(Zn=0)s_n = G_n(0) = \Pr(Z_n = 0). Then sn+1=G(sn)s_{n+1} = G(s_n), the sequence is increasing (the events {Zn=0}\{Z_n = 0\} increase) and has limit qq. Because GG is continuous on [0,1][0, 1], q=G(q)q = G(q): it is a root. If r∈[0,1]r \in [0, 1] is another root, since GG is increasing and s0=0≤rs_0 = 0 \le r, induction gives sn≤rs_n \le r for every nn (from sn≤rs_n \le r follows sn+1=G(sn)≤G(r)=rs_{n+1} = G(s_n) \le G(r) = r), so q≤rq \le r: it is the smallest.

For the second part, GG is convex on [0,1][0, 1] (a sum of convex functions pkskp_k s^k), and strictly convex if pk>0p_k > 0 for some k≥2k \ge 2. If m≤1m \le 1, the tangent at s=1s = 1, 1+m(s−1)1 + m(s - 1), lies below GG and above the diagonal (m≤1m \le 1 and s−1≤0s - 1 \le 0), so G(s)>sG(s) > s for every s<1s < 1 (equality would require GG to be affine, i.e. pk=0p_k = 0 for k≥2k \ge 2, and then m=p1<1m = p_1 < 1 gives G(s)−s=p0(1−s)>0G(s) - s = p_0(1 - s) > 0): 11 is the only root. If m>1m > 1, G(1−h)=1−mh+o(h)<1−hG(1 - h) = 1 - mh + o(h) < 1 - h for small hh, so G(s)−s<0G(s) - s < 0 near 11, while G(0)−0=p0≥0G(0) - 0 = p_0 \ge 0: continuity gives a root in [0,1)[0, 1), and q<1q < 1.

∎

The figure animates the proof. The sequence sns_n is the staircase between the curve y=G(s)y = G(s) and the diagonal; it converges to their first intersection. The tangent at (1,1)(1, 1) has slope mm: when mm crosses 11, a second intersection appears (the critical value m=1m = 1 is the phase transition).

InteractiveExtinction probability: iterating the PGF
q = 0.417y = G(s)
  • y=G(s)y = G(s)
  • y=sy = s
  • tangent at (1,1)(1,1), slope mm
  • staircase Gn(0)G_n(0)
  • smallest root qq of G(s)=sG(s) = s
Probability of extinction by generation nn
Number of offspring
1.50
n = 25
regimesupercritical, m = 1.50
extinction probability qq0.4172
P(Zn=0)=Gn(0)\Pr(Z_n = 0) = G_n(0) at current nn0.4172
survival probability 1−q1 - q0.5828
p0,p1,p2,p3p_0, p_1, p_2, p_30.22, 0.33, 0.25, 0.13
With m>1m > 1, curve GG meets the diagonal at q<1q < 1: the process never becomes extinct with probability 1−q1 - q.
The blue curve is y=G(s)y = G(s) for an offspring law with mean mm; the dashed line is the diagonal, and the tangent at (1,1)(1, 1) has slope mm. The magenta staircase starts at s0=0s_0 = 0 and applies sn+1=G(sn)s_{n+1} = G(s_n): sns_n is P(Zn=0)\Pr(Z_n = 0), the probability of extinction by generation nn. On the right, sns_n rises with nn toward the smallest root qq of G(s)=sG(s) = s (red circle on the left, dashed red line on the right). Move mm across 11: below it, the curve is above the diagonal and q=1q = 1; above it a root smaller than 11 appears and the population never dies out with probability 1−q1 - q. Near m=1m = 1 the staircase barely advances: critical extinction is extremely slow. Change the family while keeping mm fixed: qq depends on the entire shape of GG on [0,1][0, 1], but whether q<1q < 1 or q=1q = 1 is decided by mm alone.

This idea goes further than it may seem. The threshold m=1m = 1 separates a cascade that dies out from one that spreads, and the same structure governs gradient propagation in a very deep network with critical initialization, the R0R_0 of an epidemic, or the branching structure of a Hawkes process.

Moment generating function

The PGF only works for integer-valued variables. For a real variable XX, replace sXs^X with eλXe^{\lambda X}, which is the same when s=eλs = e^\lambda, and evaluate at every real λ\lambda.

Since eλX>0e^{\lambda X} > 0, the expectation is always defined, although it may be +∞+\infty. Always 0∈DX0 \in D_X with MX(0)=1M_X(0) = 1. If λ1<λ<λ2\lambda_1 < \lambda < \lambda_2 belong to the domain, eλx≤eλ1x+eλ2xe^{\lambda x} \le e^{\lambda_1 x} + e^{\lambda_2 x} implies λ∈DX\lambda \in D_X: the domain is an interval containing 00. Nearly all the useful properties occur when 00 is an interior point, that is, when MM is finite on (−a,b)(-a, b) for a,b>0a, b > 0.

Proof

Fix λ0∈(−a,b)\lambda_0 \in (-a, b) and δ>0\delta > 0 with [λ0−2δ,λ0+2δ]⊂(−a,b)[\lambda_0 - 2\delta, \lambda_0 + 2\delta] \subset (-a, b). For each kk there is a CC such that ∣x∣k≤Ceδ∣x∣\abs{x}^k \le C e^{\delta\abs{x}}, and so, for ∣λ−λ0∣≤δ\abs{\lambda - \lambda_0} \le \delta,

∣x∣keλx≤C eδ∣x∣+λx≤C(e(λ0+2δ)x+e(λ0−2δ)x),\abs{x}^k e^{\lambda x} \le C\,e^{\delta\abs{x} + \lambda x} \le C\big(e^{(\lambda_0 + 2\delta)x} + e^{(\lambda_0 - 2\delta)x}\big),

a function with finite expectation that does not depend on λ\lambda. Taking λ0=0\lambda_0 = 0 proves (1). The same bound is the dominating function required by the theorem on differentiation under the integral sign (applied with ∂λeλx=xeλx\partial_\lambda e^{\lambda x} = x e^{\lambda x} and repeated kk times), proving (2). For (3), ∑k∣λx∣k/k!=e∣λx∣≤eλx+e−λx\sum_k \abs{\lambda x}^k/k! = e^{\abs{\lambda x}} \le e^{\lambda x} + e^{-\lambda x} is integrable for ∣λ∣<min⁡(a,b)\abs{\lambda} < \min(a, b), so the dominated convergence theorem (or Fubini) allows exchanging sum and expectation in E[eλX]=E[∑k(λX)k/k!]\E[e^{\lambda X}] = \E[\sum_k (\lambda X)^k/k!].

∎

That is why it is called the moment generating function: it is the exponential series of the sequence of moments. To see the mechanism, the exponential X∼Exp⁡(θ)X \sim \operatorname{Exp}(\theta) has M(λ)=∫0∞θe−(θ−λ)x ⁣dx=θθ−λM(\lambda) = \int_0^\infty \theta e^{-(\theta - \lambda)x}\dd x = \dfrac{\theta}{\theta - \lambda} for λ<θ\lambda < \theta, and the geometric expansion 11−λ/θ=∑k(λ/θ)k\dfrac{1}{1 - \lambda/\theta} = \sum_k (\lambda/\theta)^k identifies, by property 3, E[Xk]/k!=θ−k\E[X^k]/k! = \theta^{-k}, that is, E[Xk]=k!/θk\E[X^k] = k!/\theta^k, without a single integration by parts.

For the normal, completing the square gives M(λ)=eμλ+σ2λ2/2M(\lambda) = e^{\mu\lambda + \sigma^2\lambda^2/2} for every λ∈R\lambda \in \R (the domain is R\R), and again the moments can be read from the power series of an exponential. For the Poisson, M(λ)=eμ(eλ−1)M(\lambda) = e^{\mu(e^\lambda - 1)}, the PGF evaluated at s=eλs = e^\lambda.

When the MGF exists and when it does not

Having 00 in the interior of the domain is a statement about the tails.

Proof

(⇒\Rightarrow) If MM is finite on (−a,b)(-a, b), Markov’s inequality applied to eλXe^{\lambda X} with λ=b/2\lambda = b/2 gives P(X>x)≤e−λxM(λ)\Pr(X > x) \le e^{-\lambda x} M(\lambda), and similarly with −a/2-a/2 for P(X<−x)\Pr(X < -x). (⇐\Leftarrow) If P(∣X∣>x)≤Ce−cx\Pr(\abs{X} > x) \le C e^{-cx} and ∣λ∣<c\abs{\lambda} < c, the tail formula, E[e∣λ∣∣X∣]=1+∫0∞∣λ∣e∣λ∣xP(∣X∣>x) ⁣dx≤1+C∣λ∣∫0∞e−(c−∣λ∣)x ⁣dx<∞\E[e^{\abs{\lambda}\abs{X}}] = 1 + \int_0^\infty \abs{\lambda} e^{\abs{\lambda}x}\Pr(\abs{X} > x)\dd x \le 1 + C\abs{\lambda}\int_0^\infty e^{-(c - \abs{\lambda})x}\dd x < \infty, bounds M(λ)≤E[e∣λ∣∣X∣]M(\lambda) \le \E[e^{\abs{\lambda}\abs{X}}].

∎

The laws in this catalogue fall into these groups. With tails decaying faster than any exponential (normal, binomial, Poisson, bounded support), the domain is all of R\R; the Poisson, with a tail of order e−xlog⁡xe^{-x\log x}, is in this group even though its tail is heavier than the Gaussian. With exponential tails (exponential, gamma, Laplace), the domain is an interval bounded by the rate: λ<θ\lambda < \theta for the exponential with rate θ\theta. For heavy tails (Pareto, Cauchy, Student’s tt, log-normal), the domain is only (−∞,0](-\infty, 0] or only {0}\{0\}: for Pareto with index 33, ∫1∞eλx 3x−4 ⁣dx=∞\int_1^\infty e^{\lambda x}\,3x^{-4}\dd x = \infty for every λ>0\lambda > 0, because the exponential beats any power.

This is information rather than a failure of the tool: MM being finite near 00 means exactly that the tail decays exponentially. This is the definition of a sub-exponential variable that we will see in the Bernstein lesson, and of a sub-Gaussian one if, in addition, with centered XX, M(λ)≤eσ2λ2/2M(\lambda) \le e^{\sigma^2\lambda^2/2} for all λ∈R\lambda \in \R.

Cumulant generating function

The MGF turns sums into products, MX+Y=MXMYM_{X+Y} = M_X M_Y, but products are awkward to differentiate. A logarithm turns them back into sums.

Convexity follows from Hölder’s inequality, and that proof (which holds on the whole domain, including its boundary, where ψ\psi is not differentiable) is the first exercise. Property 3 follows by taking logarithms of the product of MGFs. Property 2 needs an idea useful throughout the lesson: exponential tilting.

Tilting a law

If λ∈DX\lambda \in D_X, the formula

Pλ( ⁣dx)=eλx−ψ(λ) PX( ⁣dx)P_\lambda(\dd x) = e^{\lambda x - \psi(\lambda)}\,P_X(\dd x)

defines a probability (its total mass is M(λ)/M(λ)=1M(\lambda)/M(\lambda) = 1), the exponentially tilted law of XX. It multiplies the density by an increasing exponential (when λ>0\lambda > 0) and renormalizes it, moving mass to the right. Notice P0=PXP_0 = P_X. All the information about derivatives of ψ\psi is in it: for interior λ\lambda, differentiating under the integral,

ψ′(λ)=M′(λ)M(λ)=E[XeλX]M(λ)=Eλ[X],ψ′′(λ)=M′′M−(M′M)2=Eλ[X2]−Eλ[X]2=Var⁡λ(X).\psi'(\lambda) = \frac{M'(\lambda)}{M(\lambda)} = \frac{\E[X e^{\lambda X}]}{M(\lambda)} = \E_\lambda[X], \qquad \psi''(\lambda) = \frac{M''}{M} - \Big(\frac{M'}{M}\Big)^2 = \E_\lambda[X^2] - \E_\lambda[X]^2 = \Var_\lambda(X).

The derivative of ψ\psi at λ\lambda is the mean of the tilted law, and the second derivative is its variance. At λ=0\lambda = 0 the tilted law is the original one, giving property 2, and since variance is nonnegative, ψ′′≥0\psi'' \ge 0: convexity (strict if XX is nonconstant, because then Var⁡λ(X)>0\Var_\lambda(X) > 0). The slope ψ′(λ)\psi'(\lambda) increases with λ\lambda because tilting pushes the mean to the right, faster when there is more variance to move.

InteractiveThe shape of the cumulant generating function
Cumulant function ψ(λ)=log⁡E[eλX]\psi(\lambda) = \log \E[e^{\lambda X}]
ψ = +∞−I
  • ψ(λ)\psi(\lambda)
  • tangent at λ0\lambda_0
  • tangent at 00, slope E[X]\E[X]
  • curvature parabola
Original and tilted laws pλ0(x)=p(x) eλ0x−ψ(λ0)p_{\lambda_0}(x) = p(x)\,e^{\lambda_0 x - \psi(\lambda_0)}
  • p(x)p(x) and its mean E[X]\E[X]
  • pλ0(x)p_{\lambda_0}(x) y su media ψ′(λ0)\psi'(\lambda_0)
With a=ψ′(λ0)=2.00a = \psi'(\lambda_0) = 2.00, the Chernoff bound on the right tail P(X≥a)\Pr(X \ge a) is e−I=0.736e^{-I} = 0.736. On the graph of ψ\psi, the tangent intersects the axis λ=0\lambda = 0 at −I=−0.31-I = −0.31.
Law of XX
0.50
ψ(λ0)\psi(\lambda_0)0.693
ψ′(λ0)\psi'(\lambda_0), tilted mean2.000
ψ′′(λ0)\psi''(\lambda_0), tilted variance4.000
ψ′(0)=E[X]\psi'(0) = \E[X], ψ′′(0)=Var⁡(X)\psi''(0) = \Var(X)1.000, 1.000
κ1,…,κ4\kappa_1, \dots, \kappa_41, 1, 2, 6
I=λ0ψ′(λ0)−ψ(λ0)I = \lambda_0\psi'(\lambda_0) - \psi(\lambda_0)0.307
For X∼Exp⁡(1)X \sim \operatorname{Exp}(1), ψ(λ)=−log⁡(1−λ)\psi(\lambda) = -\log(1 - \lambda) has a vertical asymptote at rate λ=1\lambda = 1: M(λ)=∞M(\lambda) = \infty for λ≥1\lambda \ge 1. The tilted law is another exponential, with rate 1−λ1 - \lambda.
On the left, ψ(λ)=log⁡E[eλX]\psi(\lambda) = \log\E[e^{\lambda X}] in blue, with its tangent at λ0\lambda_0 (dashed, slope ψ′(λ0)\psi'(\lambda_0)), the parabola with curvature ψ′′(λ0)\psi''(\lambda_0) (magenta), and the tangent at 00 in dotted gray, with slope E[X]\E[X]. On the right, the original and tilted laws pλ0(x)=p(x)eλ0x−ψ(λ0)p_{\lambda_0}(x) = p(x)e^{\lambda_0 x - \psi(\lambda_0)}, with their means: the tilted mean is exactly the slope, and the tilted variance the curvature. The tangent intersects the λ=0\lambda = 0 axis at −I-I, with I=λ0ψ′(λ0)−ψ(λ0)I = \lambda_0\psi'(\lambda_0) - \psi(\lambda_0), the exponent of the Chernoff bound (below). For the exponential, ψ\psi has a vertical asymptote at rate λ=1\lambda = 1 and the tilted mean shoots up as you approach it. For the Pareto and log-normal, ψ=+∞\psi = +\infty for every λ>0\lambda > 0: tilting is possible only toward the origin, and the domain ends at a wall.

Cumulants versus moments

The first cumulants have names of their own. Expanding log⁡M\log M with M(λ)=1+m1λ+m2λ2/2+⋯M(\lambda) = 1 + m_1\lambda + m_2\lambda^2/2 + \cdots (where mk=E[Xk]m_k = \E[X^k]) and log⁡(1+u)=u−u2/2+⋯\log(1 + u) = u - u^2/2 + \cdots gives

κ1=m1,κ2=m2−m12,κ3=E[(X−m1)3],κ4=E[(X−m1)4]−3 κ22.\kappa_1 = m_1, \qquad \kappa_2 = m_2 - m_1^2, \qquad \kappa_3 = \E\big[(X - m_1)^3\big], \qquad \kappa_4 = \E\big[(X - m_1)^4\big] - 3\,\kappa_2^2.

Through order 33, cumulants and central moments coincide. From order four onward they do not: κ4\kappa_4 is the central moment of order 44 minus 3σ43\sigma^4, so κ4/σ4\kappa_4/\sigma^4 is the excess kurtosis, which is 00 for the normal (whose central moment of order 44 is 3σ43\sigma^4). The advantage of cumulants over moments is additivity. If SnS_n is the sum of nn independent copies of XX, then κr(Sn)=nκr(X)\kappa_r(S_n) = n\kappa_r(X), whereas the central moment of order 44 of the sum is nκ4+3n2σ4n\kappa_4 + 3n^2\sigma^4, mixing nn with n2n^2.

Lawψ(λ)\psi(\lambda)κn\kappa_n
N(μ,σ2)\Normal(\mu, \sigma^2)μλ+σ2λ2/2\mu\lambda + \sigma^2\lambda^2/2μ,σ2,0,0,…\mu, \sigma^2, 0, 0, \dots
Poisson⁡(μ)\operatorname{Poisson}(\mu)μ(eλ−1)\mu(e^\lambda - 1)μ\mu for every nn
Exp⁡(θ)\operatorname{Exp}(\theta)−log⁡(1−λ/θ)-\log(1 - \lambda/\theta)(n−1)!/θn(n - 1)!/\theta^n
Gamma⁡(k,θ)\operatorname{Gamma}(k, \theta)−klog⁡(1−λ/θ)-k\log(1 - \lambda/\theta)k (n−1)!/θnk\,(n - 1)!/\theta^n
Unif⁡(−1,1)\operatorname{Unif}(-1, 1)log⁡(sinh⁡λ/λ)\log\big(\sinh\lambda/\lambda\big)0,13,0,−215,0,…0, \tfrac13, 0, -\tfrac{2}{15}, 0, \dots

Three observations from the table. The normal is the law with zero cumulants from order 33 onward, and the only one: by a theorem of Marcinkiewicz, if ψ\psi is a polynomial it has degree at most 22. The Poisson has all cumulants equal, so its mean and variance coincide. And the gamma has κn=k(n−1)!/θn\kappa_n = k(n-1)!/\theta^n, the cumulant of kk independent exponentials: its excess kurtosis is κ4/κ22=6/k\kappa_4/\kappa_2^2 = 6/k, decreasing like 1/k1/k when variables are added, and here the central limit theorem emerges in cumulant form. Standardize SnS_n by σn\sigma\sqrt{n}: the cumulant of order r≥3r \ge 3 of (Sn−nμ)/(σn)(S_n - n\mu)/(\sigma\sqrt n) is nκr/(σn)r=κr σ−r n1−r/2→0n\kappa_r/(\sigma\sqrt{n})^r = \kappa_r\,\sigma^{-r}\,n^{1 - r/2} \to 0, while κ1=0\kappa_1 = 0 and κ2=1\kappa_2 = 1 stay fixed: the cumulants approach those of the normal, one by one.

The Chernoff bound

Convexity and tilting meet in the most useful bound in applied probability. For λ≥0\lambda \ge 0 and a∈Ra \in \R, Markov’s inequality applied to eλXe^{\lambda X} gives

P(X≥a)=P(eλX≥eλa)≤e−λa M(λ)=e−(λa−ψ(λ)).\Pr(X \ge a) = \Pr\big(e^{\lambda X} \ge e^{\lambda a}\big) \le e^{-\lambda a}\,M(\lambda) = e^{-(\lambda a - \psi(\lambda))}.

We can choose the best λ\lambda: P(X≥a)≤exp⁡ ⁣(−sup⁡λ≥0{λa−ψ(λ)})\Pr(X \ge a) \le \exp\!\big(-\sup_{\lambda \ge 0}\{\lambda a - \psi(\lambda)\}\big), the Legendre transform of ψ\psi at aa. For a>E[X]a > \E[X] (the interesting tail; if a≤E[X]a \le \E[X] the supremum is 00 and the bound is trivial), the optimum, when interior to the domain, satisfies ψ′(λ)=a\psi'(\lambda) = a: tilt the law until its mean is exactly aa. The figure shows this: with λ0\lambda_0 and a=ψ′(λ0)a = \psi'(\lambda_0), the exponent is I=λ0a−ψ(λ0)I = \lambda_0 a - \psi(\lambda_0), visible on the graph of ψ\psi as the negative of the tangent’s vertical-axis intercept. For N(0,σ2)\Normal(0, \sigma^2), ψ(λ)=σ2λ2/2\psi(\lambda) = \sigma^2\lambda^2/2 and λa−ψ\lambda a - \psi is maximized at λ=a/σ2\lambda = a/\sigma^2, with I=a2/(2σ2)I = a^2/(2\sigma^2): the Gaussian tail P(X≥a)≤e−a2/(2σ2)\Pr(X \ge a) \le e^{-a^2/(2\sigma^2)}. For Poisson(μ\mu), I=alog⁡(a/μ)−a+μI = a\log(a/\mu) - a + \mu, the Kullback-Leibler divergence between Poisson(aa) and Poisson(μ\mu): the exponent of a tail is a distance between the original and tilted laws. This is developed in the lessons on Chernoff and Cramér; here it suffices to know where it comes from.

Characteristic function

The MGF fails for heavy tails because eλxe^{\lambda x} grows without bound. The solution is to replace the real exponential with an imaginary exponential, which rotates rather than explodes: eitxe^{itx} has modulus 11 for every xx and tt, so its expectation always exists.

A center of mass

Think of φ(t)\varphi(t) geometrically. Each possible value xx of XX becomes, for fixed tt, a point eitxe^{itx} on the unit circle, and φ(t)\varphi(t) is the center of mass of those points, each weighted by its probability. As tt rises, the point for atom xx rotates at angular speed xx. At t=0t = 0 all are at 11 and φ(0)=1\varphi(0) = 1.

InteractiveThe characteristic function as a center of mass
ReIm
  • atom xx at eitxe^{itx}, size by weight
  • center of mass φ(t)\varphi(t)
  • path of φ\varphi from 00 to tt
00.51
Modulus ∣φ(t)∣\abs{\varphi(t)} for t∈[0,4π]t \in [0, 4\pi]. The dashed line is the edge of the circle.
1.00
φ(t)\varphi(t)−0.046 − 0.017 i
∣φ(t)∣\abs{\varphi(t)}0.0491
arg⁡φ(t)\arg\varphi(t)−2.783 rad
Lattice with spacing 11: at t=2πt = 2\pi all points return together, ∣φ∣=1\abs{\varphi} = 1.
The blue points are eitxe^{itx} for each atom xx of the law, sized by probability; the magenta point is their center of mass φ(t)\varphi(t), and the magenta curve its path from 00 to tt. On the right, ∣φ(t)∣\abs{\varphi(t)} versus tt. Play the animation. With the die (integer atoms) all points return to 11 together at t=2πt = 2\pi and ∣φ∣=1\abs{\varphi} = 1: this is a lattice law and its characteristic function is periodic. With atoms 0,1,20, 1, \sqrt 2, which are incommensurable, the tt window extends to [0,26π][0, 26\pi]: the modulus returns near 11 (0.990.99 at t≈31.2t \approx 31.2, 0.9980.998 at t≈75.5t \approx 75.5, where t/2πt/2\pi and t2/2πt\sqrt2/2\pi are nearly integers simultaneously) but never reaches it. With the coin ±1\pm 1 it returns to the edge already at t=πt = \pi. With the normal, uniform, or Cauchy, speeds form a continuum, points spread around the circle and the center sinks toward 00. For continuous laws, 160160 equally weighted atoms at quantiles are drawn only to visualize the cloud; the center of mass uses the exact formula for φ\varphi.

The figure suggests three facts, proved below: ∣φ∣≤1\abs{\varphi} \le 1 (the center of mass of points on a circle lies in the disk); if all points coincide at some t≠0t \ne 0, the law is lattice; and the modulus tends to zero when the law has a density, by the Riemann-Lebesgue lemma.

Proof

(1) ∣E[eitX]∣≤E∣eitX∣=1\abs{\E[e^{itX}]} \le \E\abs{e^{itX}} = 1 by the triangle inequality for expectation, and eitX‾=e−itX\overline{e^{itX}} = e^{-itX}. (2) ∣φ(t+h)−φ(t)∣=∣E[eitX(eihX−1)]∣≤E∣eihX−1∣\abs{\varphi(t + h) - \varphi(t)} = \abs{\E[e^{itX}(e^{ihX} - 1)]} \le \E\abs{e^{ihX} - 1}, independent of tt and tending to 00 as h→0h \to 0 by dominated convergence (the bound is 22). (3) E[eit(aX+b)]=eitbE[ei(at)X]\E[e^{it(aX + b)}] = e^{itb}\E[e^{i(at)X}]. (4) As for the PGF, eitXe^{itX} and eitYe^{itY} are independent and bounded.

(5) Apply differentiation under the integral with dominating function ∣x∣k∈L1(PX)\abs{x}^k \in L^1(P_X): φ(k)(t)=E[(iX)keitX]\varphi^{(k)}(t) = \E[(iX)^k e^{itX}], continuous by dominated convergence. The expansion uses the elementary bound ∣eiy−∑k≤n(iy)k/k!∣≤min⁡ ⁣(∣y∣n+1/(n+1)!, 2∣y∣n/n!)\abs{e^{iy} - \sum_{k \le n}(iy)^k/k!} \le \min\!\big(\abs{y}^{n+1}/(n+1)!,\ 2\abs{y}^n/n!\big). With y=tXy = tX,

∣φ(t)−∑k≤n(it)kk!E[Xk]∣≤∣t∣n E[min⁡(∣t∣ ∣X∣n+1(n+1)!, 2∣X∣nn!)],\Big\lvert\varphi(t) - \sum_{k \le n}\frac{(it)^k}{k!}\E[X^k]\Big\rvert \le \abs{t}^n\,\E\Big[\min\Big(\frac{\abs{t}\,\abs{X}^{n+1}}{(n+1)!},\ \frac{2\abs{X}^n}{n!}\Big)\Big],

and the expectation tends to 00 as t→0t \to 0 by dominated convergence (the bound 2∣X∣n/n!2\abs{X}^n/n! is integrable and the first argument of the minimum tends to 00 pointwise). This is the remainder o(∣t∣n)o(\abs{t}^n).

∎

Properties 3 and 4 use the same mechanism as the PGF and MGF, now without any condition. Property 5 implies that if XX has mean 00 and variance 11, φ(t)=1−t2/2+o(t2)\varphi(t) = 1 - t^2/2 + o(t^2).

Examples. For Bernoulli, φ(t)=1−p+peit\varphi(t) = 1 - p + pe^{it}, and for the exponential with rate θ\theta, φ(t)=∫0∞θe−(θ−it)x ⁣dx=θ/(θ−it)\varphi(t) = \int_0^\infty \theta e^{-(\theta - it)x}\dd x = \theta/(\theta - it): the MGF formula with λ=it\lambda = it. For the uniform on (−1,1)(-1, 1), φ(t)=sin⁡t/t\varphi(t) = \sin t/t. For the standard normal there is a short proof without complex variables. Since x p(x)=−p′(x)x\,p(x) = -p'(x) for the Gaussian density, differentiating under the integral and integrating by parts gives

φ′(t)=∫ix eitxp(x) ⁣dx=i∫eitx(−p′(x)) ⁣dx=i (it)∫eitxp(x) ⁣dx=−t φ(t),\varphi'(t) = \int i x\,e^{itx}p(x)\dd x = i\int e^{itx}\big(-p'(x)\big)\dd x = i\,(it)\int e^{itx}p(x)\dd x = -t\,\varphi(t),

and φ(0)=1\varphi(0) = 1 gives φ(t)=e−t2/2\varphi(t) = e^{-t^2/2}. By property 3, for N(μ,σ2)\Normal(\mu, \sigma^2) it is eiμt−σ2t2/2e^{i\mu t - \sigma^2t^2/2}. Note the elegance: up to constants, the normal density is its own Fourier transform. This self-duality makes the inversion proof tractable. (The normal appearing as a limit of sums has another cause, seen in cumulants: it is the only law with quadratic ψ\psi, and when a sum is standardized cumulants of order ≥3\ge 3 vanish.)

The standard Cauchy has φ(t)=e−∣t∣\varphi(t) = e^{-\abs{t}}, calculated by residues or inversion in the second exercise. It is striking because e−∣t∣e^{-\abs{t}} is not differentiable at 00, consistent with the Cauchy having no mean (E∣X∣=∞\E\abs{X} = \infty).

Lattice laws and the behavior of ∣φ∣\abs{\varphi}

The figure suggested that ∣φ(t0)∣=1\abs{\varphi(t_0)} = 1 for some t0≠0t_0 \ne 0 is very special. It is.

Proof

(⇐\Leftarrow) If X=a+hNX = a + hN with integer NN, eit0X=eit0a ei 2πN sgn(t0)=eit0ae^{it_0X} = e^{it_0 a}\,e^{i\,2\pi N\,\mathrm{sgn}(t_0)} = e^{it_0 a} almost surely and ∣φ(t0)∣=1\abs{\varphi(t_0)} = 1. (⇒\Rightarrow) Let φ(t0)=eiα\varphi(t_0) = e^{i\alpha}. Then 1=e−iαφ(t0)=E[ei(t0X−α)]1 = e^{-i\alpha}\varphi(t_0) = \E[e^{i(t_0X - \alpha)}], and taking real parts, E[1−cos⁡(t0X−α)]=0\E[1 - \cos(t_0X - \alpha)] = 0. Since 1−cos⁡≥01 - \cos \ge 0, it is 00 almost surely: t0X−α∈2πZt_0 X - \alpha \in 2\pi\mathbb{Z}, i.e. X∈α/t0+(2π/t0)ZX \in \alpha/t_0 + (2\pi/t_0)\mathbb{Z}. Periodicity of ∣φ∣\abs{\varphi} follows from φ(t+2π/h)=eia 2π/h φ(t)\varphi(t + 2\pi/h) = e^{ia\,2\pi/h}\,\varphi(t).

∎

Thus for an integer variable not concentrated on a coarser progression, ∣φ(t)∣=1\abs{\varphi(t)} = 1 exactly at t∈2πZt \in 2\pi\mathbb{Z}; the coin ±1\pm 1 has spacing 22 and returns at t=πt = \pi, as shown. At the opposite extreme, the Riemann-Lebesgue lemma (the analogue of Fourier coefficients of an integrable function tending to zero) says that if XX has a density, φ(t)→0\varphi(t) \to 0 as ∣t∣→∞\abs{t} \to \infty. The converse is false (a singular law may have φ→0\varphi \to 0), but the smoother the density, the faster φ\varphi decays: the infinitely smooth normal has Gaussian decay; the exponential, with a jump at 00, only 1/t1/t. This correspondence between smoothness of ff and decay of φ\varphi determines numerical inversion accuracy.

Preview: the central limit theorem in four lines

Let XiX_i be iid with mean 00 and variance 11, Sn=X1+⋯+XnS_n = X_1 + \cdots + X_n, and φ\varphi the characteristic function of X1X_1. By properties 3 and 4, the characteristic function of Sn/nS_n/\sqrt n is φ(t/n)n\varphi(t/\sqrt n)^n, and by property 5, φ(u)=1−u2/2+o(u2)\varphi(u) = 1 - u^2/2 + o(u^2):

φSn/n(t)=(1−t22n+o(1n))n⟶e−t2/2(n→∞).\varphi_{S_n/\sqrt n}(t) = \Big(1 - \frac{t^2}{2n} + o\big(\tfrac1n\big)\Big)^n \longrightarrow e^{-t^2/2} \qquad (n \to \infty).

The limit is the characteristic function of the standard normal. One link is missing: Lévy’s continuity theorem, which states that if characteristic functions of a sequence of laws converge pointwise to a function continuous at 00, the sequence converges in distribution. It turns the convergence of φSn/n\varphi_{S_n/\sqrt n} into Sn/n⇒N(0,1)S_n/\sqrt n \Rightarrow \Normal(0, 1); the complete proof, with the tail bound, is in the central limit theorem lesson.

Uniqueness and inversion

Everything above is useful only if the characteristic function identifies the law. It does, with a constructive formula.

Proof

The idea is to smooth with a Gaussian, making the integral tractable, and then remove the smoothing.

Step 1: the smoothed law. Let Z∼N(0,1)Z \sim \Normal(0, 1) be independent of XX and ε>0\varepsilon > 0. The density of εZ\varepsilon Z is gε(u)=(2πε2)−1/2e−u2/(2ε2)g_\varepsilon(u) = (2\pi\varepsilon^2)^{-1/2}e^{-u^2/(2\varepsilon^2)}, and by Gaussian self-duality, gε(u)=12π∫e−itu e−ε2t2/2 ⁣dtg_\varepsilon(u) = \frac{1}{2\pi}\int e^{-itu}\,e^{-\varepsilon^2t^2/2}\dd t. The sum X+εZX + \varepsilon Z has density fε(x)=E[gε(x−X)]f_\varepsilon(x) = \E[g_\varepsilon(x - X)], and by Fubini (the integrand is bounded by integrable e−ε2t2/2e^{-\varepsilon^2t^2/2}),

fε(x)=12π∫e−itx E[eitX] e−ε2t2/2 ⁣dt=12π∫e−itx φX(t) e−ε2t2/2 ⁣dt.f_\varepsilon(x) = \frac{1}{2\pi}\int e^{-itx}\,\E\big[e^{itX}\big]\,e^{-\varepsilon^2t^2/2}\dd t = \frac{1}{2\pi}\int e^{-itx}\,\varphi_X(t)\,e^{-\varepsilon^2t^2/2}\dd t.

The law of X+εZX + \varepsilon Z depends on XX only through φX\varphi_X.

Step 2: uniqueness. For every bounded continuous hh, E[h(X+εZ)]→E[h(X)]\E[h(X + \varepsilon Z)] \to \E[h(X)] as ε→0\varepsilon \to 0 (dominated convergence: X+εZ→XX + \varepsilon Z \to X and hh is bounded). If φX=φY\varphi_X = \varphi_Y, the preceding steps give E[h(X+εZ)]=E[h(Y+εZ)]\E[h(X + \varepsilon Z)] = \E[h(Y + \varepsilon Z)] for every ε\varepsilon, and taking ε→0\varepsilon \to 0, E[h(X)]=E[h(Y)]\E[h(X)] = \E[h(Y)] for every bounded continuous hh. Such functions determine the law (indicators of closed intervals are decreasing limits of bounded continuous functions, and intervals form a π\pi-system generating the Borel sets: π\pi-λ\lambda theorem).

Step 3: inversion. If φX∈L1\varphi_X \in L^1, dominated convergence gives fε(x)→f(x):=12π∫e−itxφX(t) ⁣dtf_\varepsilon(x) \to f(x) := \frac{1}{2\pi}\int e^{-itx}\varphi_X(t)\dd t uniformly in xx (the difference is bounded by 12π∫∣φX∣ (1−e−ε2t2/2) ⁣dt→0\frac{1}{2\pi}\int\abs{\varphi_X}\,(1 - e^{-\varepsilon^2t^2/2})\dd t \to 0). Thus ff is continuous (uniform limit of continuous functions), bounded and ≥0\ge 0 (limit of densities). For h∈Cch \in C_c, E[h(X+εZ)]=∫hfε→∫hf\E[h(X + \varepsilon Z)] = \int h f_\varepsilon \to \int h f, and the limit is also E[h(X)]\E[h(X)]: the law of XX has density ff.

∎

This argument is also an algorithm. A program inverting a characteristic function with Gaussian smoothing does just this: it produces a valid density, at the cost of bias controlled by ε\varepsilon. Without integrability (for example, an atomic law has a nondecaying φ\varphi), Lévy’s formula still holds in an integrated form: for a<ba < b continuity points of the distribution function,

F(b)−F(a)=lim⁡T→∞12π∫−TTe−ita−e−itbit φ(t) ⁣dt.F(b) - F(a) = \lim_{T \to \infty}\frac{1}{2\pi}\int_{-T}^{T}\frac{e^{-ita} - e^{-itb}}{it}\,\varphi(t)\dd t.

Takeaways. Three constantly used consequences. (i) Recognizing laws: if φS(t)=eiμt−σ2t2/2\varphi_{S}(t) = e^{i\mu t - \sigma^2t^2/2}, then SS is normal. A sum of independent normals N(μi,σi2)\Normal(\mu_i, \sigma_i^2) has φ=∏jeiμjt−σj2t2/2=ei(∑μj)t−(∑σj2)t2/2\varphi = \prod_j e^{i\mu_jt - \sigma_j^2t^2/2} = e^{i(\sum\mu_j)t - (\sum\sigma_j^2)t^2/2}, so it is N(∑μj,∑σj2)\Normal(\sum\mu_j, \sum\sigma_j^2), and uniqueness justifies that conclusion. (ii) Symmetry: φ−X=φX‾\varphi_{-X} = \overline{\varphi_X}, so φX\varphi_X is real if and only if X=d−XX \overset{d}{=} -X. (iii) Multivariate: the characteristic function of a vector, φX(t)=E[ei t⊤X]\varphi_{\vb{X}}(\vb{t}) = \E[e^{i\,\vb{t}\T\vb{X}}], determines its law and equals ∏jφXj(tj)\prod_j\varphi_{X_j}(t_j) if and only if the coordinates are independent. The multivariate Gaussian lesson defines the Gaussian vector this way.

One consequence for MGFs: if MX=MYM_X = M_Y in a neighborhood of 00, then XX and YY have the same law. Both characteristic functions arise by analytically continuing λ↦M(λ)\lambda \mapsto M(\lambda) to λ=it\lambda = it and agree in the strip; the final section gives the argument.

Inverting with the FFT

The inversion formula is an integral, and integrals can be discretized. With step Δt\Delta t and cutoff TT, the trapezoid rule is

f^(x)=Δt2π∑∣tk∣≤Tφ(tk) e−itkx,tk=k Δt,\hat f(x) = \frac{\Delta t}{2\pi}\sum_{\abs{t_k} \le T}\varphi(t_k)\,e^{-it_kx}, \qquad t_k = k\,\Delta t,

and evaluated on the grid xj=j Δxx_j = j\,\Delta x with Δx Δt=2π/N\Delta x\,\Delta t = 2\pi/N it is exactly a discrete Fourier transform of NN terms: the one computed by np.fft.fft in O(Nlog⁡N)\mathcal{O}(N\log N) (with a small alternating sign change for centered grids, as the code shows). This is the Carr-Madan method for option prices, and the method used by libraries to calculate densities of laws defined by their characteristic function (stable laws, Lévy processes, compound Poisson mixtures). It has three dangers, each with a precise mathematical cause:

  • Aliasing. f^\hat f is periodic in xx with period L=2π/ΔtL = 2\pi/\Delta t: by the Poisson summation formula, f^(x)=∑j∈ZfT(x+jL)\hat f(x) = \sum_{j \in \mathbb{Z}}f_T(x + jL), the (truncated) density summed with all its shifted copies. If the law has mass outside [−L/2,L/2][-L/2, L/2] (heavy tails), that mass wraps around to the other side. Remedy: small Δt\Delta t, i.e. a large window LL.
  • Resolution. Cutting off at ∣t∣≤T\abs{t} \le T amounts to smoothing ff with a kernel of width ∼π/T\sim \pi/T, which is also the grid spacing Δx\Delta x. Remedy: large TT.
  • Gibbs ringing. If ff has a jump (the exponential at 00, the uniform at its endpoints), φ\varphi decays only as 1/t1/t and the abrupt cutoff at TT produces waves around the jump, including negative densities and overshoot near 9 %9\,\% of the jump. Remedy: multiply φ\varphi by e−ε2t2/2e^{-\varepsilon^2t^2/2} (adding N(0,ε2)\Normal(0, \varepsilon^2) noise, as in the inversion proof) or another smooth window, at the cost of bias of order ε\varepsilon at the jump.
InteractiveInverting a characteristic function on a grid
Exact density versus f^(x)=Δt2π∑∣tk∣≤Tφ(tk) e−itkx\hat f(x) = \frac{\Delta t}{2\pi}\sum_{\abs{t_k} \le T}\varphi(t_k)\,e^{-it_k x}
  • exact density ff
  • grid reconstruction f^\hat f
  • window edge ±L/2\pm L/2
What remains of ∣φ(t)∣\abs{\varphi(t)}
Gray: ∣φ∣\abs{\varphi}. Aqua: after multiplication by e−ε2t2/2e^{-\varepsilon^2 t^2/2}. Red: discarded region. If ∣φ∣\abs{\varphi} has not fallen nearly to zero at TT, the cutoff leaves a trace.
Scenarios
Law to recover
0.25
10
0.00
error ∫∣f^−f∣ ⁣dx\int \abs{\hat f - f}\dd x in view0.209
window L=2π/ΔtL = 2\pi/\Delta t25.13
resolution in xx, π/T\pi/T0.314
terms in the sum, 2T/Δt2T/\Delta t81
∣φ(T)∣\abs{\varphi(T)}, what is discarded1.0e−1
minimum of f^\hat f−0.085
There is negative mass: this is Gibbs ringing from the cutoff at TT. A density cannot be negative; the ringing is an artifact, not data.
Reconstruction f^\hat f (magenta) against exact density (gray, dashed). In Gibbs ringing (exponential, with a jump at 00), cutoff TT leaves waves and negative values; increase TT and the waves narrow but do not disappear (the jump overshoot is always near 9 %9\,\%). In Gaussian smoothing, multiplying φ\varphi by e−ε2t2/2e^{-\varepsilon^2t^2/2} removes the ringing but rounds the jump. In Aliasing, a Cauchy is inverted with too short a window (the red line marks ±L/2\pm L/2): heavy tails decaying as 1/x21/x^2 wrap around and raise the density. In Well chosen (normal) error is practically zero. On the right, the modulus ∣φ(t)∣\abs{\varphi(t)}: red shows the discarded region, aqua after smoothing. Adjust Δt\Delta t, TT and ε\varepsilon by hand and see which readout changes: the window depends only on Δt\Delta t and resolution only on TT.

The moment problem

One last question: do moments determine the law? If E[Xk]=E[Yk]\E[X^k] = \E[Y^k] for all k≥1k \ge 1, do XX and YY have the same law? If the MGF exists, yes.

Proof

Let MXM_X be finite on (−a,a)(-a, a). For any t0∈Rt_0 \in \R, differentiating under the integral gives φX(k)(t0)=E[(iX)keit0X]\varphi_X^{(k)}(t_0) = \E[(iX)^k e^{it_0X}], so ∣φX(k)(t0)∣≤E∣X∣k\abs{\varphi_X^{(k)}(t_0)} \le \E\abs{X}^k, and the MGF theorem gives E∣X∣k≤Cr k! r−k\E\abs{X}^k \le C_r\,k!\,r^{-k} for any r<ar < a (from er∣x∣≥rk∣x∣k/k!e^{r\abs{x}} \ge r^k\abs{x}^k/k! and E[er∣X∣]≤M(r)+M(−r)<∞\E[e^{r\abs{X}}] \le M(r) + M(-r) < \infty). Thus the Taylor series of φX\varphi_X at any point t0t_0 converges to φX\varphi_X for ∣t−t0∣<r\abs{t - t_0} < r: the bound ∣eiy−∑k≤n(iy)k/k!∣≤∣y∣n+1/(n+1)!\abs{e^{iy} - \sum_{k \le n}(iy)^k/k!} \le \abs{y}^{n+1}/(n+1)! with y=(t−t0)Xy = (t - t_0)X bounds the order-nn remainder by ∣t−t0∣n+1E∣X∣n+1/(n+1)!≤Cr(∣t−t0∣/r)n+1→0\abs{t - t_0}^{n+1}\E\abs{X}^{n+1}/(n+1)! \le C_r(\abs{t - t_0}/r)^{n+1} \to 0. Thus φX\varphi_X is analytic on R\R. The same holds for YY, whose even absolute moments are equal and whose odd absolute moments are bounded by the even ones (Cauchy-Schwarz), so it has the same bound. At t0=0t_0 = 0, derivatives φ(k)(0)=ikE[Xk]\varphi^{(k)}(0) = i^k\E[X^k] agree, hence φX=φY\varphi_X = \varphi_Y on (−r,r)(-r, r). Two analytic functions agreeing on an interval agree on all R\R (identity principle), and by uniqueness X=dYX \overset{d}{=} Y.

∎

The theorem says “if the MGF exists, moments suffice.” It does not say the converse, which is false: there are laws without an MGF whose moments do not determine the law. The classic example, due to Stieltjes (1894), is the log-normal.

Proof

It is a density: 1+asin⁡(⋅)≥01 + a\sin(\cdot) \ge 0 for ∣a∣≤1\abs{a} \le 1. With u=log⁡xu = \log x, ∫0∞xkf(x)sin⁡(2πlog⁡x) ⁣dx=∫Reku ϕ(u)sin⁡(2πu) ⁣du\int_0^\infty x^k f(x)\sin(2\pi\log x)\dd x = \int_{\R} e^{ku}\,\phi(u)\sin(2\pi u)\dd u, where ϕ\phi is the standard normal density. Completing the square, ekuϕ(u)=ek2/2ϕ(u−k)e^{ku}\phi(u) = e^{k^2/2}\phi(u - k), and with v=u−kv = u - k the integral is ek2/2∫ϕ(v)sin⁡(2π(v+k)) ⁣dv=ek2/2∫ϕ(v)sin⁡(2πv) ⁣dv=0e^{k^2/2}\int\phi(v)\sin\big(2\pi(v + k)\big)\dd v = e^{k^2/2}\int\phi(v)\sin(2\pi v)\dd v = 0, because kk is integer (the sine has period 2π2\pi in vv) and ϕ(v)sin⁡(2πv)\phi(v)\sin(2\pi v) is odd. Taking k=0k = 0 shows faf_a integrates to 11 and, for k≥1k \ge 1, that moments agree. The laws differ for a≠0a \ne 0 because their densities differ on a set of positive Lebesgue measure (for example, where sin⁡(2πlog⁡x)>0\sin(2\pi\log x) > 0).

∎

The figure makes this tangible. With u=log⁡Xu = \log X, the two densities are a Gaussian and a Gaussian multiplied by a sinusoid; the moments of XX are the values of the Laplace transform of that density at integers, E[ekU]\E[e^{kU}], and the sinusoid is orthogonal to all exponentials with integer kk against the Gaussian. With ω=2π\omega = 2\pi, total variation distance between ff and f1f_1 is 12E∣sin⁡2πZ∣≈0.318\tfrac12\E\abs{\sin 2\pi Z} \approx 0.318: the laws are not close, yet the table’s six moments agree up to rounding.

InteractiveSame moments, different law
Density of XX on the xx scale
Density of U=log⁡XU = \log X: a Gaussian with a sinusoid
The characteristic function does distinguish them: ∣φfa(t)−φf(t)∣\abs{\varphi_{f_a}(t) - \varphi_f(t)}
Moments E[Xk]\E[X^k]: log-normal and perturbed
ke^(k²/2)with arel. diff.
11.6491.6490
27.3897.3890
390.01790.0170
42980.9582980.9580
52.683e+52.683e+50
66.566e+76.566e+70
  • log-normal ff
  • perturbed fa=f (1+asin⁡(ωlog⁡x))f_a = f\,(1 + a\sin(\omega\log x))
0.90
2.00
total variation distance TV⁡(f,fa)\operatorname{TV}(f, f_a)0.286
maximum ∣φfa(t)−φf(t)∣\abs{\varphi_{f_a}(t) - \varphi_f(t)}, t∈[0,15]t \in [0, 15]0.180
ω\omega is a multiple of π\pi: sin⁡(ωk)=0\sin(\omega k) = 0 for every integer kk, and all six moments agree with the log-normal up to quadrature error. Different laws, same moments.
The log-normal density ff (gray, dashed) and the perturbed fa=f (1+asin⁡(ωlog⁡x))f_a = f\,(1 + a\sin(\omega\log x)), on the xx scale and the u=log⁡xu = \log x scale (where the perturbation is a sinusoid of frequency ω\omega on a Gaussian). The table calculates moments E[Xk]\E[X^k] of faf_a by quadrature and compares them with exact values ek2/2e^{k^2/2}: with ω\omega a multiple of π\pi (slider value 22, giving the classic sin⁡(2πlog⁡x)\sin(2\pi\log x)) relative difference is zero or order 10−1610^{-16}, floating-point noise, for any amplitude aa. Move ω/π\omega/\pi off the integers and moments separate by relative difference a e−ω2/2sin⁡(ωk)a\,e^{-\omega^2/2}\sin(\omega k): substantially at ω/π=0.5\omega/\pi = 0.5, around 10−510^{-5} at 1.51.5 (the factor e−ω2/2e^{-\omega^2/2} suppresses it). Below, the characteristic function does distinguish the two laws: ∣φfa−φf∣\abs{\varphi_{f_a} - \varphi_f} reaches 0.20.2 with ω=2π\omega = 2\pi and a=1a = 1.

This phenomenon teaches two lessons. First: agreement of all moments does not identify a law, so a moment-matching method can confuse laws with different tails. A sufficient condition, finer than the MGF, is Carleman’s condition: ∑nm2n−1/(2n)=∞\sum_n m_{2n}^{-1/(2n)} = \infty guarantees determinacy, with mk=E[Xk]m_k = \E[X^k]. For the log-normal m2n=e2n2m_{2n} = e^{2n^2}, m2n−1/(2n)=e−nm_{2n}^{-1/(2n)} = e^{-n} and the series converges: the condition fails, as expected. Second: the characteristic function always distinguishes laws, because it determines the law without assumptions. Of the four transforms, only it gives complete identification.

Implementation from scratch

All of the above can be calculated in a few lines of NumPy. Start with the simplest point: convolution is a product of PGFs evaluated at roots of unity. The fast Fourier transform evaluates G(s)=∑kpkskG(s) = \sum_k p_k s^k at s=e−2πij/Ms = e^{-2\pi ij/M}, j=0,…,M−1j = 0, \dots, M-1: it is the PGF at MM points of the circle; multiplying and applying the inverse yields the pmf of the sum. Choose MM larger than the sum’s support to avoid circular overlap.

[ ]Convolución como producto de PGFBrowser
import numpy as np

dado = np.array([0] + [1 / 6] * 6)               # pmf de un dado sobre {0, ..., 6}
M = 64                                           # mayor que el soporte de la suma de 10 dados (0 a 60)

conv = np.array([1.0])
for _ in range(10):                              # diez convoluciones directas
    conv = np.convolve(conv, dado)
G = np.fft.fft(dado, M)                          # G(w^j): la PGF en las raíces M-ésimas de la unidad
via_pgf = np.fft.ifft(G ** 10).real[:61]         # producto de diez PGF y transformada inversa

s = np.arange(61)
print(f"P(S = 35):  convolución {conv[35]:.6f}   PGF {via_pgf[35]:.6f}")
print(f"mayor diferencia entre las dos pmf: {np.max(np.abs(conv - via_pgf)):.1e}")
print(f"E[S] = {np.sum(s * conv):.4f}, Var(S) = {np.sum((s - 35.0) ** 2 * conv):.4f}   (teoría 35 y {10 * 35 / 12:.4f})")

The two columns agree in every printed digit and the largest difference across the pmf is around 10−1710^{-17}: rounding. We get P(S=35)=0.0727\Pr(S = 35) = 0.0727, the number in the motivation. PGF composition calculates the compound Poisson without enumerating convolutions: N∼Poisson⁡(3)N \sim \operatorname{Poisson}(3) turns and one die per turn, S=ξ1+⋯+ξNS = \xi_1 + \cdots + \xi_N with GS(s)=exp⁡(3(H(s)−1))G_S(s) = \exp\big(3(H(s) - 1)\big).

[ ]Suma aleatoria: G_N(H(s)) en la circunferenciaBrowser
lam, M = 3.0, 256
cara = np.array([0] + [1 / 6] * 6)               # un dado con caras 1..6, y probabilidad 0 en 0
H = np.fft.fft(cara, M)                          # H(s) en las raíces de la unidad
pmf_S = np.fft.ifft(np.exp(lam * (H - 1))).real  # G_N(H(s)) = exp(lam (H(s) - 1)) y vuelta a la pmf

k = np.arange(M)
print(f"suma de masas {pmf_S.sum():.6f},  mínimo {pmf_S.min():.1e}")
print(f"E[S] = {np.sum(k * pmf_S):.4f} (teoría {lam * 3.5})   Var(S) = {np.sum((k - 10.5) ** 2 * pmf_S):.4f} "
      f"(teoría {lam * 35 / 12 + lam * 3.5 ** 2})")

rng = np.random.default_rng(0)                   # comprobación por simulación
N = rng.poisson(lam, 200_000).astype(np.intp)    # intp: en Pyodide (32 bits) np.repeat exige índices de ese tipo
tiradas = rng.integers(1, 7, int(N.sum()))
S = np.bincount(np.repeat(np.arange(N.size), N), weights=tiradas, minlength=N.size)
print(f"P(S=0): PGF {pmf_S[0]:.5f}, e^-3 = {np.exp(-lam):.5f}, simulación {np.mean(S == 0):.5f}")
print(f"P(S=10): PGF {pmf_S[10]:.5f}, simulación {np.mean(S == 10):.5f}")

The variance 45.5=E[N]Var⁡(ξ)+Var⁡(N) E[ξ]2=3⋅3512+3⋅3.5245.5 = \E[N]\Var(\xi) + \Var(N)\,\E[\xi]^2 = 3\cdot\tfrac{35}{12} + 3\cdot 3.5^2 is the previous lesson’s formula, reproduced by the PGF without conditioning. The simulation of 200 000200\,000 replicates agrees with the exact pmf to the third digit, as Monte Carlo error permits. (And P(S=0)=GN(H(0))=GN(0)=e−3\Pr(S = 0) = G_N(H(0)) = G_N(0) = e^{-3} agrees with the probability of no turns.)

Now invert a characteristic function. With grids tk=(k−N/2)Δtt_k = (k - N/2)\Delta t, xj=(j−N/2)Δxx_j = (j - N/2)\Delta x and Δt Δx=2π/N\Delta t\,\Delta x = 2\pi/N, the exponent e−itkxje^{-it_kx_j} equals e−2πijk/Ne^{-2\pi ijk/N} up to a factor (−1)j+k(-1)^{j+k} (because N/2N/2 is even), giving the wrapper around np.fft.fft. The code recovers the density of a sum of three independent exponentials with rates 1,2,31, 2, 3 (whose characteristic function is the product ∏iλi/(λi−it)\prod_i\lambda_i/(\lambda_i - it)) and of a sum of three uniforms, comparing them with the exact solution, simulation and direct convolution.

[ ]Inversión de una función característica con la FFTBrowser
def densidad_desde_cf(phi, x_max, N=4096, eps=0.0):
    """f(x_j) en la malla x_j = (j - N/2) dx de [-x_max, x_max), por inversión de Fourier discreta de phi."""
    dx = 2 * x_max / N
    dt = 2 * np.pi / (N * dx)                    # dt * dx = 2 pi / N: es la relación malla-malla de la FFT
    k = np.arange(N)
    t = (k - N // 2) * dt
    vals = phi(t) * np.exp(-0.5 * (eps * t) ** 2) * (-1.0) ** k   # suavizado gaussiano opcional y signo alterno
    f = (dt / (2 * np.pi)) * (-1.0) ** k * np.fft.fft(vals)
    return (k - N // 2) * dx, f.real

tasas = np.array([1.0, 2.0, 3.0])
phi_hipo = lambda t: np.prod([r / (r - 1j * t) for r in tasas], axis=0)
x, f = densidad_desde_cf(phi_hipo, x_max=20)

# solución exacta (fracciones simples) y convolución directa de las tres densidades
c = [np.prod([tasas[j] / (tasas[j] - tasas[i]) for j in range(3) if j != i]) for i in range(3)]
exacta = (x >= 0) * sum(c[i] * tasas[i] * np.exp(-tasas[i] * np.maximum(x, 0)) for i in range(3))
dx = 0.005
g = np.arange(0, 30, dx)
conv = np.convolve(np.convolve(np.exp(-g), 2 * np.exp(-2 * g)) * dx, 3 * np.exp(-3 * g))[: g.size] * dx

rng = np.random.default_rng(1)
S = sum(rng.exponential(1 / r, 300_000) for r in tasas)
h, e = np.histogram(S, bins=60, range=(0, 6), density=True)
centros = (e[:-1] + e[1:]) / 2

print(f"suma de tres exponenciales (tasas 1, 2, 3), {x.size} puntos")
print(f"  FFT frente a exacta:      {np.max(np.abs(f - exacta)):.1e}")
print(f"  convolución directa:      {np.max(np.abs(conv - np.interp(g, x, f))):.1e}   (error de la malla de paso {dx})")
print(f"  simulación (300 000):     {np.max(np.abs(h - np.interp(centros, x, f))):.1e}   (ruido de Monte Carlo)")

def phi_unif01(t):
    t = np.where(t == 0, 1e-300, t)
    return (np.exp(1j * t) - 1) / (1j * t)
xu, fu = densidad_desde_cf(lambda t: phi_unif01(t) ** 3, x_max=6)
irwin = np.where((xu >= 0) & (xu < 1), xu**2 / 2, np.where((xu >= 1) & (xu < 2), (-2 * xu**2 + 6 * xu - 3) / 2, np.where((xu >= 2) & (xu <= 3), (3 - xu) ** 2 / 2, 0.0)))
print(f"suma de tres uniformes (Irwin-Hall), FFT frente a exacta: {np.max(np.abs(fu - irwin)):.1e}")

The FFT wins by several orders of magnitude: direct convolution has discretization error of order Δx\Delta x (here 10−310^{-3} to 10−210^{-2}), and simulation has Monte Carlo noise 1/n1/\sqrt{n}. For a smooth density and cutoff T=NΔt/2≈320T = N\Delta t/2 \approx 320 where ∣φ∣\abs{\varphi} is already around 10−710^{-7}, the FFT reaches 10−610^{-6}. When it breaks, it does so for the three reasons above, as the same function shows:

[ ]Aliasing y rizado de GibbsBrowser
cauchy = lambda x: 1 / (np.pi * (1 + x**2))
phi_cauchy = lambda t: np.exp(-np.abs(t))
for x_max in [5, 200]:
    xc, fc = densidad_desde_cf(phi_cauchy, x_max)
    print(f"Cauchy con ventana [-{x_max}, {x_max}): error máximo {np.max(np.abs(fc - cauchy(xc))):.1e}")

print("\nuniforme (0, 1), con un salto en cada extremo, N = 512:")
for eps in [0.0, 0.02, 0.05]:
    xg, fg = densidad_desde_cf(phi_unif01, x_max=4, N=512, eps=eps)
    exacta_u = ((xg >= 0) & (xg <= 1)) * 1.0
    print(f"  eps = {eps:4.2f}:  mínimo {fg.min():+.4f}  máximo {fg.max():.4f}   error L1 {np.sum(np.abs(fg - exacta_u)) * (xg[1] - xg[0]):.3f}")

The Cauchy with a short window has error ∼10−2\sim 10^{-2} (aliasing: its heavy tails wrap around), and with the long window 10−510^{-5}. The uniform shows the smoothing tradeoff: without smoothing the minimum is negative, −0.088-0.088, and the maximum exceeds 11 by 9 %9\,\%; with ε=0.02\varepsilon = 0.02 both anomalies almost disappear and error falls; with ε=0.05\varepsilon = 0.05 the jumps are overly rounded and error rises again. This trades off truncating φ\varphi at TT (ringing) against smoothing bias (rounded jumps), with an intermediate ε\varepsilon minimizing their sum.

Finally, the symbolic part. SymPy differentiates the exact generating functions: each cumulant is a derivative at 00, and the relation κ4=μ4−3σ4\kappa_4 = \mu_4 - 3\sigma^4 is checked against moments.

[ ]Cumulantes con SymPyBrowser
import sympy as sp

lam = sp.symbols("lambda")
th, mu, sg, k, lm = sp.symbols("theta mu sigma k lm", positive=True)

def cumulantes(psi, n=6):
    return [sp.simplify(sp.diff(psi, lam, j).subs(lam, 0)) for j in range(1, n + 1)]

casos = {
    "normal": mu * lam + sg**2 * lam**2 / 2,
    "exponencial": -sp.log(1 - lam / th),
    "gamma": -k * sp.log(1 - lam / th),
    "Poisson": lm * (sp.exp(lam) - 1),
}
for nombre, psi in casos.items():
    print(f"{nombre:12s} kappa_1..6 =", cumulantes(psi))

# uniforme (-1, 1): psi = log(sinh(lam)/lam) no se evalúa en 0 directamente, pero sí su serie
serie = sp.series(sp.log(sp.sinh(lam) / lam), lam, 0, 7).removeO()
print("uniforme    ", [sp.nsimplify(serie.coeff(lam, j) * sp.factorial(j)) for j in range(1, 7)])

# momentos de la exponencial desde la MGF y la relación kappa_4 = mu_4 - 3 sigma^4
M = sp.exp(casos["exponencial"])
m = [sp.simplify(sp.diff(M, lam, j).subs(lam, 0)) for j in range(1, 5)]
mu4 = sp.simplify(m[3] - 4 * m[2] * m[0] + 6 * m[1] * m[0] ** 2 - 3 * m[0] ** 4)
print("momentos E[X^k], k=1..4:", m)
print("mu_4 central =", mu4, "   kappa_4 - (mu_4 - 3 kappa_2^2) =", sp.simplify(cumulantes(casos["exponencial"])[3] - (mu4 - 3 * cumulantes(casos["exponencial"])[1] ** 2)))

The preceding cumulant table is verified symbol by symbol: the exponential yields κn=(n−1)!/θn\kappa_n = (n-1)!/\theta^n, the gamma multiplies it by kk, and the Poisson yields μ\mu at every order. The last line confirms that κ4=6/θ4\kappa_4 = 6/\theta^4 equals μ4−3σ4=9/θ4−3/θ4\mu_4 - 3\sigma^4 = 9/\theta^4 - 3/\theta^4.

Estimating cumulants from data

With samples, the natural estimator of κn\kappa_n replaces central moments by those of the empirical law: κ^1=xˉ\hat\kappa_1 = \bar x, κ^2=m2\hat\kappa_2 = m_2, κ^3=m3\hat\kappa_3 = m_3, κ^4=m4−3m22\hat\kappa_4 = m_4 - 3m_2^2, with mr=1n∑(xi−xˉ)rm_r = \frac1n\sum(x_i - \bar x)^r. An exact, not merely asymptotic, property demonstrates additivity: if you take all sums xi+yjx_i + y_j of two samples, each weighted 1/(nm)1/(nm) (the image under (x,y)↦x+y(x, y) \mapsto x + y of the product of the two empirical laws), that law is the convolution of the empirical laws and the cumulants of the sum are exactly the sum of their cumulants.

[ ]Cumulantes muestrales y aditividad exactaBrowser
def cumulantes_muestrales(x):
    x = np.asarray(x, dtype=float)
    d = x - x.mean()
    m2, m3, m4 = np.mean(d**2), np.mean(d**3), np.mean(d**4)
    return np.array([x.mean(), m2, m3, m4 - 3 * m2**2])

rng = np.random.default_rng(0)
x = rng.exponential(1.0, 200_000)
print("Exp(1):      ", np.round(cumulantes_muestrales(x), 3), "  teoría [1, 1, 2, 6]")
u = rng.uniform(-1, 1, 200_000)
print("Unif(-1, 1): ", np.round(cumulantes_muestrales(u), 3), "  teoría [0, 0.333, 0, -0.133]")
g = rng.gamma(10, 0.5, 400_000)                  # suma de diez exponenciales de tasa 2
kg = cumulantes_muestrales(g)
print(f"Gamma(10, tasa 2): curtosis en exceso {kg[3] / kg[1]**2:.3f}   (teoría 6/10 = 0.6)")

a, b = rng.exponential(1.0, 300), rng.uniform(-1, 1, 300)
suma = (a[:, None] + b[None, :]).ravel()         # las 90 000 sumas x_i + y_j: la ley empírica de la suma
dif = cumulantes_muestrales(suma) - (cumulantes_muestrales(a) + cumulantes_muestrales(b))
print("kappa_n(suma) - kappa_n(a) - kappa_n(b):", dif)

The first two lines agree with theory up to sampling error (the exponential’s κ^4\hat\kappa_4 is the noisiest, using a fourth-order moment of an exponential tail), and the last line is zero up to floating-point rounding, ∼10−15\sim 10^{-15}: this is not an approximation but an algebraic identity for empirical laws.

The library version

ToolWhat it providesNotes
scipy.stats.<ley>.stats(moments="mvsk")exact mean, variance, skewness and excess kurtosisthese are κ1,κ2,κ3/κ23/2,κ4/κ22\kappa_1, \kappa_2, \kappa_3/\kappa_2^{3/2}, \kappa_4/\kappa_2^2
scipy.stats.kstat(x, n)kk-statistics (unbiased estimators of κn\kappa_n)up to n=4n = 4; not the plug-in estimators above
scipy.stats.<ley>.moment(n)raw moment of order nnexact
scipy.fft.ifft, np.fft.ifftnumerical inversionused above; scipy.fft also supports workers for parallelism
scipy.optimize.brentqsmallest root of G(s)=sG(s) = sextinction probability
sympysymbolic generating functions and cumulantssp.diff, sp.series
[ ]scipy: cumulantes, k-estadísticos y extinciónBrowser
from scipy import stats, optimize

print("Gamma(3, escala 0.5) exacto, mvsk:", np.round(np.array(stats.gamma(3, scale=0.5).stats(moments="mvsk"), dtype=float), 4))
x = np.random.default_rng(0).exponential(1.0, 200_000)
print("k-estadísticos de una Exp(1):", [round(float(stats.kstat(x, n)), 3) for n in (1, 2, 3, 4)], " (teoría 1, 1, 2, 6)")

# probabilidad de extinción con descendencia Poisson(1.5): la menor raíz de G(s) = s en [0, 1)
G = lambda s: np.exp(1.5 * (s - 1))
q = optimize.brentq(lambda s: G(s) - s, 0.0, 0.99)
print(f"q = {q:.6f}   (probabilidad de extinción; supervivencia {1 - q:.4f})")
s_n = 0.0
for n in range(1, 6):
    s_n = G(s_n)
    print(f"  Pr(Z_{n} = 0) = {s_n:.4f}")

kstat agrees with the preceding cell’s estimator to the third digit because with n=200 000n = 200\,000 the bias correction, of order 1/n1/n, is invisible; for small samples (n≲30n \lesssim 30) it matters. Brent’s root finder, however, would not work on all of [0,1][0, 1]: G(1)−1=0G(1) - 1 = 0, the interval contains two roots (the one sought and the trivial root), and brentq would return 11 as soon as it sees the right endpoint is a root. The right endpoint must instead satisfy G(s)−s<0G(s) - s < 0, which for m>1m > 1 is any s∈(q,1)s \in (q, 1) such as 0.990.99; alternatively use fixed-point iteration, which converges monotonically from 00 to the smallest root by the extinction theorem.

Common mistakes

Exercises

ProofThe cumulant generating function is convex
Prove: Let XX be a real variable with domain D={λ:M(λ)<∞}D = \{\lambda : M(\lambda) < \infty\}, M(λ)=E[eλX]M(\lambda) = \E[e^{\lambda X}]. Prove that ψ=log⁡M\psi = \log M is convex on DD and that, if 00 is an interior point of DD, ψ′(0)=E[X]\psi'(0) = \E[X] and ψ′′(0)=Var⁡(X)\psi''(0) = \Var(X).
0
Use Hölder's inequality E[UV]≤E[Up]1/p E[Vq]1/q\E[UV] \le \E[U^p]^{1/p}\,\E[V^q]^{1/q} for U,V≥0U, V \ge 0, with 1/p+1/q=11/p + 1/q = 1, p,q>1p, q > 1.

Step 1 of 4. Let λ1,λ2∈D\lambda_1, \lambda_2 \in D and θ∈(0,1)\theta \in (0, 1). How do you rewrite e(θλ1+(1−θ)λ2)Xe^{(\theta\lambda_1 + (1 - \theta)\lambda_2)X} to apply Hölder?

ProofThe mean of Cauchy variables is Cauchy
Prove: Prove that the characteristic function of the standard Cauchy, with density p(x)=1/(π(1+x2))p(x) = 1/(\pi(1 + x^2)), is φ(t)=e−∣t∣\varphi(t) = e^{-\abs{t}}, and deduce that the mean Xˉn=(X1+⋯+Xn)/n\bar X_n = (X_1 + \cdots + X_n)/n of nn iid standard Cauchy variables is again standard Cauchy.
0
Use the inversion formula: first compute the characteristic function of the Laplace density 12e−∣x∣\tfrac12 e^{-\abs{x}} and apply inversion to it.

Step 1 of 4. What is the characteristic function of the Laplace density q(x)=12e−∣x∣q(x) = \tfrac12 e^{-\abs{x}}?

NumericExtinction with Poisson(1.5) offspring
A branching process has a Poisson number of offspring per individual with mean 1.51.5. Use the PGF to calculate the probability qq that the lineage eventually dies out.
QuizThe domain of the MGF
Which distribution has a moment generating function finite only for λ<1\lambda < 1?
NumericExcess kurtosis of a sum of exponentials
Let X1,…,X10X_1, \dots, X_{10} be independent exponentials with rate 22 and S=X1+⋯+X10S = X_1 + \cdots + X_{10}. Calculate the excess kurtosis of SS, κ4(S)/κ2(S)2\kappa_4(S)/\kappa_2(S)^2.
QuizWhich cannot be a characteristic function?
Which of these functions is not the characteristic function of any real random variable?
QuizMoments and laws
Which statement is true?
NumericThe t cutoff for FFT inversion
You want a density on x∈[−20,20)x \in [-20, 20) on a grid of N=4096N = 4096 points by characteristic-function inversion with np.fft. The grids satisfy Δt Δx=2π/N\Delta t\,\Delta x = 2\pi/N, with tk=(k−N/2)Δtt_k = (k - N/2)\Delta t. What cutoff T=NΔt/2T = N\Delta t/2 does the characteristic function reach?
CodeSample cumulants and additivity
Implement sample_cumulants(x), returning a length-4 array of sample cumulants [k1, k2, k3, k4] for sample x, calculated using central moments of the empirical law: k1 is the mean, k2 and k3 are the central moments of orders 2 and 3 (with divisor nn), and k4 = m4 - 3 * m2**2. Tests check values for an exponential and a uniform, translation invariance (for k2,k3,k4k_2, k_3, k_4), scaling κn(cX)=cnκn(X)\kappa_n(cX) = c^n\kappa_n(X) and exact additivity of cumulants of the empirical law of sums xi+yjx_i + y_j.
import numpy as np

def sample_cumulants(x):
  """Cumulantes k1, k2, k3, k4 de la ley empirica de la muestra x."""
  x = np.asarray(x, dtype=float)
  # tu codigo: momentos centrales m2, m3, m4 y combinacion para k4
  return np.zeros(4)
Shift+Enter to run

Summary

Key idea
Adding independent variables convolves their laws, and a suitable transform turns this into multiplication. The probability generating function applies to integers, the moment generating function to light tails, the cumulant generating function (ψ=log⁡M\psi = \log M) is convex and additive, and the characteristic function φ(t)=E[eitX]\varphi(t) = \E[e^{itX}] always exists, determines the law and has an inversion formula (computed by FFT). The MGF may not exist for heavy tails, and matching moments does not guarantee matching laws.
  • PGF: G(s)=E[sX]G(s) = \E[s^X] for integers; GX+Y=GXGYG_{X+Y} = G_X G_Y, GS=GN∘HG_S = G_N\circ H for random sums; a branching process extinction probability is the smallest root of G(s)=sG(s) = s and equals 11 if and only if mean offspring is ≤1\le 1.
  • MGF: M(λ)=E[eλX]M(\lambda) = \E[e^{\lambda X}], finite near 00 if and only if the tail decays exponentially; then M(k)(0)=E[Xk]M^{(k)}(0) = \E[X^k] and moments determine the law. For heavy tails it is +∞+\infty for every λ>0\lambda > 0.
  • CGF: ψ=log⁡M\psi = \log M is convex; ψ′(λ)\psi'(\lambda) and ψ′′(λ)\psi''(\lambda) are the mean and variance of the tilted law eλx−ψ(λ)P( ⁣dx)e^{\lambda x - \psi(\lambda)}P(\dd x); cumulants are additive, κ3\kappa_3 is the central moment of order 33 and κ4=μ4−3σ4\kappa_4 = \mu_4 - 3\sigma^4; the Chernoff bound is exp⁡(−sup⁡λ{λa−ψ(λ)})\exp(-\sup_\lambda\{\lambda a - \psi(\lambda)\}).
  • Characteristic function: always exists, ∣φ∣≤1\abs{\varphi} \le 1, uniformly continuous, φX+Y=φXφY\varphi_{X+Y} = \varphi_X\varphi_Y, and with E∣X∣n<∞\E\abs{X}^n < \infty it has a moment expansion. A law is lattice if and only if ∣φ(t0)∣=1\abs{\varphi(t_0)} = 1 for some t0≠0t_0 \ne 0; with a density, φ→0\varphi \to 0 (Riemann-Lebesgue). For the normal it is eiμt−σ2t2/2e^{i\mu t - \sigma^2t^2/2}; for the Cauchy, e−∣t∣e^{-\abs{t}}.
  • Uniqueness and inversion: φ\varphi determines the law and, if φ∈L1\varphi \in L^1, f(x)=12π∫e−itxφ(t) ⁣dtf(x) = \frac{1}{2\pi}\int e^{-itx}\varphi(t)\dd t. FFT inversion requires controlling aliasing (L=2π/ΔtL = 2\pi/\Delta t), resolution (π/T\pi/T) and Gibbs ringing at jumps.
  • Moment problem: an MGF finite near 00 implies determinacy; the log-normal and f(1+asin⁡(2πlog⁡x))f(1 + a\sin(2\pi\log x)) have the same moments and different laws, distinguished by φ\varphi.