# Am I talking right?

I'm trying to describe expected value. My paragraph goes:

From probability theory we have $E[f(x)] = \int{f(x)p(x)dx}$. That is, the expected value of $f(x)$ is equal to the sum of infinitesimals $f(x)dx$ weighted by the probability that $f$ should take on those values $f(x)$ at each $x$.

Am I speaking about infinitesimals correctly? I'm thinking here of the integral summing infinitesimal products $f(x)p(x)dx$, but I'm not sure if I've made a no-no reference to use of infinitesimals here in my notation or conception.

-
It depends on what you mean by "correctly." This is a fine intuition but it is not how people rigorously define integration. – Qiaochu Yuan Aug 5 '12 at 21:18
For finite $\Delta x>0$, the probability that the random variable $X$ lies between $x$ and $\Delta x$ is roughly $p(x)\Delta x$, so even for a purely intuitive explanation I would break up the product into $f(x)$ (the value of the function) and $p(x)\,\mathrm dx$ (the probability of it attaining that value) instead. – Rahul Aug 5 '12 at 21:35
Oh, and shouldn't you distinguish between the random variable and the values it takes? That is, shouldn't it be $E[f(X)]$ on the left, for some random variable $X$ over whose sample space the integration on the right takes place? – Rahul Aug 5 '12 at 21:36
Infinitesimals aren't a "no-no." Here's a nice book at the freshman calc level that treats them rigorously: math.wisc.edu/~keisler/calc.html – Ben Crowell Aug 5 '12 at 22:21

If you have a probability density $p(x)$, then I would actually write: "The expected value of $f(x)$ is equal to the sum of $f(x)$ weighted by the infinitesimal probability that $X\in[x,x+dx]$ which is $p(x)dx$"
So there are two things going on here. First $p(x)$ is a probability density, in that $p(x)$ has units of probability per unit $x$ ($x$ could be length, age, whatever). In other words $p(x)$ by itself is NOT a probability in the usual sense, it needs to be multiplied by the $dx$ term to become an infinitesimal probability. This is sort of a wishy-washy physics explanation of probability density.
Next, when writing $E[f(X)]$ one has two choices. The first choice is to express $E[f(X)]$ in terms of the probability density of $X$, which is to say $p(x)$. In this sense, we have $E[f(X)]=\int f(x)p(x)dx$. In other words, we are first querying the domain of $f$ as a random variable and then applying $f$. The other option is to write the expected value in terms of the density of $f(X)$ as a random variable. In this case we would define $g(y)$ as the probability that $f(x)\in[y,y+dy]$. In this case we are querying the range of $f$ as a random variable, that inherits it's randomness from the random domain $X$. So for any event $A$, $P(f(X)\in A)=P(X\in f^{-1}(A))$ where the right-hand-side is a known quantity since we know the distribution of $X$. To wit, we get $E[f(X)]=\int yg(y)dy$.