# Expected value of a continuous random variable.

I have come across a proof of the following in Ross's book on Probability -

For a non-negative continuous random variable Y with a probability density function $f_Y$ $$\mathrm{E} [Y] = \int_0^\infty P[Y \geq y]dy$$

The author proves it by using

$$\int_0^\infty \int_y^\infty f_Y(x)dxdy = \int_0^\infty (\int_0^x dy) f_Y(x)dx$$

He refers to it as "interchanging the order of integration". I have studied a fair amount of Calculus from Apostol's books (Vol 1 & 2). But I still can't seem to provide a proof of this equation. How does one go about proving this last equation?

-

we have \begin{align*} \int_{[0,\infty)}\int_{[y,\infty)} f_Y(x)\; dx\, dy &= \int_{[0,\infty)}\int_{[0,\infty)}\chi_{[y,\infty)}(x)f_Y(x)\;dx\,dy\\ &= \int_{[0,\infty)}\int_{[0,\infty)}\chi_{[y,\infty)}(x)f_Y(x)\;dy\,dx\\ &= \int_{[0,\infty)}\int_{[0,\infty)}\chi_{[y,\infty)}(x)\;dy\cdot f_Y(x)\;dx\\ &= \int_{[0,\infty)} \int_{[0,\infty)} \chi_{[0,x]}(y)\; dy\cdot f_Y(x)\; dx\\ &= \int_{[0,\infty)} xf_Y(x)\; dx\\ &= E(Y) \end{align*} where $\chi_A$ denotes the indicator function of a set $A$.

-
Thanks martini. I am trying to understand how you got from $$\int_{[0,\infty)}\chi_{[y,\infty)}(x)\;dy$$ to $$\int_{[0,\infty)} \chi_{[0,x]}(y)\; dy$$ In the first integral $\chi_{[y,\infty)}$ is a whole family of functions and not just one function? – user869081 Jul 25 '12 at 15:28
@user869081 We argue as follows: $\chi_{[y,\infty)}(x)$ is equal to one iff $x \in [y,\infty)$. This holds iff $y \le x$ or (as $x, y \ge 0$) iff $y \in [0,x]$, which is equivalent to $\chi_{[0,x]}(y)$. BTW: in both cases we have for each $x$ a function $y \mapsto ...$ which we integrate. – martini Jul 25 '12 at 19:09
Thanks martini!! I can see why $\int_{[0,\infty)}\chi_{[y,\infty)}(x)\;dy$ equals x. For x,y $\geq 0$, put $G \left(y,x\right) = \chi_{[y,\infty)}(x) =\left\{ \begin{array}{ll} 1 & \mbox {if } x \in {[y,\infty)}\\ 0 & \mbox{otherwise} \end{array} = \chi_\left[0,x\right](y) \right.$ – user869081 Jul 26 '12 at 6:57

To complete martini's proof, let me remark that changing the order of integration is allowed in this case by Tonelli's Theorem.

-
Thanks Rasmus. Is a rigorous understanding of this proof possible under Riemann integral settings? Is one required to understand Lebesgue integration? Just wondering... – user869081 Jul 25 '12 at 15:01

Intuitively, your double integral $$\int_0^\infty \int_y^\infty f_Y(x)\,\mathrm dx\, \mathrm dy$$ is the integral of $f_Y(x)$, regarded as a function of two variables $x$ and $y$, over the first octant $\{(x,y)\colon 0 \leq y \leq x < \infty\}$ set up by fixing $y$, letting $x$ vary from $y$ to $\infty$, (the inner integral) and then letting $y$ vary from $0$ to $\infty$ (the outer integral). An alternative way of computing this integral is to fix $x$, let $y$ vary from $0$ to $x$, and then let $x$ vary from $0$ to $\infty$. This results in the other expression $$\int_0^\infty \left [ \int_0^x \, \mathrm dy\right]f_Y(x)\,\mathrm dx.$$ The formal way of transforming one integral into another has been given by martini in his answer, with the interchange in the order of integration being justified via Tonelli's theorem as Rasmus points out. But let me say that at the level of Ross's A First Course in Probability (assuming that is the book you mean) the fine points and formal proofs are probably not expected to be considered by the average reader who is allowed to blithely interchange order of integration etc.

Another way of looking at the problem in intuitive fashion is to note that $$\int_0^\infty [1 - F(x)]\,\mathrm dx$$ computes the area between the CDF curve $F(x)$ and the line at height $1$ above the $x$ axis. One way to do this is to divide the region into thin vertical strips, so that the strip at $x$ extends from $(x,F(x))$ to $(x,1)$ and is of width $\Delta x$. Find Riemann sums, take limits as the width goes to $0$, etc.and you get $$\int_0^{\infty} [1-F(x)]\mathrm dx.$$ The other way is to divide into thin horizontal strips with the strip at height $F(x)$ above the axis having length $x$ since it extends from $(0,F(x))$ to $(x,F(x))$, and has thickness (height) $F(x+\Delta x) - F(x)$. The area is thus approximately $x\cdot [F(x+\Delta x) - F(x)]\Delta x \approx xf(x)\Delta x$, and proceeding with Riemann sums, etc., the end result is $$\int_0^{\infty} x f(x)\, \mathrm dx$$ which of course is the expected value.

-
Thanks Dilip. Yes, "A First Course in Probability" thats the book I meant. Ross uses it as a lemma to prove $$E\left[g\left(X\right)\right] = \int_0^{\infty} g(x) f_X(x)\, \mathrm dx$$ More advanced texts seem to use Lebesgue integration, etc. to prove this. That has made me wonder if an understanding of this requires one to go beyond Riemann integration? – user869081 Jul 26 '12 at 7:19
@user869081 A rigorous definition of random variables, expectations, and the like necessarily requires a measure-theoretic approach and so Lebesgue integration is used to provide the value of $E[g(X)]$ as the integral you show above. But, at the level of Ross's book (a non-measure-theoretic development), what do you need to show that for a Riemann-integrable function $f_Y(x)$, $$\int_0^\infty\left[ \int_y^\infty f_Y(x)\,\mathrm dx\right]\, \mathrm dy = \int_0^\infty \left [ \int_0^x \, \mathrm dy\right]f_Y(x)\,\mathrm dx ?$$ – Dilip Sarwate Jul 26 '12 at 17:23