TITLE: Proving the Law of the Unconscious Statistician
QUESTION [14 upvotes]: The proof seems a little too easy.  I am wondering if I misunderstood something. 

Let $Y = g(X)$. Prove the $$\mathbb E(Y) = \sum_x g(x)f_x(x)$$
  provided that the sum converges absolutely.

By definition: $\mathbb E(Y) = \sum_y yf_y(y)$. Since $g^{-1}(y) = \{x_1, x_2,\dots\}$ $$f_y(y) = \mathbb P(Y=y) = \sum_i \mathbb P(X=x_i)$$ where $g(x_i) = y$. Hence $$\mathbb E(Y) = \sum_y y \sum_i \mathbb P(x_i) = \sum_y \sum_i g(x_i) \mathbb P(x_i) = \sum_i g(x_i) \mathbb P(x_i) = \sum_x g(x)f_x(x)$$
My understanding is that you need to capture every single $x_i \in g^{-1}(y)$. Repeat the process for every $y$ and then add up the terms.

REPLY [2 votes]: I found this pretty confusing myself until I spelled it out for myself in slow motion (using Iverson brackets to simplify the bounds on the summations):
\begin{align}
\mathbb EY &= \mathbb Eg(X)\\
&= \sum_z z \cdot \mathbb P(g(X) = z) &&\text{Definition of expected value}\\
&=\sum_z z\sum_w \mathbb P(X=w)[g(w) = z] &&\text{Sum probability of basic events s.t. $g(w) = z$}\\
&=\sum_z\sum_w z\cdot \mathbb P(X=w)[g(w)=z] &&\text{Distribute the $z$}\\
&=\sum_w\sum_z z\cdot \mathbb P(X=w)[g(w)=z] &&\text{Associativity: swap order of summation}\\
&=\sum_w\sum_{z = g(w)}g(w)\cdot \mathbb P(X=w) &&\text{Non-zero inner sum occurs when $z = g(w)$}\\
&=\sum_w g(w)\cdot \mathbb P(X=w)\sum_{z = g(w)}1 &&\text{Inner product depends only on $w$; factor it}\\
&=\sum_w g(w)\cdot \mathbb P(X=w) &&\text{$z$ takes on one value so the inner sum is trivially 1}
\end{align}