= Law of the unconscious statistician
{title2=$\mathbb E[g(X)]=\int g(x)\,d\mu_X(x)$}
{wiki}
= Expected value rule
{synonym}
The <law of the unconscious statistician> computes the <expected value> of a <measurable function> of a <random variable> directly from the original <probability distribution>. If $g(X)$ is an <integrable random variable>, then
$$
\mathbb E[g(X)]=\int_{\mathbb R}g(x)\,d\mu_X(x).
$$
Use $\sum_xg(x)p_X(x)$ for a <probability mass function>, or $\int_{\mathbb R}g(x)f_X(x)\,dx$ for a <probability density function>. There is no need to derive the <probability distribution> of $g(X)$ first. The identity is the integration rule for a <pushforward measure>, and also holds with an infinite value when $g$ is nonnegative. https://ocw.mit.edu/courses/res-6-012-introduction-to-probability-spring-2018/pages/part-i-the-fundamentals/[Tsitsiklis, Introduction to Probability, Lecture 5: the expected value rule]{ref}.
For $X$ taking $-1,2,8$ with <probabilities> $1/2,3/10,1/5$, choosing $g(x)=x^2$ gives $\mathbb E[X^2]=\tfrac12+4\tfrac3{10}+64\tfrac15=14.5$. Its <variance> is therefore $14.5-1.7^2=11.61$. Squaring the <expected value> would instead give $2.89$, because squaring does not commute with averaging.
Back to article page