# When does improper Riemann integration fail for computing expected values?

Riemann integration requires bounded intervals of integration. However, some continuous random variables (like those from the normal or gamma distribution) have unbounded support sets.

For these 2 distributions, would improper Riemann integrals be sufficient to get their expected values? If not, why not?

Usually, improper Riemann integration will correctly provide the expectation of a continuous random variable with an unbounded support. Where you will usually encounter problems with improper Riemann integrals is when the integral of interest does not converge absolutely. In this case the improper integral may have some value, but this value has limited probabilistic meaning; for example the law of large numbers doesn't necessarily hold.

As an example of this to get a feel for it, you can look at the evaluation of the expected value of $$X \sin(X)$$ where $$X$$ has PDF $$\frac{1}{x^2}$$ on $$[1,\infty)$$ and $$0$$ otherwise. This expectation is formally $$\int_1^\infty \frac{\sin(x)}{x} dx$$ which has a value in improper Riemann integration. But actually this random variable will not satisfy the law of large numbers, as you can observe numerically, so it doesn't make a whole lot of sense to say that it has an expected value.

Indeed, if you have Matlab or Octave, try running the following:

x=1./rand(1000,1);
plot(cumsum(x.*sin(x))./(1:1000)');


This shows sample means from this distribution for progressively larger samples, and you see that they don't converge. (Off-topic: the weird 1/rand trick being used there is called the probability integral transformation, which is extremely useful for numerical work in probability.)

Note that this will never be a problem for a random variable of one sign such as your example of the Gamma distribution. It is also not a problem for the normal distribution.

The exception to the second "usually" above is when the improper Riemann integral doesn't exist but the Lebesgue integral does. This is a pretty uncommon situation in practice.

• @Iterator516 No, the integrals in both of those cases converge absolutely. – Ian Oct 30 at 15:30
• Awesome! Thank you! – Iterator516 Oct 30 at 15:30
• I mistakenly deleted my initial question to Ian. I asked if the integrals for the expectations of the normal and the gamma distributions do converge. – Iterator516 Oct 30 at 16:29