# Expectation of a discrete function of a continuous random variable

Suppose $X$ is a discrete random variable. Now, if some function $g(X)$ is a measurable function, then $g(X)$ is also a discrete random variable. In this case, we define the Expectation of the discrete random variable $g(X)$ in terms of $p_X(x)$ as $$E[g(X)] = \sum_{x : p_X(x) > 0} x \cdot p_X(x)$$

Suppose $X$ is a continuous random variable. Now, if some continuous function $g(X)$ is a measurable function, then $g(X)$ is also a continuous random variable. In this case, we define the Expectation of the continuous random variable $g(X)$ in terms of $f_X(x)$ as $$E[g(X)] = \int_{-\infty}^{+\infty} x \cdot f_X(x) dx$$

Now, suppose $X$ is a continuous random variable and if a function $g(X)$ is a measurable function, then $g(X)$ is also a random variable. If $g(\cdot)$ is a discrete function i.e. if $g(X)$ is a discrete random variable, then how is expectation of $g(X)$ defined in terms of $f_X(x)$?

• This is called the "law of the unconscious statistician": $E[g(X)]=\int_{-\infty}^\infty g(x) f_X(x) dx$. The fact that $g$ takes on discrete values doesn't change anything about this formula.
– Ian
Sep 6, 2018 at 15:14
• Okay. Thank you! You can write it as an answer so that I can accept it. Sep 6, 2018 at 15:41

$$E[g(X)]=\int_{-\infty}^\infty g(x) f_X(x) dx.$$
This holds for any measurable function $g$ and continuous random variable $X$. The fact that $g$ takes on discrete values doesn't change anything.