---
tag: 01ZWX875AT
kind: statement
role: theorem
name: Law of the unconscious statistician
aliases: [lotus, change-of-variables-formula-for-expectation]
msc: [60A05]
uses: [0DCT0QZVQ1, 0TST4MHA3A, 0WF4EJP91W, 04YG690N5V]
sources:
  - url: https://en.wikipedia.org/wiki/Law_of_the_unconscious_statistician
    locator: Measure-theoretic formulation
same_as:
  wikidata: Q6503509
  wikipedia: Law of the unconscious statistician
---

## Statement

Let $X$ be a random variable on $(\Omega, \mathcal{F}, P)$ with values in $(E, \mathcal{E})$ and with [[law|0TST4MHA3A]] $\mu_X$. Let $g \colon E \to \mathbb{R}$ be measurable.
Then $g(X)$ is integrable if and only if $\int_E |g| \, d\mu_X < \infty$. In that case,
$$E[g(X)] = \int_E g(x) \, \mu_X(dx).$$
In particular, if $X$ is discrete with [[mass function|0WF4EJP91W]] $p$, then $E[g(X)] = \sum_x g(x) \, p(x)$. If $X$ is real with [[density|04YG690N5V]] $f$, then $E[g(X)] = \int_{-\infty}^{\infty} g(x) f(x) \, dx$.

## Remarks

The formula also holds for $g \ge 0$ without any integrability condition, with both sides in $[0, \infty]$.
The proof checks the formula first for indicator functions $g = 1_B$, where it says $P(X \in B) = \mu_X(B)$. Then it extends to simple, nonnegative and integrable $g$.
The point is that one does not need the law of $g(X)$ to compute $E[g(X)]$.

## History

The name refers to statisticians who use the formula as the definition of $E[g(X)]$. They are "unconscious" that it is a theorem that needs a proof.

## Explanations

### L1 human

To find the average of $g(X)$, you can average $g(x)$ over the values $x$ of $X$ with their probabilities.
For a fair die, $E[X^2] = (1 + 4 + 9 + 16 + 25 + 36)/6 = 91/6$.
