Expectation as a Lebesgue Integral

The expectation of a random variable is an average over the sample space, weighted by probability. Made precise, it is nothing new: it is the Lebesgue integral of X taken against the probability measure \mathbb{P},

\mathbb{E}[X] \;=\; \int_{\Omega} X \, d\mathbb{P}.

That single line is the rigorous version of the expected value you met in statistics. Because it is the Lebesgue integral — slicing by value, not by input — expectation automatically inherits linearity, monotonicity and the convergence theorems, which is exactly what makes it behave so well under limits and conditioning later.

Probability is the expectation of an indicator

Start with the simplest random variable of all, the indicator \mathbf{1}_A of an event A — it reads 1 when A happens and 0 when it does not. As a simple function it has a single non-zero value, a_1 = 1 on the set A_1 = A, so its integral is forced by the simple-function definition:

\mathbb{E}[\mathbf{1}_A] \;=\; \int_{\Omega} \mathbf{1}_A \, d\mathbb{P} \;=\; 1 \cdot \mathbb{P}(A) \;=\; \mathbb{P}(A).

So probability is just the expectation of an indicator. This tiny identity, \mathbb{E}[\mathbf{1}_A] = \mathbb{P}(A), is the hinge on which the discrete formula below turns.

The discrete formula, derived

Suppose X takes finitely (or countably) many values x_1, x_2, \dots. Write \{X = x_k\} for the event that X lands on the value x_k. These events are disjoint and cover \Omega, so X is exactly the value-weighted stack of their indicators:

X \;=\; \sum_k x_k \, \mathbf{1}_{\{X = x_k\}}.

Take the expectation of both sides and push it through the sum by linearity:

\mathbb{E}[X] \;=\; \mathbb{E}\!\Big[\sum_k x_k \, \mathbf{1}_{\{X = x_k\}}\Big] \;=\; \sum_k x_k \, \mathbb{E}\!\big[\mathbf{1}_{\{X = x_k\}}\big]

by linearity of expectation (the constants x_k come out front). Now apply \mathbb{E}[\mathbf{1}_A] = \mathbb{P}(A) to each indicator, with A = \{X = x_k\}:

=\; \sum_k x_k \, \mathbb{P}(X = x_k) \;=\; \sum_k x_k \, p(x_k),

writing p(x_k) = \mathbb{P}(X = x_k) for the probability mass function. So the familiar "sum value times probability" is not a separate definition — it is the abstract integral, unpacked one indicator at a time.

The density formula, by pushforward

When X is continuous there are no atoms \{X = x\} of positive probability to sum over, so we change scenery from \Omega to the real line. The pushforward (law) \mathbb{P}_X records how much probability X sends to each Borel set, \mathbb{P}_X(B) = \mathbb{P}(X \in B), and the change-of-variables rule turns the integral over \Omega into an integral over \mathbb{R}:

\mathbb{E}[X] \;=\; \int_{\Omega} X \, d\mathbb{P} \;=\; \int_{\mathbb{R}} x \, d\mathbb{P}_X(x).

If X has a density f, meaning d\mathbb{P}_X(x) = f(x)\,dx, the last integral becomes the schoolbook formula; the discrete formula is the same identity with \mathbb{P}_X a sum of point masses p(x_k):

\mathbb{E}[X] = \int_{-\infty}^{\infty} x\, f(x)\, dx, \qquad \mathbb{E}[X] = \sum_k x_k\, p(x_k).

A fully worked mean: the fair die

Let X be the face of a fair six-sided die, so X \in \{1, 2, 3, 4, 5, 6\} with p(x_k) = \tfrac{1}{6} for every face. The discrete formula gives

\mathbb{E}[X] \;=\; \sum_{k=1}^{6} x_k\, p(x_k) \;=\; 1\cdot\tfrac16 + 2\cdot\tfrac16 + 3\cdot\tfrac16 + 4\cdot\tfrac16 + 5\cdot\tfrac16 + 6\cdot\tfrac16.

Factor out the common probability \tfrac16:

=\; \tfrac16\,(1 + 2 + 3 + 4 + 5 + 6).

Add the faces inside the bracket:

=\; \tfrac16 \cdot 21.

And divide:

=\; \tfrac{21}{6} \;=\; 3.5.

Notice the mean 3.5 is not a value the die can actually show — the expectation is the balance point of the distribution, not one of its outcomes.

For integrable random variables X, Y and scalars a, b: \mathbb{E}[aX + bY] \;=\; a\,\mathbb{E}[X] + b\,\mathbb{E}[Y], \qquad X \le Y \;\Rightarrow\; \mathbb{E}[X] \le \mathbb{E}[Y]. Both come for free from the construction of the integral: they are exactly its linearity and monotonicity, read with \mu = \mathbb{P}.

Two rules we lean on everywhere

Linearity deserves a second look, because it holds with no strings attached: \mathbb{E}[aX + bY] = a\,\mathbb{E}[X] + b\,\mathbb{E}[Y] even when X and Y are dependent. Monotonicity says a pointwise inequality survives averaging: if X \le Y everywhere then \mathbb{E}[X] \le \mathbb{E}[Y]. Together they are the workhorses of every later computation — splitting a payoff into pieces, bounding one quantity by another, or recognising probability as \mathbb{E}[\mathbf{1}_A] on demand.

To average a function g(X) you do not first need the distribution of g(X). The Law of the Unconscious Statistician says you may integrate g directly against the law of X:

\mathbb{E}[g(X)] \;=\; \int_{\mathbb{R}} g \, d\mathbb{P}_X \;=\; \int_{-\infty}^{\infty} g(x)\, f(x)\, dx

(the last step when X has density f; for a discrete X it is \sum_k g(x_k)\,p(x_k)). It is the pushforward of the previous card with x replaced by g(x) — "unconscious" because you use the density of X without ever finding the density of g(X).

And here is why linearity asks for no independence. Expectation is the integral \int_{\Omega} \cdot \, d\mathbb{P}, and an integral is additive for every pair of integrands — that is a property of the integral sign, not of any relationship between X and Y. Pointwise, (aX + bY)(\omega) = aX(\omega) + bY(\omega) at each \omega, so summing the values commutes with averaging them no matter how X and Y are coupled. Independence only becomes necessary for a product, \mathbb{E}[XY] = \mathbb{E}[X]\mathbb{E}[Y] — a fact about factorising the joint law, not about adding.