Contents/ Part VIII · Mathematical Statistics/ Chapter 46

Moments, MGFs & Inequalities

Two questions about any distribution: what is its shape, and how far can it stray? Moments and the moment generating function answer the first; Markov, Chebyshev, and Hoeffding answer the second, and underwrite the generalization guarantees of machine learning.

⏱️ ~16 min read
🐍 Notebook included
📊 Chapter 46

A distribution can be summarized by a sequence of numbers, its moments, and bounded by a handful of remarkably general inequalities. Together they let you describe a distribution's shape and guarantee how rarely it produces extreme values, often knowing almost nothing else about it.

M(t)
The moments E[X], E[X²], … capture a distribution's center, spread, skew, and tails. The moment generating function M(t) = E[etX] encodes them all. Concentration inequalities bound the probability of straying far from the mean.
📐
Why moments and bounds matter

Moments are how we compactly describe and compare distributions; the MGF is the algebraic tool that proves many classic results (including the Central Limit Theorem). Concentration inequalities, meanwhile, turn into the finite-sample guarantees, "how much data is enough?", at the heart of statistical learning theory.

1

Moments: a Distribution's Shape

The k-th moment is E[Xk]. In standardized, central form the first four have familiar names: mean (center), variance (spread), skewness (asymmetry), and kurtosis (tail heaviness).

The first four moments: four ways a shape can differ 1. mean center 2. variance spread 3. skewness asymmetry 4. kurtosis tail weight

In the notebook, a normal has skew ≈ 0 and baseline kurtosis, while an exponential has skew ≈ 2 and heavy positive kurtosis. These four numbers let you compare distributions at a glance, the standard vocabulary for "what does this data's shape look like?"

2

The Moment Generating Function

Skim-friendly: this is the most abstract section in the book. If the algebra of MGFs is not what you came for, read the one idea, that a single function encodes every moment of a distribution, and move on; you can return when you need it. The rest of the book does not depend on the mechanics here.

The moment generating function packs every moment into one function: M(t) = E[etX]. Differentiate it at t = 0 and the moments fall out: M′(0) = E[X], M″(0) = E[X²], and so on.

One function, every moment: differentiate M(t) at t = 0 M(t) = E[eᵗᶋ] the MGF M′(0) = E[X] (mean) M″(0) = E[X²] … and the MGF uniquely identifies the distribution; sums multiply their MGFs.

For an exponential with rate 2, recovering M′(0) and M″(0) numerically gives mean 0.5 and E[X²] = 0.5, hence variance 0.25, all exact. Two deeper facts make the MGF indispensable: it uniquely identifies a distribution, and the MGF of a sum of independent variables is the product of their MGFs, which is how the Central Limit Theorem and many distribution results are proved.

3

Markov and Chebyshev Inequalities

How often can a variable stray far from its mean, when you know almost nothing about it? Markov needs only a mean: for X ≥ 0, P(X ≥ a) ≤ E[X]/a. Chebyshev adds the variance: P(|X − μ| ≥ kσ) ≤ 1/k², for any distribution.

Chebyshev: at most 1/k² of any distribution lies beyond kσ μ−2σ μ+2σ at least 1 − 1/k² here ≤ 1/4 ≤ 1/4

For k = 2, Chebyshev caps the tails at 1/4, so at least 75% of any distribution lies within two standard deviations of the mean. The notebook's exponential keeps only 5% beyond 2σ, far inside the bound. That looseness is the point: these inequalities hold with minimal assumptions, making them the universal safety net of probability.

4

Concentration: Why Averages Pile Up

Chebyshev is loose; for averages we can do far better. Hoeffding's inequality says the mean of n bounded variables is exponentially unlikely to stray: P(|X̄ − μ| ≥ ε) ≤ 2e−2nε². Averages concentrate.

As n grows, the sample mean concentrates exponentially fast onto μ μ n=25 n=100 n=400

In the notebook, the chance the mean of n uniforms is more than 0.1 from 0.5 falls from 8% (n = 25) to essentially zero (n = 400), with Hoeffding's exponential bound tracking above it. This is a sharper, finite-sample relative of the Law of Large Numbers, and it is precisely why a model scored on enough data yields a trustworthy estimate.

5

Moments & Inequalities in Machine Learning & AI

These tools are quietly everywhere in machine learning: moments are matched to train generative models, and concentration inequalities are the engine of statistical learning theory.

Idea (this chapter)In ML / AI it appears asConcrete example
Moment matchingTraining generative modelsmaximum mean discrepancy (MMD); moment-matching GANs
Method of momentsQuick parameter estimationestimate a rate as 1/mean
Kurtosis / higher momentsInitialization & stabilitycontrolling activation distributions in deep nets
Hoeffding / Chernoff boundsGeneralization & PAC learninghow much data guarantees a given accuracy
ConcentrationBandits & confidence boundsUCB exploration uses concentration to bound rewards
🤖
Why this matters for AI research

Concentration inequalities are the mathematical foundation of generalization theory. Invert Hoeffding and you get a sample-complexity rule, to estimate a test accuracy within ±0.02 at 95% confidence you need about 4,600 examples, the kind of guarantee that defines PAC learning and tells you whether a benchmark gap is real. The same bounds power the confidence intervals in multi-armed bandits (the "upper confidence bound" algorithm is named for them). On the modeling side, moment matching trains generative models by forcing their synthetic data to share the moments of real data (maximum mean discrepancy is exactly this), the method of moments gives fast parameter estimates, and controlling higher moments keeps activations well-behaved deep in a network. Describing shape and bounding tails is the quiet machinery behind both training and theory.

🐍

Measure shape and bound tails in Python

The companion notebook computes the four moments for symmetric and skewed distributions, recovers the mean and variance by differentiating an empirical moment generating function, verifies the Markov and Chebyshev bounds, watches sample means concentrate under Hoeffding, and inverts Hoeffding into a sample-complexity rule, the guarantee behind honest model evaluation.

📓 View Notebook (code & outputs) ▶ Open in Colab ⬇ View / Download on GitHub

View opens the rendered notebook instantly (no setup). Open in Colab runs & edits it live in your browser. To run locally, install numpy, scipy, and matplotlib and launch jupyter notebook.

🎓 Key Takeaways

  • Moments E[Xk] describe shape: mean, variance, skewness, and kurtosis are the first four.
  • The MGF M(t) = E[etX] generates every moment by differentiation at 0, uniquely identifies a distribution, and multiplies for sums.
  • Markov & Chebyshev bound tails with minimal assumptions: P(|X − μ| ≥ kσ) ≤ 1/k² for any distribution.
  • Hoeffding / concentration: averages of bounded variables stray only with exponentially small probability.
  • In ML/AI: moment matching trains generative models, and concentration bounds give generalization and sample-complexity guarantees (PAC learning, bandits).
6

Practice Challenges

Five short challenges, beginner to intermediate. Try them with NumPy/SciPy before checking the solutions.

1

Four moments

Generate 100,000 draws from Poisson(3) and report mean, variance, skewness, and kurtosis.

Hint: for Poisson, mean = variance = λ, skew = 1/√λ.
2

MGF

For X ~ Normal(5, 2), recover the mean by differentiating the empirical MGF at 0.

Hint: M′(0) ≈ (M(h) − M(−h))/(2h).
3

Chebyshev

Scores have mean 70 and sd 8 (shape unknown). Bound the fraction outside 54 to 86.

Hint: that range is μ ± 2σ; use 1/k².
4

Markov

Response times are nonnegative with mean 200 ms. Bound P(time ≥ 1000 ms).

Hint: P(X ≥ a) ≤ E[X]/a.
5

Sample complexity

Using Hoeffding, how many test examples estimate an accuracy within ±0.03 at 99% confidence?

Hint: n ≥ ln(2/δ)/(2ε²).
Check your work

A fully-worked solutions notebook walks through all five challenges, each verified in code. Try them yourself first, then compare.

📓 View Solutions ▶ Open Solutions in Colab ⬇ View / Download on GitHub
7

Quiz: Test Yourself

Eight quick questions on moments, MGFs, and inequalities. Answer them, hit Check Answers, and keep refining until you score 100%. Your progress is saved, so you can hop back to the chapter and return anytime.