Law of a random variable (characterization)

If $X$ is a real random variable defined on $(\Omega,\mathcal{F},\mathbf{P})$ then there exist several characterizations of the law of $X$ being $\mu$ :

$X \sim \mu$ if and only if for every $\{...\}$ function $f:\mathbb{R}$ $\to \mathbb{R}$ we have $\mathbf{E}[f(X)]=\int_{\mathbb{R}}f(x)d\mu$.

where $\{...\}$ may be measurable positive, measurable bounded, continuous bounded, continuous compactly supported.

Why we cannot take a test function $f$ that is only supposed to be continuous ? Is the integrability of $f(X)$ the only problem that arises ?

You could require $f$ to only be continuous, but the idea is to have as few test functions as possible to satisfy the definition. Another way to say this is, the above possible values for $\{...\}$ are equivalent to the requirement that the equality holds for continuous functions.
Here is a proof of that for the continuous bounded characterization. On one hand, if the equality holds for all continuous functions it holds for just bounded ones. In the other direction, suppose $f$ is continuous, we want to show: $$E[f(X)] = \int_{\mathbb{R}} f(x) d\mu$$ First let $f^+$ be the positive part of $f$: $f^+(x) = f(x)\chi_{\{f(x) \geq 0 \}}$. Define $f_n$ to be $f^+$ restricted to $[0, n]$ via: $$f_n(x) = \min\{f(x), n\}$$ Then $f_n \to f$ and by the monotone convergence theorem: $$E[f^+(X)] = \int_{\mathbb{R}} f^+(x) d\mu$$ We can apply the same technique for the negative part of $f$.
• What if both $\mathbf{E}[f^{+}(X)]$ and $\mathbf{E}[f^{-}(X)]$ are infinite ? You wouldn't be able to conclude by linearity since $\infty - \infty$ is not defined. Aug 30, 2015 at 15:13
• @Nocturne: For reference: en.wikipedia.org/wiki/Lebesgue_integration A general function is defined as being Lebesgue integrable only if both the positive and negative parts are integrable (as positive functions). (Or equivalently, $\int_\mathbb{R} |f| d\mu$ is integrable. Therefore, if either of them are infinite, $\int_\mathbb{R}$ is not well defined. But then, neither is $E[|f(X)|]$ by the above calculation. So the LHS is also in the same state. Aug 30, 2015 at 15:21
• @Nocturne - Alternatively, you can just require that $$E[f(X)] = \int_\mathbb{R} f(x) d\mu$$ for any $f$ that is continuous and integrable. Aug 30, 2015 at 15:29
• Thanks. That's why I asked if integrability of $f(X)$ was the only obstacle in considering test functions that are only supposed to be continuous. Aug 30, 2015 at 15:32