Tutorials › Statistical Theory I - Probability and Distribution Theory › Deriving LOTUS by Partitioning the Range

Expectation and LOTUS · Tutorial 307 of 994

Deriving LOTUS by Partitioning the Range

See why expectations of transformed variables can be calculated from the distribution of the original variable, and learn which conditions make the formulas valid.

Intermediate 10 min read

What You'll Learn

  • Derive discrete LOTUS by grouping the probability mass of outcomes that produce the same transformed value.
  • State when the discrete sum is nonnegative, finite, or absolutely convergent.
  • Derive density LOTUS using measurable partitions of the range and simple-function approximation.
  • Distinguish expectation from a symmetric principal-value calculation.
  • Apply the formulas to finite, countable, and continuous distributions.

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.

Definition: Let \(X\) be a real-valued random variable and let \(g:\mathbb{R}\to\mathbb{R}\) be Borel measurable. The transformed random variable is \(Y=g(X)\). If \(X\) is discrete with probability mass function \(p_X\), the discrete LOTUS formula is $$ E[g(X)] = \sum_{x} g(x)p_X(x). $$ If \(X\) has density \(f_X\) with respect to Lebesgue measure, the density LOTUS formula is $$ E[g(X)] = \int_{-\infty}^{\infty} g(x)f_X(x)\,dx. $$ For either formula, it is valid as an extended expectation when \(g\geq 0\); for a finite signed expectation, a sufficient condition is \(E[|g(X)|]<\infty\).

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\).

$$ P(Y=y)=\sum_{\substack{x\in S\\g(x)=y}}p_X(x). $$

If \(g\geq 0\), use the definition of expectation for a nonnegative discrete random variable and substitute this grouped probability:

$$ \begin{aligned} E[Y] &=\sum_{y\in T}yP(Y=y)\\ &=\sum_{y\in T}y\sum_{\substack{x\in S\\g(x)=y}}p_X(x)\\ &=\sum_{x\in S}g(x)p_X(x). \end{aligned} $$

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

$$ E[g(X)]=\sum_{x\in S}g(x)p_X(x), \qquad \sum_{x\in S}|g(x)|p_X(x)<\infty. $$

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

$$ E[g(X)]=1(0.6)+4(0.1)+9(0.3)=0.6+0.4+2.7=3.7. $$

Using the original values of \(X\) instead gives

$$ \sum_x g(x)p_X(x) =4(0.1)+1(0.2)+1(0.4)+9(0.3) =0.4+0.2+0.4+2.7 =3.7. $$

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

$$ P(g(X)=1)=\sum_{j=1}^{\infty}2^{-2j} =\frac{1/4}{1-1/4} =\frac13, \qquad P(g(X)=-1)=\sum_{j=0}^{\infty}2^{-(2j+1)} =\frac{1/2}{1-1/4} =\frac23. $$

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

$$ \begin{aligned} E[g(X)] &=\sum_{j=1}^{r}a_jP(X\in A_j)\\ &=\sum_{j=1}^{r}a_j\int_{A_j}f_X(x)\,dx\\ &=\int_{-\infty}^{\infty}g(x)f_X(x)\,dx. \end{aligned} $$

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

$$ q_m(t)=2^{-m}\left\lfloor 2^m\min(t,m)\right\rfloor, \qquad m=1,2,\ldots. $$

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\),

$$ E[q_m(g(X))] =\int_{-\infty}^{\infty}q_m(g(x))f_X(x)\,dx. $$

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:

Derived result: If \(X\) has density \(f_X\) and \(g:\mathbb{R}\to[0,\infty]\) is Borel measurable, then $$ E[g(X)]=\int_{-\infty}^{\infty}g(x)f_X(x)\,dx, $$ with both sides interpreted as nonnegative extended integrals.

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

$$ E[X^2]=\int_{-\infty}^{\infty}x^2\frac{1}{\sqrt{2\pi}}e^{-x^2/2}\,dx. $$

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

$$ \int_{-R}^{R}x^2\phi(x)\,dx =[-x\phi(x)]_{-R}^{R}+\int_{-R}^{R}\phi(x)\,dx. $$

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.

SituationCondition 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

$$ \int_0^\infty \frac{x}{\pi(1+x^2)}\,dx=\infty, \qquad \int_{-\infty}^0 \frac{|x|}{\pi(1+x^2)}\,dx=\infty. $$

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.

  1. For a discrete \(X\), explain why the outcomes contributing to \(P(g(X)=y)\) are precisely the values \(x\) satisfying \(g(x)=y\).
  2. Why does nonnegativity of \(g\) allow countable terms to be regrouped even if the expectation is infinite?
  3. What condition ensures that the signed discrete LOTUS sum can be regrouped without changing its value?
  4. In the density derivation, what role do the sets on which \(q_m(g(x))\) is constant play?
  5. Why does a symmetric principal value of zero not establish that a random variable has expectation zero?