Expectation

Suppose you play a game where you roll a fair die. You win the square of the number shown, in dollars. How much should you expect to walk away with, on average? This applies if you play many times. This is the question that expectation answers. It is the long-run average value of a random quantity. This average is weighted by how likely each outcome is. Expectation is arguably the single most useful number attached to a random variable. It compresses an entire probability distribution into one representative summary. This works in the same way that a center of mass summarizes a distribution of physical weight along a rod. The idea matters because almost every quantitative claim in probability and statistics is, at bottom, a statement about an expectation. This includes insurance premiums, machine learning loss functions, and statistical estimators. Variances, covariances, moment generating functions, and even probabilities themselves are all expectations of cleverly chosen random variables. Probabilities count as expectations via indicator variables. Understanding expectation rigorously is a prerequisite for everything that follows in probability theory. So is understanding why you are allowed to compute the expectation of a function of a random variable, without first finding that function's own distribution. The big picture is this: expectation is a linear, monotone, positivity-respecting map from random variables to real numbers. It is built by integrating (or summing) the variable against its probability measure. Two structural facts make expectation tractable in practice. The first is linearity — the expectation of a sum is the sum of expectations, always, with no independence assumption required. The second is the law of the unconscious statistician (LOTUS). LOTUS lets you compute E[g(X)]E[g(X)] directly from the distribution of XX. This bypasses the distribution of g(X)g(X) entirely. This article gives the precise definition of expectation for discrete and continuous random variables. It proves linearity in full generality, including the infinite-sum case. It proves LOTUS carefully in both the discrete and continuous settings. It also works through examples chosen to expose common errors. These include the temptation to assume independence is needed for linearity. They also include forgetting that expectations of infinite series must converge absolutely to be well defined.

Key takeaways
  • Expectation is a weighted average: E[X]=∑xx p(x)E[X] = \sum_x x\,p(x) for discrete XX, E[X]=∫xf(x) dxE[X] = \int x f(x)\,dx for continuous XX.
  • Expectation may fail to exist (diverge) even when the random variable is finite with probability one — absolute convergence is required.
  • Linearity holds unconditionally: E[aX+bY]=aE[X]+bE[Y]E[aX+bY] = aE[X] + bE[Y], for any X,YX, Y on the same space, no independence needed.
  • LOTUS lets you compute E[g(X)]E[g(X)] using only the distribution of XX, never the distribution of g(X)g(X).
  • Expectation is monotone and respects positivity: X≥0  ⟹  E[X]≥0X \ge 0 \implies E[X] \ge 0, and X≤Y  ⟹  E[X]≤E[Y]X \le Y \implies E[X] \le E[Y].
  • Key idea: expectation is a single linear functional built from the probability measure, and linearity plus LOTUS turn hard distributional problems into easy summation/integration problems.

Where this lives today

Expectation is the computational backbone of statistics, where estimators are evaluated by their expected value (bias) and where maximum likelihood and Bayesian methods both reduce, at some stage, to expectations under a model. In finance, the no-arbitrage pricing of derivatives is built on computing expected discounted payoffs under a risk-neutral probability measure — precisely a LOTUS calculation applied to a payoff function of an underlying asset price. In machine learning, the expected loss (risk) over a data distribution is the quantity that training algorithms attempt to minimize, and LOTUS is used constantly to compute the expected value of a loss function applied to model predictions without needing the (often intractable) distribution of the loss itself. In statistical physics, expectation under the Boltzmann distribution gives thermodynamic averages such as mean energy, connecting directly back to the center-of-mass intuition of this article. In information theory, entropy H(X)=−E[log⁡p(X)]H(X) = -E[\log p(X)] is itself an expectation of a function of the pmf, a direct LOTUS-style computation. In queueing theory and operations research, expected waiting times and expected costs guide system design, again computed via linearity even when the underlying random variables (arrival times, service times) are heavily dependent. Finally, expectation is the immediate stepping stone to Variance and Moments (which uses E[(X−E[X])2]E[(X-E[X])^2], itself a LOTUS computation) and to Moment Generating Functions (which package all moments E[Xn]E[X^n] into a single function E[etX]E[e^{tX}]).

:::quiz[If XX has P(X=−2)=0.4P(X=-2)=0.4, P(X=1)=0.5P(X=1)=0.5, P(X=5)=0.1P(X=5)=0.1, what is E[X]E[X]?]

  • 0.6
  • -0.3 ✓
  • 1.0
  • 2.4

:::quiz[LOTUS lets you compute E[g(X)]E[g(X)] using:]

  • The distribution of g(X)g(X), found first via change of variables
  • The distribution of XX alone, applied directly with gg ✓
  • Only the CDF of g(X)g(X)
  • Monte Carlo simulation exclusively

:::quiz[For XX with density f(x)=2xf(x)=2x on [0,1][0,1], what is E[X2]E[X^2]?]

  • 1/2
  • 1/3
  • 2/3
  • 1/2... recompute: ∫01x2(2x) dx=1/2\int_0^1 x^2 (2x)\,dx = 1/2 ✓

:::quiz[Why does the counterexample series fail to define a valid E[X]E[X]?]

  • Because the pmf does not sum to 1
  • Because the series converges conditionally but not absolutely, so its sum depends on term order ✓
  • Because XX takes infinitely many values, which is never allowed
  • Because negative values are not permitted for random variables

:::faq[Does linearity extend to infinitely many random variables, E[∑i=1∞Xi]=∑i=1∞E[Xi]E\big[\sum_{i=1}^\infty X_i\big] = \sum_{i=1}^\infty E[X_i]?] Not automatically — this requires an extra hypothesis beyond pairwise finiteness of each E[Xi]E[X_i], typically ∑iE∣Xi∣<∞\sum_i E|X_i| < \infty, after which the dominated convergence theorem (or monotone convergence, if all Xi≥0X_i \ge 0) licenses interchanging the infinite sum and the expectation. Without such a condition, the interchange can fail exactly as in the counterexample above, where infinite rearrangements are not automatically benign. This finite-vs-infinite distinction is why the theorem in this article is stated for two (equivalently, any finite number of) random variables, with the infinite extension treated as a separate, stronger result.

Ask the tutor: Why is independence needed for E[XY]=E[X]E[Y]E[XY]=E[X]E[Y] but not for E[X+Y]=E[X]+E[Y]E[X+Y]=E[X]+E[Y]?

DefinitionExpected Value

Let XX be a random variable on a probability space (Ω,F,P)(\Omega, \mathcal{F}, P).

Discrete case. If XX takes values in a countable set {x1,x2,… }\{x_1, x_2, \dots\} with probability mass function p(xi)=P(X=xi)p(x_i) = P(X = x_i), the expectation of XX is

E[X]=∑ixi p(xi),E[X] = \sum_{i} x_i \, p(x_i),

provided the series converges absolutely, i.e. ∑i∣xi∣ p(xi)<∞\sum_i |x_i|\,p(x_i) < \infty. If this sum diverges (does not converge absolutely), E[X]E[X] is said not to exist (or, if all terms have a fixed sign, E[X]E[X] may be declared +∞+\infty or −∞-\infty).

Continuous case. If XX has probability density function ff, meaning P(X∈A)=∫Af(x) dxP(X \in A) = \int_A f(x)\,dx for (Borel) sets AA, the expectation of XX is

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

provided ∫−∞∞∣x∣f(x) dx<∞\int_{-\infty}^\infty |x| f(x)\,dx < \infty.

Unified measure-theoretic statement. Both cases are instances of the Lebesgue integral of XX against PP:

E[X]=∫ΩX(ω) dP(ω),E[X] = \int_\Omega X(\omega)\, dP(\omega),

defined whenever E∣X∣=∫Ω∣X∣ dP<∞E|X| = \int_\Omega |X|\,dP < \infty, in which case XX is called integrable. This article develops the discrete and continuous cases explicitly; the underlying justification for why these two formulas are special cases of one operation is the content of measure-theoretic integration, referenced but not re-derived here.

Intuition

Think of the probability mass function of a discrete random variable as a set of point weights placed along the real line: weight p(xi)p(x_i) sitting at position xix_i. The expectation E[X]E[X] is exactly the center of mass of this system of weights — the balance point of a rigid, weightless rod on which the weights are hung. If you replace weights with a continuous density smeared along the line, the same balance-point interpretation survives, with the sum becoming an integral. This mechanical picture immediately explains several facts that otherwise look mysterious. It explains why E[X]E[X] need not equal any value that XX can actually take (the center of mass of a two-point system need not coincide with either point). It explains why E[X]E[X] is not generally equal to the median or the mode — those are different notions of "typical value," while expectation specifically tracks the balance point. It also foreshadows why E[X]E[X] can be pulled outside sums and scalar multiples: shifting or scaling every weight's position shifts or scales the balance point in the same way, and combining two independent physical systems' balance points behaves additively when you consider their sum.

Figure
Expectation as a center of mass for a die-roll-squared payoff, values 1,4,9,16,25,36 with mass 1/6 each
1 4 9 16 25 36 E[X²] = 91/6 ≈ 15.17 Mass 1/6 at each point 1,4,9,16,25,36

Structural theorem

TheoremLinearity of Expectation

Let XX and YY be random variables on the same probability space (Ω,F,P)(\Omega, \mathcal F, P) with E∣X∣<∞E|X| < \infty and E∣Y∣<∞E|Y| < \infty, and let a,b∈Ra, b \in \mathbb{R} be constants. Then aX+bYaX + bY is integrable and

E[aX+bY]=a E[X]+b E[Y].E[aX + bY] = a\,E[X] + b\,E[Y].

No assumption of independence between XX and YY is required.

LemmaLOTUS, discrete case

Let XX be a discrete random variable with pmf pp, taking values in a countable set SS, and let g:R→Rg : \mathbb{R} \to \mathbb{R} be any function. Then

E[g(X)]=∑x∈Sg(x) p(x),E[g(X)] = \sum_{x \in S} g(x)\,p(x),

provided ∑x∈S∣g(x)∣ p(x)<∞\sum_{x \in S} |g(x)|\,p(x) < \infty, in which case both sides exist and are equal.

LemmaLOTUS, continuous case

Let XX be a continuous random variable with density ff, and let g:R→Rg:\mathbb{R}\to\mathbb{R} be a (Borel-measurable) function such that Y=g(X)Y = g(X) is a well-defined random variable. Then

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

provided ∫−∞∞∣g(x)∣ f(x) dx<∞\int_{-\infty}^\infty |g(x)|\,f(x)\,dx < \infty, in which case both sides exist and are equal.

Proof

We give complete, self-contained proofs for the discrete case first (where all manipulations are honest series rearrangements justified by absolute convergence), then indicate how the continuous case follows by the analogous integral argument. The technique throughout is direct computation from the definition, together with Fubini/Tonelli-type rearrangement of absolutely convergent double sums (justified explicitly below), so no result depending on the theorems being proved is invoked.

Step 1: LOTUS, discrete case. Let XX take values in a countable set S={x1,x2,… }S = \{x_1, x_2, \dots\} with P(X=xi)=p(xi)P(X = x_i) = p(x_i). Fix g:R→Rg:\mathbb{R}\to\mathbb{R} and set Y=g(X)Y = g(X). Since XX takes countably many values, so does YY; let T=g(S)={y1,y2,… }T = g(S) = \{y_1, y_2, \dots\} be the (countable) set of values YY can take. By definition of expectation applied directly to YY,

E[Y]=∑y∈Ty P(Y=y).E[Y] = \sum_{y \in T} y \, P(Y = y).

For each fixed y∈Ty \in T, the event {Y=y}\{Y = y\} is exactly {X∈g−1({y})}\{X \in g^{-1}(\{y\})\}, a disjoint union of the events {X=x}\{X = x\} over those x∈Sx \in S with g(x)=yg(x) = y. Since these events are pairwise disjoint (as XX takes only one value) and countable in number, countable additivity of PP gives

P(Y=y)=∑x:g(x)=yp(x).P(Y = y) = \sum_{x : g(x) = y} p(x).

Substituting,

E[Y]=∑y∈Ty∑x:g(x)=yp(x)=∑y∈T∑x:g(x)=yg(x) p(x),E[Y] = \sum_{y \in T} y \sum_{x: g(x) = y} p(x) = \sum_{y\in T} \sum_{x: g(x)=y} g(x)\, p(x),

using y=g(x)y = g(x) inside the inner sum. The double sum on the right ranges, without overlap or omission, over every x∈Sx \in S exactly once (each xx has a unique image y=g(x)y = g(x), so it appears in exactly one inner sum). Because we are given ∑x∈S∣g(x)∣p(x)<∞\sum_{x \in S} |g(x)| p(x) < \infty, this double sum converges absolutely, so by the theorem on rearrangement of absolutely convergent series (a series that converges absolutely may be summed in any order or grouping without changing its value), we may collapse the double sum into a single sum indexed by x∈Sx \in S:

E[Y]=∑x∈Sg(x) p(x).E[Y] = \sum_{x \in S} g(x)\, p(x).

This proves the discrete LOTUS. Note this argument never required computing the distribution of YY beyond identifying which xx's map to a given yy — but crucially, the final formula does not reference TT or the grouping at all, which is exactly the labor LOTUS saves you.

Step 2: Linearity, discrete case. Apply Step 1 with g(x1,x2)g(x_1, x_2) replaced by the two-variable function h(x,y)=ax+byh(x,y) = ax + by applied to the pair (X,Y)(X,Y), viewed as a single discrete random vector Z=(X,Y)Z = (X,Y) taking values in the countable set SX×SYS_X \times S_Y with joint pmf pX,Yp_{X,Y}. By the same argument as Step 1 (which extends verbatim to functions of a discrete random vector, since a countable product of countable sets is countable and the disjointness/additivity argument is unchanged),

E[aX+bY]=∑(x,y)(ax+by) pX,Y(x,y),E[aX+bY] = \sum_{(x,y)} (ax+by)\, p_{X,Y}(x,y),

provided ∑(x,y)∣ax+by∣ pX,Y(x,y)<∞\sum_{(x,y)} |ax+by|\,p_{X,Y}(x,y) < \infty. This absolute convergence holds because ∣ax+by∣≤∣a∣∣x∣+∣b∣∣y∣|ax + by| \le |a||x| + |b||y|, and

∑(x,y)(∣a∣∣x∣+∣b∣∣y∣) pX,Y(x,y)=∣a∣∑x∣x∣pX(x)+∣b∣∑y∣y∣pY(y)=∣a∣E∣X∣+∣b∣E∣Y∣<∞,\sum_{(x,y)} (|a||x| + |b||y|)\, p_{X,Y}(x,y) = |a| \sum_x |x| p_X(x) + |b|\sum_y |y| p_Y(y) = |a| E|X| + |b| E|Y| < \infty,

where the middle equality uses that summing pX,Y(x,y)p_{X,Y}(x,y) over yy recovers the marginal pX(x)p_X(x) (and symmetrically for yy), a rearrangement again justified by absolute convergence of each nonnegative series. Now split the finite (absolutely convergent) double sum:

∑(x,y)(ax+by) pX,Y(x,y)=a∑(x,y)x pX,Y(x,y)+b∑(x,y)y pX,Y(x,y).\sum_{(x,y)} (ax + by)\, p_{X,Y}(x,y) = a\sum_{(x,y)} x\, p_{X,Y}(x,y) + b \sum_{(x,y)} y\, p_{X,Y}(x,y).

For the first term, sum over yy first for each fixed xx:

∑(x,y)x pX,Y(x,y)=∑xx∑ypX,Y(x,y)=∑xx pX(x)=E[X],\sum_{(x,y)} x\, p_{X,Y}(x,y) = \sum_x x \sum_y p_{X,Y}(x,y) = \sum_x x\, p_X(x) = E[X],

and symmetrically the second term equals E[Y]E[Y]. Hence

E[aX+bY]=aE[X]+bE[Y],E[aX + bY] = a E[X] + b E[Y],

with no reference anywhere to independence of XX and YY — the joint pmf pX,Y(x,y)p_{X,Y}(x,y) was used exactly as given, whatever the dependence structure between XX and YY happens to be.

Step 3: LOTUS and linearity, continuous case. The continuous case requires an integral version of the rearrangement argument; the rigorous justification is Fubini's theorem for absolutely integrable functions, which plays the exact structural role that "rearrangement of absolutely convergent series" played above. We outline the argument, which mirrors Step 1–2 line by line with sums replaced by integrals. For LOTUS: let XX have density ff and let Y=g(X)Y = g(X). If gg is monotone and differentiable with inverse g−1g^{-1}, the density of YY can be found via the change-of-variables formula fY(y)=f(g−1(y)) ∣(g−1)′(y)∣f_Y(y) = f(g^{-1}(y)) \,|(g^{-1})'(y)|, and then

E[Y]=∫y fY(y) dy=∫g(x)f(x) dxE[Y] = \int y\, f_Y(y)\, dy = \int g(x) f(x)\, dx

by the ordinary calculus substitution y=g(x)y = g(x), dy=g′(x) dxdy = g'(x)\,dx (with the sign of g′g' compensating the absolute value in fYf_Y, exactly as in the change-of-variables formula for densities). For general (non-monotone, possibly non-differentiable) Borel gg, the identity E[g(X)]=∫g(x)f(x) dxE[g(X)] = \int g(x) f(x)\, dx is proved by the standard layer-cake / simple-function approximation argument: it holds by definition of the integral for gg an indicator function 1A\mathbf 1_A (since then E[g(X)]=P(X∈A)=∫Af(x) dxE[g(X)] = P(X \in A) = \int_A f(x)\,dx directly from the definition of density), extends to nonnegative simple functions by linearity of finite sums, extends to nonnegative measurable gg by monotone convergence (approximating gg from below by simple functions), and extends to general gg integrable against ff by splitting g=g+−g−g = g^+ - g^-. This is precisely the construction of the Lebesgue integral, applied here to the measure with density ff. For linearity in the continuous case: apply the two-dimensional analogue of the above with joint density fX,Y(x,y)f_{X,Y}(x,y) and g(x,y)=ax+byg(x,y) = ax+by:

E[aX+bY]=∬(ax+by) fX,Y(x,y) dx dy,E[aX+bY] = \iint (ax+by)\, f_{X,Y}(x,y)\, dx\,dy,

valid because ∣ax+by∣≤∣a∣∣x∣+∣b∣∣y∣|ax+by| \le |a||x|+|b||y| is integrable against fX,Yf_{X,Y} (by the same triangle-inequality bound and marginal-integral argument as Step 2, with sums replaced by integrals). Fubini's theorem for absolutely integrable functions permits splitting this double integral and integrating each variable out separately, giving

E[aX+bY]=a∫x fX(x) dx+b∫y fY(y) dy=aE[X]+bE[Y],E[aX+bY] = a\int x\, f_X(x)\, dx + b \int y\, f_Y(y)\, dy = aE[X] + bE[Y],

again without any use of independence. ■\blacksquare

∎
CorollaryMonotonicity and Positivity

If X≥0X \ge 0 almost surely and E[X]E[X] exists, then E[X]≥0E[X] \ge 0. Consequently, if X≤YX \le Y almost surely and both have finite expectation, then E[X]≤E[Y]E[X] \le E[Y].

Proof

If X≥0X \ge 0, every term xi p(xi)x_i \,p(x_i) (discrete) or every value xf(x)x f(x) integrated (continuous, since f≥0f \ge 0 and x≥0x \ge 0 on the support) is nonnegative, so the defining sum/integral is a sum/integral of nonnegative terms and hence nonnegative. For the second claim, apply the first statement to Y−X≥0Y - X \ge 0 and use linearity (Linearity of Expectation) to write E[Y]−E[X]=E[Y−X]≥0E[Y] - E[X] = E[Y-X] \ge 0. ■\blacksquare

∎

Worked examples

Example 1: A non-symmetric wager with LOTUS. A biased die has P(X=1)=0.1P(X=1) = 0.1, P(X=2)=0.05P(X=2) = 0.05, P(X=3)=0.35P(X=3)=0.35, P(X=4)=0.05P(X=4) = 0.05, P(X=5)=0.15P(X=5) = 0.15, P(X=6)=0.30P(X=6) = 0.30 (these sum to 11: 0.1+0.05+0.35+0.05+0.15+0.30=1.000.1+0.05+0.35+0.05+0.15+0.30 = 1.00). A gambler is paid g(X)=10X−X2g(X) = 10X - X^2 dollars. To find E[g(X)]E[g(X)], LOTUS says we never need the distribution of g(X)g(X) itself — only pXp_X and gg:

E[g(X)]=∑x=16(10x−x2) p(x).E[g(X)] = \sum_{x=1}^{6} (10x - x^2)\, p(x).

Compute g(x)g(x) at each value: g(1)=10−1=9g(1) = 10-1=9, g(2)=20−4=16g(2)=20-4=16, g(3)=30−9=21g(3)=30-9=21, g(4)=40−16=24g(4)=40-16=24, g(5)=50−25=25g(5)=50-25=25, g(6)=60−36=24g(6)=60-36=24. Now weight by the pmf:

E[g(X)]=9(0.1)+16(0.05)+21(0.35)+24(0.05)+25(0.15)+24(0.30).E[g(X)] = 9(0.1) + 16(0.05) + 21(0.35) + 24(0.05) + 25(0.15) + 24(0.30).

Term by term: 0.9+0.8+7.35+1.2+3.75+7.20.9 + 0.8 + 7.35 + 1.2 + 3.75 + 7.2. Summing: 0.9+0.8=1.70.9+0.8=1.7; 1.7+7.35=9.051.7+7.35=9.05; 9.05+1.2=10.259.05+1.2=10.25; 10.25+3.75=14.010.25+3.75=14.0; 14.0+7.2=21.214.0+7.2=21.2. So E[g(X)]=21.2E[g(X)] = 21.2 dollars. As a consistency check via linearity, note g(X)=10X−X2g(X) = 10X - X^2, so

E[g(X)]=10E[X]−E[X2].E[g(X)] = 10E[X] - E[X^2].

Compute E[X]=1(0.1)+2(0.05)+3(0.35)+4(0.05)+5(0.15)+6(0.30)=0.1+0.1+1.05+0.2+0.75+1.8=4.0E[X] = 1(0.1)+2(0.05)+3(0.35)+4(0.05)+5(0.15)+6(0.30) = 0.1+0.1+1.05+0.2+0.75+1.8 = 4.0. Compute E[X2]=1(0.1)+4(0.05)+9(0.35)+16(0.05)+25(0.15)+36(0.30)=0.1+0.2+3.15+0.8+3.75+10.8=18.8E[X^2] = 1(0.1)+4(0.05)+9(0.35)+16(0.05)+25(0.15)+36(0.30) = 0.1+0.2+3.15+0.8+3.75+10.8 = 18.8. Then 10E[X]−E[X2]=40−18.8=21.210E[X] - E[X^2] = 40 - 18.8 = 21.2, matching exactly — confirming both LOTUS and linearity are consistent computational routes to the same number, as the theorem guarantees.

Example 2: A continuous asymmetric density, LOTUS for a non-monotone transformation. Let XX have density f(x)=3x2f(x) = 3x^2 on [0,1][0,1] (and 00 elsewhere); check this integrates to 11: ∫013x2 dx=[x3]01=1\int_0^1 3x^2\,dx = [x^3]_0^1 = 1. Let Y=g(X)=(2X−1)2Y = g(X) = (2X-1)^2, a non-monotone (parabolic, folded) transformation of XX on [0,1][0,1], which is 0 at x=1/2x=1/2 and increases toward both endpoints. Rather than find the distribution of YY (which would require splitting into two branches around x=1/2x=1/2 and adding densities), LOTUS gives the answer directly:

E[Y]=∫01(2x−1)2⋅3x2 dx.E[Y] = \int_0^1 (2x-1)^2 \cdot 3x^2 \, dx.

Expand (2x−1)2=4x2−4x+1(2x-1)^2 = 4x^2 - 4x + 1, so the integrand is

3x2(4x2−4x+1)=12x4−12x3+3x2.3x^2(4x^2-4x+1) = 12x^4 - 12x^3 + 3x^2.

Integrate term by term over [0,1][0,1]:

∫0112x4 dx=125,∫0112x3 dx=3,∫013x2 dx=1.\int_0^1 12x^4\,dx = \frac{12}{5}, \qquad \int_0^1 12x^3\,dx = 3, \qquad \int_0^1 3x^2\,dx = 1.

So

E[Y]=125−3+1=125−2=12−105=25.E[Y] = \frac{12}{5} - 3 + 1 = \frac{12}{5} - 2 = \frac{12-10}{5} = \frac{2}{5}.

Thus E[(2X−1)2]=2/5=0.4E[(2X-1)^2] = 2/5 = 0.4. Notice how little work this required compared to deriving fYf_Y: LOTUS converted a change-of-variables problem (with a fold at x=1/2x=1/2, requiring fY(y)=f(x1)∣dx1/dy∣+f(x2)∣dx2/dy∣f_Y(y) = f(x_1)|dx_1/dy| + f(x_2)|dx_2/dy| for the two preimages) into a single polynomial integral against the known density of XX.

:::counterexample[Dropping absolute convergence breaks well-definedness of E[X]E[X]] The hypothesis of absolute convergence (not mere convergence, and not merely "the sum exists in some order") is essential, not a technicality. Consider a discrete random variable XX taking values xk=(−1)k+12kkx_k = (-1)^{k+1}\dfrac{2^k}{k} for k=1,2,3,…k=1,2,3,\dots with masses p(xk)=2−kp(x_k) = 2^{-k}; these masses sum to 11 since ∑k2−k=1\sum_k 2^{-k} = 1, so this is a legitimate pmf. Now attempt to compute E[X]E[X] term by term as ordinarily listed:

∑k=1∞xk p(xk)=∑k=1∞(−1)k+12kk⋅2−k=∑k=1∞(−1)k+1k=1−12+13−14+⋯=ln⁡2,\sum_{k=1}^\infty x_k\, p(x_k) = \sum_{k=1}^\infty (-1)^{k+1}\frac{2^k}{k}\cdot 2^{-k} = \sum_{k=1}^\infty \frac{(-1)^{k+1}}{k} = 1 - \frac12 + \frac13 - \frac14 + \cdots = \ln 2,

which looks like a perfectly good finite answer, ln⁡2≈0.693\ln 2 \approx 0.693. But this series is only conditionally convergent, not absolutely convergent: ∑k∣xk∣p(xk)=∑k1k=∞\sum_k |x_k| p(x_k) = \sum_k \frac{1}{k} = \infty (the harmonic series diverges). By the Riemann rearrangement theorem, a conditionally convergent series can be reordered to converge to any target real number, or to diverge, simply by listing its terms (+1,−1/2,+1/3,…+1, -1/2, +1/3,\dots) in a different order. Since the definition of E[X]E[X] as "the sum over all outcomes" makes no reference to an ordering of the countable outcome space (the underlying probability space has no built-in order on its sample points), the "value" ln⁡2\ln 2 obtained above is an artifact of one arbitrary enumeration of the xkx_k's and is not intrinsic to XX. This is exactly why the definition of E[X]E[X] requires absolute convergence: without it, the quantity is not well-defined as a property of the random variable, only of an incidental labeling of its outcomes. This is also why linearity, as proved above, explicitly assumed E∣X∣,E∣Y∣<∞E|X|, E|Y| < \infty: the rearrangement step in the proof is licensed only by absolute convergence, and dropping that hypothesis genuinely breaks the proof, not just its presentation.

Scope, edge cases & common traps

SituationWhat holdsWhat can fail
X,YX, Y dependent, both integrableE[aX+bY]=aE[X]+bE[Y]E[aX+bY]=aE[X]+bE[Y] alwaysE[XY]=E[X]E[Y]E[XY]=E[X]E[Y] generally fails without independence
X≥0X\ge 0 but E[X]=∞E[X]=\inftyExpectation may be declared +∞+\infty (e.g. St. Petersburg-type variables)The variable is not "integrable"; many downstream theorems (variance, CLT) require finiteness
Series/integral converges only conditionallyA numerical value can be computed by a specific orderingThat value is not intrinsic to XX; E[X]E[X] is undefined (see counterexample)
gg non-monotone or non-injectiveLOTUS still applies exactly as statedAttempting to find fg(X)f_{g(X)} first (instead of using LOTUS) is unnecessary extra work and error-prone
Mixed discrete/continuous XXDefinition extends via Riemann–Stieltjes/Lebesgue integral against the CDFNaively applying only the pure-discrete or pure-continuous formula misses part of the distribution

The mathematician behind it

Origins · 1 minChristiaan Huygens and how this was discovered
CH
Christiaan Huygens
1629–1695 · Dutch mathematician, physicist, astronomer

Huygens is credited with the first published systematic treatment of expected value, in his 1657 treatise De Ratiociniis in Ludo Aleae ("On Reasoning in Games of Chance"), building on correspondence between Pascal and Fermat concerning the fair division of stakes in interrupted games. Huygens framed expectation as the fair price to pay to enter a game with given prizes and probabilities — precisely the center-of-mass / fair-value intuition still used to introduce the concept today. His treatment predates a formal axiomatic theory of probability by nearly three centuries, yet his definition of "expectation" for finite games already matches, term for term, the discrete formula E[X]=∑xip(xi)E[X] = \sum x_i p(x_i) used throughout this article.

History
- 1654: Pascal and Fermat correspond on the "problem of points," implicitly computing weighted averages of outcomes.
- 1657: Huygens publishes De Ratiociniis in Ludo Aleae, formally defining expectation for games of chance.
- 1713: Jacob Bernoulli's Ars Conjectandi develops expectation further alongside the law of large numbers.
- 1814: Laplace's Théorie Analytique des Probabilités generalizes expectation to continuous distributions via integrals.
- 1933: Kolmogorov's axiomatization unifies discrete and continuous expectation as a single Lebesgue integral against a probability measure.
Why does expectation require absolute convergence rather than just convergence?

Expectation is defined as a sum or integral over the outcomes of a random variable, and the underlying sample space carries no intrinsic ordering. If the defining series converges only conditionally, the Riemann rearrangement theorem guarantees that reordering the very same terms can produce any target value, or even divergence. That would make "E[X]E[X]" depend on an arbitrary labeling of outcomes rather than on the random variable itself, which is unacceptable for a quantity meant to be an intrinsic property of XX. Requiring absolute convergence, E∣X∣<∞E|X| < \infty, guarantees the sum is independent of order, so E[X]E[X] is genuinely well-defined. This is why textbooks always state the integrability condition as a hypothesis, not an afterthought.

Does linearity of expectation require independence?

No — this is one of the most important and most frequently misunderstood facts in probability. The identity E[aX+bY]=aE[X]+bE[Y]E[aX+bY] = aE[X]+bE[Y] holds for any two random variables on the same probability space with finite expectations, no matter how strongly dependent they are. The proof only uses the joint distribution to marginalize back down to XX and YY individually, a step that works regardless of dependence structure. Independence becomes essential for a different identity, E[XY]=E[X]E[Y]E[XY] = E[X]E[Y], which genuinely fails in general when X,YX, Y are dependent. Confusing these two facts is one of the most common errors made when first learning expectation.

What is the point of LOTUS if I could just find the distribution of g(X)g(X) and use the ordinary expectation formula?

Finding the distribution of Y=g(X)Y = g(X) can be substantially harder than computing E[g(X)]E[g(X)] directly, especially when gg is non-monotone, non-injective, or complicated (as in Example 2, where g(x)=(2x−1)2g(x) = (2x-1)^2 folds the interval [0,1][0,1] onto itself). LOTUS bypasses that derivation entirely: it says you may plug g(x)g(x) straight into the known pmf or density of XX and sum or integrate, obtaining the same numerical answer with far less work and far less risk of a change-of-variables error, such as forgetting a Jacobian term or missing a branch of a non-monotone transformation.

Can expectation fail to exist even if XX is finite with probability 1?

Yes. A random variable can take only finite real values on every outcome, yet have E∣X∣=∞E|X| = \infty, so that E[X]E[X] is undefined (or assigned ±∞\pm\infty by convention in the one-signed case). The classical example is the St. Petersburg paradox: a fair-coin game paying 2k2^k dollars if the first head appears on flip kk, giving E[X]=∑k=1∞2k⋅2−k=∑k=1∞1=∞E[X] = \sum_{k=1}^\infty 2^k \cdot 2^{-k} = \sum_{k=1}^\infty 1 = \infty, even though any single play of the game yields a finite payout. This shows finiteness of XX pointwise is a weaker condition than integrability of XX, and the two must not be conflated.

How does expectation relate to variance and moment generating functions?

Expectation is the base operation from which both are built. The variance of XX is defined as Var(X)=E[(X−E[X])2]\mathrm{Var}(X) = E[(X - E[X])^2], itself an application of LOTUS with g(x)=(x−E[X])2g(x) = (x - E[X])^2, measuring the average squared deviation from the mean. The moment generating function is MX(t)=E[etX]M_X(t) = E[e^{tX}], again a direct LOTUS computation, and its derivatives at t=0t=0 recover all the moments E[Xn]E[X^n] of XX simultaneously. Both of these topics, Variance and Moments and Moment Generating Functions, are impossible to state or compute without the definition of expectation and the LOTUS machinery developed here.

Is expectation the same as the "most likely value" or the median?

No, and this is a common conceptual confusion. The mode is the value (or values) with the highest probability mass or density; the median is the value splitting the probability mass in half; the mean (expectation) is the probability-weighted average, i.e. the balance point. For skewed distributions these three can differ substantially — for instance, income distributions typically have mean well above the median because a small number of very large incomes pull the balance point upward, while leaving the "middle" (median) relatively unaffected.

Before this

Where this leads