Why Partitioning Gives LOTUS
A function \(g\) can send several possible values of \(X\) to the same value of \(g(X)\). To find the distribution of \(g(X)\), one groups together the outcomes that have the same image. The expectation of \(g(X)\) can then be found either by summing over the values of \(g(X)\), or by keeping the original values of \(X\) and weighting each by \(g(X)\). LOTUS—the Law of the Unconscious Statistician—states that these calculations agree.
The key point is that the formula does not require us first to find a probability mass function or density for \(g(X)\). The derivation does, however, require care about how the sums or integrals are grouped. For nonnegative functions, terms can be regrouped without changing their sum, even when the result is infinite. For signed functions, absolute integrability is a standard sufficient condition.
The sums run over the support of \(X\), or equivalently over all possible values with zero-mass terms omitted. The integral runs over the real line; values outside the support contribute zero because the density is zero there. In either case, the argument of the function is a value of \(X\), while the probability weight comes from the distribution of \(X\).
The Discrete Derivation: Grouping Equal Images
Suppose \(X\) is discrete, with countable support \(S=\{x:p_X(x)>0\}\), and define \(Y=g(X)\). The possible values of \(Y\) form the countable set \(T=\{g(x):x\in S\}\). For a particular \(y\in T\), the event \(Y=y\) consists of every outcome \(X=x\) such that \(g(x)=y\). These outcomes need not form a single value of \(X\).
If \(g\geq 0\), use the definition of expectation for a nonnegative discrete random variable and substitute this grouped probability:
The last equality is a regrouping of nonnegative terms: each \(x\in S\) appears exactly once, in the group indexed by \(y=g(x)\). Countable sums of nonnegative terms are independent of the order of summation, so this argument remains valid if the expectation is infinite.
For signed \(g\), apply the same reasoning to \(g^+(x)=\max(g(x),0)\) and \(g^-(x)=\max(-g(x),0)\). If \(E[|g(X)|]<\infty\), then both \(E[g^+(X)]\) and \(E[g^-(X)]\) are finite. Their difference is well-defined, and subtracting the two nonnegative identities gives
The displayed absolute-convergence condition ensures that regrouping positive and negative contributions cannot change the value of the sum. More generally, an extended expectation is defined if at least one of \(E[g^+(X)]\) and \(E[g^-(X)]\) is finite. If both are infinite, the expectation is undefined.
Worked Example: Grouping a Finite Discrete Distribution
Let \(X\) take values \(-2,-1,1,3\) with probabilities \(0.1,0.2,0.4,0.3\), respectively, and let \(g(x)=x^2\). Calculate \(E[g(X)]\) by grouping outcomes with the same transformed value, and then check it using the discrete LOTUS sum.
The values \(-1\) and \(1\) both map to \(1\), with combined probability \(0.2+0.4=0.6\). The other transformed values are \(g(-2)=4\), with probability \(0.1\), and \(g(3)=9\), with probability \(0.3\). Thus
Using the original values of \(X\) instead gives
The two calculations agree because the two outcomes mapping to \(1\) contribute together, whether they are grouped before or after weighting by their transformed value.
Worked Example: An Infinite Discrete Partition
Let \(P(X=k)=2^{-k}\) for positive integers \(k=1,2,\ldots\), and set \(g(k)=(-1)^k\). The probabilities sum to one because \(\sum_{k=1}^{\infty}2^{-k}=1\). The transformed variable takes only the values \(-1\) and \(1\).
The even and odd values of \(k\) give the two groups. Their probabilities are
Therefore \(E[g(X)]=1(1/3)+(-1)(2/3)=-1/3\). Directly, LOTUS gives \(\sum_{k=1}^{\infty}(-1)^k2^{-k}=-1/2+1/4-1/8+\cdots=-1/3\). This regrouping is legitimate: \(\sum_k |g(k)|2^{-k}=\sum_k2^{-k}=1<\infty\), so the signed series is absolutely convergent.
The Density Derivation: Partitioning the Range
Now suppose \(X\) has density \(f_X\). Let \(g\) be Borel measurable; this ensures that the sets used below are measurable. For a function \(g\) that takes only finitely many nonnegative values \(a_1,\ldots,a_r\), define \(A_j=\{x:g(x)=a_j\}\). These sets partition the possible values of \(X\) according to the value of \(g(X)\). On each set, \(g(X)\) is constant, so
This establishes the formula for a nonnegative function with finitely many values. To extend it to any nonnegative measurable \(g\), approximate its range by finer partitions. For \(t\geq 0\), define
Each \(q_m\) takes finitely many nonnegative values. The grid spacing shrinks as \(m\) increases, the cap at \(m\) moves upward, and the grids are nested; consequently \(q_m(t)\) increases to \(t\) for every \(t\geq0\). The values of \(q_m(g(X))\) partition outcomes into sets according to which range interval contains \(g(X)\). Applying the finite-valued identity to \(q_m\circ g\) gives, for every \(m\),
Both sides have nonnegative integrands, and \(q_m(g(X))\uparrow g(X)\). The Monotone Convergence Theorem applies on the probability space for the expectation and on the real line with measure \(f_X(x)\,dx\) for the integral. Taking limits proves the nonnegative density formula, allowing either side to be infinite:
For signed \(g\), apply the nonnegative result to \(g^+\) and \(g^-\). If \(\int |g(x)|f_X(x)\,dx<\infty\), then both resulting integrals are finite, and subtracting gives the density LOTUS formula. This condition is exactly \(E[|g(X)|]<\infty\). It makes the signed integral absolutely convergent and the expectation finite.
Worked Example: The Square of a Standard Normal Variable
Let \(X\sim N(0,1)\) and \(g(x)=x^2\). Since \(g\geq0\), the density version of LOTUS applies even before we know the value of the integral. The standard normal density is \(f_X(x)=(2\pi)^{-1/2}e^{-x^2/2}\), so
Write \(\phi(x)=(2\pi)^{-1/2}e^{-x^2/2}\). Differentiating gives \(\phi'(x)=-x\phi(x)\), so \(x^2\phi(x)=-x\phi'(x)\). Integration by parts on \([-R,R]\) yields
As \(R\to\infty\), the boundary term tends to zero because \(R\phi(R)\to0\), while the remaining integral tends to \(1\), since \(\phi\) is a probability density. Hence \(E[X^2]=1\). The calculation uses the density of \(X\) directly; it does not require deriving the density of \(X^2\).
Conditions, Interpretation, and a Common Pitfall
The discrete and density formulas have the same structure, but the conditions on the underlying distribution differ in form. In the discrete case, probability mass is summed over values of \(X\); in the density case, probability is integrated against \(f_X(x)\). In both cases, measurability is needed so that the relevant events and integrals are defined. Borel measurability of \(g\) is a convenient standard condition for a real-valued random variable.
| Situation | Condition on \(g\) | Meaning of the LOTUS result |
|---|---|---|
| Discrete \(X\) | \(g(X)\geq0\) | The sum is valid as a nonnegative extended sum. |
| Discrete \(X\) | \(\sum_x|g(x)|p_X(x)<\infty\) | The signed sum converges absolutely and gives a finite expectation. |
| Density \(f_X\) | \(g\geq0\) | The integral is valid as a nonnegative extended integral. |
| Density \(f_X\) | \(\int |g(x)|f_X(x)\,dx<\infty\) | The signed integral converges absolutely and gives a finite expectation. |
A common mistake is to calculate a signed integral by symmetry even when its positive and negative parts both diverge. For example, let \(X\) have the standard Cauchy density \(f_X(x)=1/(\pi(1+x^2))\) and take \(g(x)=x\). Symmetry might suggest that the expectation is zero. But
Thus \(E[X^+]=E[X^-]=\infty\), so \(E[X]\) is undefined. The symmetric principal value, obtained by integrating over \([-R,R]\) and then taking \(R\to\infty\), is zero, but that is not the expectation. Ordinary expectation does not permit cancellation between two infinite quantities.
LOTUS matters because calculating \(E[g(X)]\) directly from \(X\)'s distribution is often simpler than finding the distribution of \(g(X)\) first. The partition argument explains why: it merely groups the original outcomes according to their transformed values, and under the stated conditions that grouping preserves the total expectation.
Check Your Understanding
Use the partition argument and the stated integrability conditions to answer these questions.
- For a discrete \(X\), explain why the outcomes contributing to \(P(g(X)=y)\) are precisely the values \(x\) satisfying \(g(x)=y\).
- Why does nonnegativity of \(g\) allow countable terms to be regrouped even if the expectation is infinite?
- What condition ensures that the signed discrete LOTUS sum can be regrouped without changing its value?
- In the density derivation, what role do the sets on which \(q_m(g(x))\) is constant play?
- Why does a symmetric principal value of zero not establish that a random variable has expectation zero?