Mathwords logoMathwords

Law of the Unconscious Statistician — Definition, Formula & Example

The Law of the Unconscious Statistician (LOTUS) is a shortcut for finding the expected value of a function of a random variable, such as X2X^2 or eXe^X. You weight each value g(x)g(x) by the probability of xx itself. You never need to work out the distribution of g(X)g(X).

Let XX be a random variable and gg a function. If XX is discrete with probability mass function pXp_X, then E[g(X)]=∑xg(x) pX(x)E[g(X)] = \sum_x g(x)\,p_X(x). If XX is continuous with probability density function fXf_X, then E[g(X)]=∫−∞∞g(x) fX(x) dxE[g(X)] = \int_{-\infty}^{\infty} g(x)\,f_X(x)\,dx. In both cases the sum or integral must converge absolutely. The result is a theorem, not a definition. By definition, E[g(X)]E[g(X)] uses the distribution of the new variable Y=g(X)Y = g(X), and LOTUS shows you get the same number using the distribution of XX. The name is a joke: people use it so naturally that they forget it needs proof.

Key Formula

E[g(X)]=∑xg(x) pX(x)orE[g(X)]=∫−∞∞g(x) fX(x) dxE[g(X)] = \sum_{x} g(x)\,p_X(x) \qquad\text{or}\qquad E[g(X)] = \int_{-\infty}^{\infty} g(x)\,f_X(x)\,dx
Where:
  • XX = The original random variable
  • gg = The function applied to X, such as squaring
  • pX(x)p_X(x) = Probability mass function of X (discrete case)
  • fX(x)f_X(x) = Probability density function of X (continuous case)
  • E[g(X)]E[g(X)] = Expected value of the transformed variable g(X)

Worked Example

Problem: A machine cuts square floor tiles. The side length XX (in inches) is 1, 2, or 3 with probabilities 0.5, 0.3, and 0.2. Find the expected area of a tile.
Step 1: The area is a function of the side length, so set g(x)=x2g(x) = x^2. You want E[X2]E[X^2].
E[Area]=E[g(X)]=E[X2]E[\text{Area}] = E[g(X)] = E[X^2]
Step 2: Apply LOTUS. Square each side length and weight it by that length's own probability. You do not need a separate table for the area.
E[X2]=12(0.5)+22(0.3)+32(0.2)=0.5+1.2+1.8=3.5E[X^2] = 1^2(0.5) + 2^2(0.3) + 3^2(0.2) = 0.5 + 1.2 + 1.8 = 3.5
Step 3: Check against the tempting shortcut of squaring the mean. It gives a different, incorrect value.
E[X]=1(0.5)+2(0.3)+3(0.2)=1.7,(E[X])2=2.89≠3.5E[X] = 1(0.5) + 2(0.3) + 3(0.2) = 1.7, \qquad (E[X])^2 = 2.89 \neq 3.5
Answer: The expected tile area is 3.5 square inches.

Why It Matters

LOTUS is the standard way to compute variance, Var⁡(X)=E[X2]−(E[X])2\operatorname{Var}(X) = E[X^2] - (E[X])^2, and moment generating functions, E[etX]E[e^{tX}], in a college probability course. Actuaries and engineers use it to find the expected cost or payoff E[g(X)]E[g(X)] when only the distribution of the underlying quantity XX is known.

Common Mistakes

Mistake: Computing E[g(X)]E[g(X)] as g(E[X])g(E[X]), for example squaring the mean to get an expected area of 1.72=2.891.7^2 = 2.89.
Correction: In general E[g(X)]≠g(E[X])E[g(X)] \neq g(E[X]). The two agree for every distribution only when gg is linear, g(x)=ax+bg(x) = ax + b. Apply gg to each value first, then average with the probabilities.

Related Terms