# What does it mean that an expected value does not exist?

$X$ is a random variable with pdf $f$ and $g: \mathbb R \to \mathbb R$ is a measurable function. Before I start operating with $E[g(X)]$ I need to show that it exists. What does it take to show it?

1) Do I need to show that $\forall a \in \mathbb R$ and $\forall b \in \mathbb R$, $a \le b$, $\int_{a}^{b}g(x)f(x)dx$ exists (i.e. $g(x)f(x)$ are Riemann integrable on any interval)?

2) Or I need to show that $\lim_{z \to \infty}\int_{c}^{z}g(x)f(x)dx + \lim_{z \to -\infty}\int_{z}^{c}g(x)f(x)dx=a \in \mathbb R$ (i.e. $a \ne \infty$ and $a \ne -\infty$) (because 1 is somehow automatically true)?

3) Or both?

Basically what can go so wrong that an expected value does not exists?

• Consider a Cauchy random variable. Its expecation does not exist, as $\int_{[-\infty,\infty]} xf(x)dx$ is not defined as $f(x)\sim \frac{1}{\pi x^2}$ when $x\to\infty$. Jan 31, 2015 at 17:03
• @ClementC. But $\int_a^b xf(x)$ still can be calculated for any $a,b \ne \infty$ or $-\infty$, right? So the problem here is that the improper integral does not converge, not because the Riemann integral does not exists on an interval. My question is: can it be that an expected value does not exist because the Riemann integral does not exist on an interval (and not because the improper integral does not converge)?
– zesy
Jan 31, 2015 at 17:10
• For the expected value to exist, you need $x\mapsto x f(x)$ to be integrable on $\mathbb{R}$, in the sense of Lebesgue. Improper integrals or integrability on any fixed $[a, b]$ are not good enough. Jan 31, 2015 at 17:17
• See one of the answers (with blue diagram) to the question math.stackexchange.com/questions/1125087/….
– zoli
Jan 31, 2015 at 17:41
• See me answer here: stats.stackexchange.com/questions/94402/… May 29, 2017 at 1:01

If your random variable $X$ is $\mathbb{R}$-valued, then you need to show that the integral over the whole of $\mathbb{R}$ exists. Note that from this you will also be able to conclude that the integral over any $[a,b]$ will also exist.
• Thanks for the answer. I guess I needed to formulate my question clearer. What I meant to ask is whether it is guaranteed that $\int_{a}^{b}g(x)f(x)dx$ always exists $\forall a,b \ne (+-)\infty, a<b$ or it might be that an expected value fails to exist because for certain $a,b \ne (+-)\infty$ $\int_{a}^{b}g(x)f(x)dx$ does not exist.
The problem is that you can't deal with $E[g(X)]$ if this number is not defined. So what does it take in order to define the expectation of a random variable? If $Y \geq 0$ is measurable, then we can always define $E[Y]$, though it may be infinite. For a general $Y$ we can split it up into $Y= Y^+ - Y^-$, where $Y^+ = \max\{Y,0\}$ and $Y^- = \max\{-Y,0\}$. Since $Y^+$ and $Y^-$ are nonnegative, we can always define $E[Y^+]$ and $E[Y^-]$. It is then natural to define $E[Y] := E[Y^+]- E[Y^-]$. This is exactly what we do, and it makes sense as long as we haven't just written $\infty-\infty$. As long as at least one of the terms is finite we are okay in defining $E[Y]$. Now to $E[g(X)]$, $Y:= g(X)$ is a random variable, and if $g \geq 0$ we don't have to worry, but it may be that both $E[Y^+]=E[Y^-] = \infty$ even if $E[|X|]<\infty$ if $g$ is nasty enough.
So how can we tell if $E[g(X)]$ exists? The easiest thing to do is to show $E[|g(X)|]<\infty$. This is equivalent to $E[g(X)^+],E[g(X)^-]<\infty$, and since $|g(X)|$ is nonnegative, we know $E[|g(X)|]$ is at least defined. Less commonly, show directly that at least one of $E[g(X)^+]$ and $E[g(X)^-]$ is finite. Here's where the fact that $X$ has a pdf comes in. If $h \geq 0$, then $E[h(X)]$ is always defined and equals $\int_{-\infty}^{\infty} h(x) f_X(x)dx$. Now we can use this with $h = |g|$ or $g^+$ or $g^-$ to actually compute $E[|g(X)|]$ or $E[g(X)^+]$ or $E[g(X)^-]$ and show at least one is finite.