Let $X$ be a continuous variable and let $f$ be the probability density function. $f$ is defined on : $[a, b]$ such that : $$\int_{a}^{b} f(x) \, \mathrm{d}x = 1$$
Then my lesson says that : $E(X) = \int_{a}^{b} xf(x) \, \mathrm{d}x$
Even if it seems like there is a big link with the expected value of a discrete random variable I don't understand this formula.
That's why intuitively according to me it should be : $$E(X) = \sum x \cdot \int_{a}^{x} f(x)\, \mathrm{d}x$$
So, can someone explains where I am wrong or maybe explain the first formula of the expected value (a demonstration would be nice).
Let's start with the arithmetic mean. The arithmetic mean is just all the numbers averaged. That is, each number is equal in weight.
Now, we look into weighted means. Let's say we have a table of probabilities of a rigged dice.
We have the weighted average, which is basically taking each number x its weight. So we have $\displaystyle \sum_{n=1}^6Px=1(0.05)+2(0.1)+3(0.15)+4(0.2)+5(0.3)+6(0.2)=4.2$.
I hope you see where I'm going with this.
Now, as the subintervals get even smaller and smaller, we have that $X$ becomes a continuous random variable.
Notice, as we break into smaller and smaller pieces, we would now have something like, the probability of $1.1$ is $0.01$, the probability of $1.2$ is $0.015$.. etc. So we have small probabilities, and more numbers to weight.
Finally as you could probably tell, this leads to the expected value, or mean, being the integral of the product of the probability (density) function and the variable.
This would be $\displaystyle \int_a^b xf(x)\,dx$.