Existence of expected value of function

According to Wikipedia, the expected value of a continuous random variable is

$$E[X] = \int_{-\infty}^{\infty} xf(x) \mathrm{d}x.$$

Suppose $f$ is a function such as $f:\mathbb{R}\rightarrow (a,b)$. Is the expected value then undefined, since $f$ does not exist for $x < a$ or $x > b$?

• You seem to be confused about the difference between the expected value of a random variable and the expected value of a function of a random variable. If $X$ is a random variable with probability density function $f$ (which must be defined on $-\infty < x < \infty$, then $E[g(X)]=\int_{-\infty}^{\infty} g(x)f(x)dx$. Aug 15, 2015 at 18:13
• The $f$ in the statement is the probability density of the random variable $X$. So long as that's true, it doesn't really matter what $f$ looks like.
– KOE
Aug 15, 2015 at 18:14
• If the random variable is restricted to (a,b) then the density, $f$, outside that range will be defined to be 0. So there's no difficulty; $f$ is defined outside the range of possible values for the variable -- it is 0 everywhere else. Aug 16, 2015 at 0:18

If you define the function the way you did, $f(x)$ does exist for $x < a$ and $x>b$. Perhaps you mean a function $g:(a,b) \to \mathbb{R}$, where the domain is a bounded interval. In that case, $g(x)$ is assumed to equal $0$ for all $x \notin (a,b)$. An example is the Beta distribution, which is defined by a probability density function on the interval $(0,1)$ and $0$ elsewhere. The Beta distribution has an expected value, so the fact that the pdf is not defined for all elements of $\mathbb{R}$ does not imply the function does not have an expected value.