# Expected value of a composition random variable

Given a countable sample space $\Omega$ and a (discrete) random variable $X:\Omega\to\mathbb{R}$, let $f_X:\mathbb{R}\to [0,1]$ be a probability function of $X$, that is, $f_X(x):=P(\{s\in\Omega\mid X(s)=x\})$ where $P$ is a probability distribution. We define the expected value of $X$ by $E(X):=\Sigma_{x} xf_X(x)$.

If $g:\mathbb{R}\to\mathbb{R}$ is a function with $im(X)\subseteq dom(g)$, then clearly $g(X):\Omega\to\mathbb{R}$ is also a random variable. But I don't understand why $E(g(X))=\Sigma_{x}g(x)f_X(x)$?

$E(g(X))=\Sigma_{x}xf_{g(X)}(x) = \Sigma_{x}xP(\{s\in\Omega\mid g(X(s))=x\})$, but how do I progress from here?

Should I perhaps define the probability distribution as a function $P:\mathbb{P}(\Omega)\to[0,1]$ satisfying the probability axioms and attempt to work something out from there?

• Is the question why: $E(g(X))=\Sigma_{x}g(x)f_X(x)=^?\Sigma_{x}xf_{g(X)}(x)$ – zoli Mar 1 '18 at 21:51
• Are you familiar with measure theory? The result follows from a transformation rule concerning the pushforward measure induced by $X$ on $\mathbb{R}$. – Joker123 Mar 1 '18 at 21:53
• @zoli the question mark is on the first equality. – Sid Caroline Mar 1 '18 at 21:53
• @Joker123 No I'm not familiar with measure theory, but I would still like to know the proof. – Sid Caroline Mar 1 '18 at 21:55

Continuing where you left off, $$\Sigma_{x\in\text{Im}(g)}xP(\{s\in\Omega\mid g(X(s))=x\})=\Sigma_{x\in\text{Im}(g)} xf_X(g^{-1}(x))=\Sigma_{x\in\text{Im}(X)}g(x)f_X(x).$$ The last equality follows since as $x$ ranges over the image of $g$, $g^{-1}(x)=\{u\in \text{Im}(X):g(u)=x\}$ partitions the image of $X.$

The random variable $X$ applies probability

$\{f_X(x_1),f_X(x_2),f_X(x_3),....\}$

to the values

$\{x_1,x_2,x_3,....\}$.

This also means that if you were to apply $g(x)$ to random variables sampled from $X$, i.e. $g(X)$, that you would apply the same probabilities:

$\{f_X(x_1),f_X(x_2),f_X(x_3),....\}$

to the values

$g(\{x_1,x_2,x_3,....\}) = \{g(x_1),g(x_2),g(x_3),...\}$

So instead of summing over the values $\{x_1,x_2,x_3,....\}$ weighted by their probabilities, we sum over the corresponding values $\{g(x_1),g(x_2),g(x_3),...\}$ weighted by their probabilities. However, these probabilities are the same as the corresponding weights for $\{x_1,x_2,x_3,....\}$.

This gives us that $E[g(X)] = \sum_x g(x) f_X(x)$.

A simpler way to think of this is that if you sampled $x_1 \sim X$, then you sampled $g(x_1) \sim g(X)$. This gives you that $g(X)$ has the same probabilities as $X$, just mapped to whatever value $g(x)$ maps $x$ to.

Thus $\{g(x_1),g(x_2),g(x_3),...\}$ all occur with corresponding probabilities $\{f_X(x_1),f_X(x_2),f_X(x_3),....\}$.