Expectation, Variance, and Moment Generating Functions

⚡ Key Takeaways

Expectation, Variance, and Moment Generating Functions are the three foundational tools for summarizing the location, spread, and full distributional shape of a random variable. The expectation E[X]E[X] is the probability-weighted average (the center of mass), the variance Var⁡(X)\operatorname{Var}(X) measures squared dispersion about that center, and the moment generating function MX(t)=E[etX]M_X(t)=E[e^{tX}] encodes ALL moments at once and uniquely determines the distribution when it exists. They apply across all of probability, statistics, physics, finance, and engineering. Core ideas trace to Huygens (1657), Chebyshev, and later formalization by Kolmogorov (1933).

💡 The Core Insight

A distribution can be probed at increasing depth: the expectation pins its center, the variance pins its scale, higher moments pin skew and tail weight, and the moment generating function assembles them into a master object. Operations that are hard on distributions — adding independent variables, scaling, shifting — become trivial on these summaries. This is the same philosophy as a Fourier transform: replace a complicated function (the density) by a transform (the MGF) where the hard operation (convolution) becomes a simple one (multiplication).

Formal Statement

DefinitionExpectation

For a discrete random variable XX with probability mass function p(x)=P(X=x)p(x)=P(X=x) over support S\mathcal{S}, the expectation is

1
E[X]=∑x∈Sx p(x),\quad E[X]=\sum_{x\in\mathcal{S}} x\,p(x),

Derivation hint: weight each attainable value by its probability and sum; this is the definition of a probability-weighted average (center of mass). For a continuous random variable with probability density function f(x)f(x),

2
E[X]=∫−∞∞x f(x) dx,\quad E[X]=\int_{-\infty}^{\infty} x\,f(x)\,dx,

Derivation hint: replace the sum over discrete masses by an integral over the density; f(x) dxf(x)\,dx is the infinitesimal probability of the interval [x,x+dx][x,x+dx]. Here xx ranges over outcomes, p(x)p(x) and f(x)f(x) are nonnegative and integrate/sum to 1. The expectation exists when ∑∣x∣p(x)<∞\sum |x|p(x)<\infty or ∫∣x∣f(x) dx<∞\int|x|f(x)\,dx<\infty (absolute convergence).

TheoremLaw of the Unconscious Statistician (LOTUS)

For any (measurable) function gg,

3
E[g(X)]=∑xg(x) p(x)orE[g(X)]=∫−∞∞g(x) f(x) dx.\quad E[g(X)]=\sum_{x} g(x)\,p(x)\quad\text{or}\quad E[g(X)]=\int_{-\infty}^{\infty} g(x)\,f(x)\,dx.

Derivation hint: one need NOT find the distribution of Y=g(X)Y=g(X) first; weight g(x)g(x) by the probability of xx directly, justified by pushing forward the measure of XX.

DefinitionVariance and Standard Deviation

The variance is the expected squared deviation from the mean μ=E[X]\mu=E[X]:

4
Var⁡(X)=E[(X−μ)2]=E[X2]−(E[X])2.\quad \operatorname{Var}(X)=E\big[(X-\mu)^2\big]=E[X^2]-\big(E[X]\big)^2.

Derivation hint: expand (X−μ)2=X2−2μX+μ2(X-\mu)^2 = X^2 - 2\mu X + \mu^2, take expectation termwise using linearity, and substitute E[X]=μE[X]=\mu. The standard deviation σ=Var⁡(X)\sigma=\sqrt{\operatorname{Var}(X)} restores the original units. Variance has units of XX squared; standard deviation has the units of XX.

DefinitionMoments and Central Moments

The nn-th raw moment is μn′=E[Xn]\mu_n'=E[X^n]; the nn-th central moment is μn=E[(X−μ)n]\mu_n=E[(X-\mu)^n]. Thus μ1′=E[X]\mu_1'=E[X] and μ2=Var⁡(X)\mu_2=\operatorname{Var}(X). The skewness and kurtosis are

5
γ1=μ3σ3,γ2=μ4σ4−3.\quad \gamma_1=\frac{\mu_3}{\sigma^3},\qquad \gamma_2=\frac{\mu_4}{\sigma^4}-3.

Derivation hint: normalize the third and fourth central moments by powers of σ\sigma to obtain scale-free shape descriptors; subtracting 3 makes the normal distribution's excess kurtosis zero.

DefinitionMoment Generating Function

The moment generating function of XX is

6
MX(t)=E ⁣[etX]={∑xetxp(x)(discrete)∫−∞∞etxf(x) dx(continuous)\quad M_X(t)=E\!\left[e^{tX}\right]=\begin{cases}\sum_x e^{tx}p(x)&\text{(discrete)}\\[4pt]\displaystyle\int_{-\infty}^{\infty} e^{tx}f(x)\,dx&\text{(continuous)}\end{cases}

Derivation hint: apply LOTUS with g(x)=etxg(x)=e^{tx}; the MGF exists only for those tt in an open interval about 0 where the sum/integral converges. When MXM_X exists in a neighborhood of t=0t=0, moments are recovered by differentiation:

7
E[Xn]=MX(n)(0)=dndtnMX(t)∣t=0.\quad E[X^n]=M_X^{(n)}(0)=\left.\frac{d^n}{dt^n}M_X(t)\right|_{t=0}.

Derivation hint: expand etX=∑n≥0tnn!Xne^{tX}=\sum_{n\ge0} \tfrac{t^n}{n!}X^n, take expectation termwise (justified by absolute convergence near 0), so MX(t)=∑ntnn!E[Xn]M_X(t)=\sum_n \tfrac{t^n}{n!}E[X^n]; the coefficient of tn/n!t^n/n! is the nn-th moment.

TheoremKey Properties

For constants a,ba,b and independent variables X,YX,Y:

8
E[aX+b]=aE[X]+b,Var⁡(aX+b)=a2Var⁡(X),\quad E[aX+b]=aE[X]+b,\qquad \operatorname{Var}(aX+b)=a^2\operatorname{Var}(X),

Derivation hint: linearity of expectation gives the first; for variance, the additive constant bb shifts the mean but not the spread, and the factor aa pulls out as a2a^2 because variance is quadratic.

9
MaX+b(t)=ebtMX(at),MX+Y(t)=MX(t) MY(t)  if X⊥Y.\quad M_{aX+b}(t)=e^{bt}M_X(at),\qquad M_{X+Y}(t)=M_X(t)\,M_Y(t)\ \text{ if } X\perp Y.

Derivation hint: E[et(aX+b)]=ebtE[e(at)X]E[e^{t(aX+b)}]=e^{bt}E[e^{(at)X}]; for the sum, independence factorizes E[etXetY]=E[etX]E[etY]E[e^{tX}e^{tY}]=E[e^{tX}]E[e^{tY}].

10
Var⁡(X+Y)=Var⁡(X)+Var⁡(Y)+2Cov⁡(X,Y),\quad \operatorname{Var}(X+Y)=\operatorname{Var}(X)+\operatorname{Var}(Y)+2\operatorname{Cov}(X,Y),

Derivation hint: expand E[((X+Y)−μX−μY)2]E[((X+Y)-\mu_X-\mu_Y)^2] and collect the cross term, which defines covariance; if independent, the covariance vanishes.

Why It Holds / Derivation

ProofVariance Shortcut Formula

We prove Var⁡(X)=E[X2]−(E[X])2\operatorname{Var}(X)=E[X^2]-(E[X])^2 from equation [4]. 1. Start from the definition Var⁡(X)=E[(X−μ)2]\operatorname{Var}(X)=E[(X-\mu)^2] with μ=E[X]\mu=E[X]. 2. Expand the square: (X−μ)2=X2−2μX+μ2(X-\mu)^2 = X^2 - 2\mu X + \mu^2. 3. Apply linearity of expectation: E[(X−μ)2]=E[X2]−2μ E[X]+μ2E[(X-\mu)^2]=E[X^2]-2\mu\,E[X]+\mu^2. 4. Substitute E[X]=μE[X]=\mu: the middle term becomes −2μ⋅μ=−2μ2-2\mu\cdot\mu=-2\mu^2. 5. Combine: E[X2]−2μ2+μ2=E[X2]−μ2=E[X2]−(E[X])2E[X^2]-2\mu^2+\mu^2 = E[X^2]-\mu^2 = E[X^2]-(E[X])^2. ■\blacksquare

∎
ProofMGF Generates Moments

We justify equation [7]. 1. Write the power series etX=∑n=0∞tnXnn!e^{tX}=\sum_{n=0}^{\infty}\frac{t^n X^n}{n!}, valid for all real arguments. 2. Provided MX(t)M_X(t) converges in an interval (−h,h)(-h,h), we may interchange expectation and summation (dominated convergence), giving MX(t)=∑n=0∞tnn!E[Xn]M_X(t)=\sum_{n=0}^\infty \frac{t^n}{n!}E[X^n]. 3. This is a Taylor series in tt; by uniqueness of power-series coefficients, E[Xn]E[X^n] is the coefficient of tn/n!t^n/n!. 4. Differentiating nn times and setting t=0t=0 kills all lower terms and the factorials of higher terms vanish at t=0t=0, isolating E[Xn]=MX(n)(0)E[X^n]=M_X^{(n)}(0). ■\blacksquare

∎
Figure
Mean (center of mass), ±σ\pm\sigma spread, and the role of the MGF as a transform
x f(x) μ = E[X] μ−σ μ+σ spread ≈ σ M_X(t)=E[e^{tX}] M'(0)=E[X] M''(0)=E[X²]
mathematician · Pafnuty Chebyshev | 1821–1894

The Russian mathematician Pafnuty Chebyshev placed expectation and variance at the heart of rigorous probability. His Chebyshev inequality, P(∣X−μ∣≥kσ)≤1/k2P(|X-\mu|\ge k\sigma)\le 1/k^2, derived purely from the existence of a finite variance, gave the first distribution-free tail bound and provided the engine for his proof of the law of large numbers. He trained a school (Markov, Lyapunov) that turned moments into the principal tool of limit theory, paving the road to the central limit theorem via the method of moments.

Building Intuition

🧠 Intuition

Think of a probability distribution as a thin metal rod whose mass is spread along the number line according to f(x)f(x). The expectation is the balance point — the center of mass where the rod would balance on a knife edge. The variance is the rod's moment of inertia about that balance point: it measures how the mass is distributed away from the center, with mass far out penalized quadratically. Standard deviation rescales this back to ordinary distance units, answering "how far, typically, are we from the center?" The MGF is best understood as a generating gadget. Imagine you want to know all the moments at once. Rather than computing infinitely many integrals, you compute one function MX(t)M_X(t), and then each moment falls out by differentiation, like extracting coefficients from a polynomial. The exponential etXe^{tX} acts as a "moment vacuum cleaner": its Taylor expansion 1+tX+t22X2+⋯1+tX+\tfrac{t^2}{2}X^2+\cdots sucks in every power of XX simultaneously, and the parameter tt tags each moment with its own power so they can be separated later.

SM
Statistical Mechanics Viewpoint

A physicist immediately recognizes MX(t)=E[etX]M_X(t)=E[e^{tX}] as a partition-function-like object. In statistical mechanics, Z(β)=∑ie−βEiZ(\beta)=\sum_i e^{-\beta E_i} generates the energy moments: ⟨E⟩=−∂βln⁡Z\langle E\rangle = -\partial_\beta \ln Z and Var⁡(E)=∂β2ln⁡Z\operatorname{Var}(E)=\partial_\beta^2 \ln Z. The same algebra appears here through the cumulant generating function KX(t)=ln⁡MX(t)K_X(t)=\ln M_X(t), whose derivatives at zero yield cumulants: K′(0)=μK'(0)=\mu and K′′(0)=σ2K''(0)=\sigma^2. That energy fluctuations relate to heat capacity is precisely the statement that the second cumulant is the variance — thermodynamics and probability share one generating-function skeleton.

Worked Examples

ExampleExponential Distribution: Mean, Variance, MGF

Given: X∼Exponential(λ)X\sim\text{Exponential}(\lambda) with density f(x)=λe−λxf(x)=\lambda e^{-\lambda x} for x≥0x\ge0, λ=2 s−1\lambda=2\ \text{s}^{-1} (e.g., inter-arrival time of customers).

Step 1 — MGF. For t<λt<\lambda,

MX(t)=∫0∞etxλe−λx dx=λ∫0∞e−(λ−t)x dx=λλ−t.M_X(t)=\int_0^\infty e^{tx}\lambda e^{-\lambda x}\,dx=\lambda\int_0^\infty e^{-(\lambda-t)x}\,dx=\frac{\lambda}{\lambda-t}.

Step 2 — Mean via M′(0)M'(0). M′(t)=λ(λ−t)2M'(t)=\dfrac{\lambda}{(\lambda-t)^2}, so E[X]=M′(0)=1λE[X]=M'(0)=\dfrac{1}{\lambda}.

Step 3 — Second moment via M′′(0)M''(0). M′′(t)=2λ(λ−t)3M''(t)=\dfrac{2\lambda}{(\lambda-t)^3}, so E[X2]=M′′(0)=2λ2E[X^2]=M''(0)=\dfrac{2}{\lambda^2}.

Step 4 — Variance. Var⁡(X)=2λ2−1λ2=1λ2\operatorname{Var}(X)=\dfrac{2}{\lambda^2}-\dfrac{1}{\lambda^2}=\dfrac{1}{\lambda^2}.

Numbers (λ=2\lambda=2): E[X]=0.5 sE[X]=0.5\ \text{s}, Var⁡(X)=0.25 s2\operatorname{Var}(X)=0.25\ \text{s}^2, σ=0.5 s\sigma=0.5\ \text{s}.

E[X]=1λ=0.5 s,Var⁡(X)=1λ2=0.25 s2\boxed{E[X]=\tfrac{1}{\lambda}=0.5\ \text{s},\quad \operatorname{Var}(X)=\tfrac{1}{\lambda^2}=0.25\ \text{s}^2}
ExampleSum of Two Independent Dice: Linearity and Variance Addition

Given: Two fair six-sided dice X1,X2X_1,X_2, independent. For one die: E[Xi]=1+2+⋯+66=3.5E[X_i]=\tfrac{1+2+\cdots+6}{6}=3.5.

Step 1 — Single-die variance. E[Xi2]=1+4+9+16+25+366=916≈15.167E[X_i^2]=\tfrac{1+4+9+16+25+36}{6}=\tfrac{91}{6}\approx15.167. Then Var⁡(Xi)=15.167−3.52=15.167−12.25=2.9167\operatorname{Var}(X_i)=15.167-3.5^2=15.167-12.25=2.9167.

Step 2 — Sum's mean (linearity, no independence needed). E[X1+X2]=3.5+3.5=7E[X_1+X_2]=3.5+3.5=7.

Step 3 — Sum's variance (independence ⇒ covariance 0). Var⁡(X1+X2)=2.9167+2.9167=5.8333\operatorname{Var}(X_1+X_2)=2.9167+2.9167=5.8333.

Step 4 — Standard deviation. σ=5.8333≈2.415\sigma=\sqrt{5.8333}\approx 2.415.

E[X1+X2]=7,Var⁡(X1+X2)=356≈5.833,σ≈2.42\boxed{E[X_1+X_2]=7,\quad \operatorname{Var}(X_1+X_2)=\tfrac{35}{6}\approx5.833,\quad \sigma\approx2.42}

Note that variances added but standard deviations did not (2.415≠1.708+1.7082.415\ne 1.708+1.708).

Common Misconceptions

⚠️ Common mistake

Variance does NOT add for the standard deviation, and only adds for variance when variables are uncorrelated. A frequent error is writing σX+Y=σX+σY\sigma_{X+Y}=\sigma_X+\sigma_Y. Standard deviations add in quadrature: σX+Y=σX2+σY2\sigma_{X+Y}=\sqrt{\sigma_X^2+\sigma_Y^2} only when independent. A second trap: E[g(X)]≠g(E[X])E[g(X)]\ne g(E[X]) in general — for nonlinear gg, Jensen's inequality gives E[g(X)]≥g(E[X])E[g(X)]\ge g(E[X]) when gg is convex (e.g., E[X2]≥(E[X])2E[X^2]\ge (E[X])^2, which is exactly why variance is nonnegative). Third: the MGF need not exist; if the defining integral diverges for all t≠0t\ne0, no moments can be extracted this way.

CounterexampleA Distribution with No MGF and Even No Mean

The Cauchy distribution with density f(x)=1π(1+x2)f(x)=\dfrac{1}{\pi(1+x^2)} has ∫−∞∞∣x∣f(x) dx=∞\int_{-\infty}^\infty |x|f(x)\,dx=\infty, so E[X]E[X] does not exist, the variance is undefined, and MX(t)=E[etX]M_X(t)=E[e^{tX}] diverges for every t≠0t\ne0. Yet the Cauchy distribution is perfectly well-defined, symmetric, and bell-shaped — a vivid reminder that "looks like a bump" does not guarantee finite moments. Its characteristic function φX(t)=E[eitX]=e−∣t∣\varphi_X(t)=E[e^{itX}]=e^{-|t|} exists, which is why characteristic functions (always defined) supersede MGFs in rigorous theory.

Connections

connection

Expectation and variance are the first two members of an infinite hierarchy unified by the MGF, which is the real analogue of the Characteristic Function (use itit instead of tt). The logarithm of the MGF gives the Cumulant Generating Function, whose derivatives produce cumulants that add under independence. Variance addition under independence is the seed of the Law of Large Numbers and the Central Limit Theorem, both of which Chebyshev's variance bound and the method of moments help prove. Covariance generalizes variance to the joint setting and underlies Linear Regression and the Multivariate Normal Distribution. The MGF's multiplicative property mirrors the Convolution Theorem — sums of independent variables convolve densities and multiply transforms.

Real-World Applications

🔬 Where this appears

Historical Development

⏳ History
- 1654 — Pascal and Fermat correspond on the "problem of points," implicitly computing expected values of gambling outcomes.
- 1657 — Christiaan Huygens publishes De Ratiociniis in Ludo Aleae, the first printed treatise giving expectation ("expectatio") a formal definition.
- 1713 — Jacob Bernoulli's Ars Conjectandi proves the (weak) law of large numbers, tying long-run averages to expectation.
- 1733–1812 — De Moivre and Laplace develop the normal approximation, implicitly using mean and variance of binomial sums; Laplace introduces generating functions.
- 1867 — Chebyshev publishes his inequality, giving the first variance-based tail bound and a clean proof of the law of large numbers.
- 1900s — Markov and Lyapunov refine the method of moments, using moment convergence to prove central limit theorems.
- 1920s — R. A. Fisher systematizes moments, cumulants, and the term "variance" (coined 1918) in mathematical statistics.
- 1933 — Kolmogorov's Grundbegriffe axiomatizes probability via measure theory, defining expectation as a Lebesgue integral and securing all earlier results.
- 1937 — Cramér and others advance large-deviation theory using MGFs and Chernoff-type exponential bounds.

Subtleties & Limits

open-problem

The MGF is powerful but fragile: it may fail to exist (heavy-tailed laws like Cauchy, log-normal, and Student-tt), so moment-based identification breaks down. Even when all moments are finite, they need not determine the distribution — the moment problem (Stieltjes, Hamburger) shows the log-normal distribution shares its entire moment sequence with infinitely many distinct distributions, so equal moments do not imply equal laws. The characteristic function repairs existence (it is always defined and uniquely determines the distribution), but inverting it constructively, and characterizing precisely which moment sequences correspond to a unique distribution (the determinacy conditions of Carleman and Krein), remain technically delicate. Generalizing moments and concentration bounds to high-dimensional and dependent data is an active research frontier.

See Also

Characteristic Function · Cumulant Generating Function · Central Limit Theorem · Law of Large Numbers · Covariance and Correlation · Multivariate Normal Distribution · Jensen's Inequality · Chebyshev Inequality · Concentration Inequalities