Canonical: https://knowlpedia.com/probability/expectation-function-of-rv/

# Expectation of a function of a random variable

Compute the expectation of a transformed random variable using the distribution of the original.

**Law of the unconscious statistician:** Let \(X:\Omega\to S\) be a [random variable](https://knowlpedia.com/probability/random-variable/) with [distribution (law)](https://knowlpedia.com/probability/distribution-law/) \(\mu_X\) on \((S,\mathcal S)\). If \(g:S\to\mathbb R\) is [measurable](https://knowlpedia.com/measure-theory/measurable-function/) and \(g(X)\) is integrable, then
\[
\mathbb E[g(X)] = \int_\Omega g(X(\omega))\,d\mathbb P(\omega) = \int_S g(x)\,\mu_X(dx).
\]

## Remarks

This identity lets you compute expectations by integrating against the distribution of \(X\) rather than over the original [probability space](https://knowlpedia.com/probability/probability-space/). When \(\mu_X\) has a [density](https://knowlpedia.com/probability/probability-density-function/) with respect to [Lebesgue measure](https://knowlpedia.com/measure-theory/lebesgue-measure/) (via the [Radon–Nikodym theorem](https://knowlpedia.com/probability/radon-nikodym-theorem/)), the right-hand side becomes an ordinary integral of \(g(x)\) against that density.
