> [!theorem]
>
> Let $X$ be a discrete [[Random Variable|random variable]] on a [[Probability|probability space]] $(\Omega, \cf, P)$, $\seq{x_i}$ such that $\sum_{i \in \nat}P(X = x_i) = 1$, and $g: \real \to \real$ be a [[Function|function]].
> Define $Z = g(X)$, where $Z(\omega) = g(X(\omega))$. Then $g$ may be pushed inside of the [[Expectation|expectation]]:
> $
> \ev{(g(X))} = \sum_{i \in \nat}g(x_i)P(X = x_i)
> $
> *Proof*. First note that
> $
> P(Z = z) = \sum_{x \in g^{-1}(z)}P(X = x)
> $
> where only a countable number of values in $g^{-1}(z)$ have strictly positive probability. Now let $\seq{z_i}$ such that $\sum_{i \in \nat}P(Z = z_i) = 1$, then
> $
> \sum_{i \in \nat}P(Z = z_i) = \sum_{i \in \nat}\sum_{X \in g^{-1}(z_i)}P(X = x) = 1
> $
> where the $x$s can be taken as a countable collection whose probabilities add up to $1$. So,
> $
> \begin{align*}
> \ev{(Z)} &= \sum_{i \in \nat}z_iP(Z = z_i) \\
> &= \sum_{i \in \nat}z_i\sum_{x \in g^{-1}(z_i)}P(X = x)\\
> &= \sum_{i \in \nat}\sum_{x \in g^{-1}(z_i)}z_iP(X = x)\\
> &= \sum_{i \in \nat}\sum_{x \in g^{-1}(z_i)}g(x)P(X = x) \\
> &= \sum_{i \in \nat}g(x_i)P(X = x_i)
> \end{align*}
> $
> where the last inequality is obtained since $\ev$ is well-defined.