For an infinitesimally small interval of width \(\delta x\),
\[ P(x \lt X \lt x+\delta x) \;\approx\; f(x) \times \delta x\]If the whole range of possible x-values is split into such slices, the definition of an expected value for a discrete random variables would give
\[ E[X] \;\approx\; \sum {x \times f(x) \; \delta x}\]In the limit, this summation becomes an integral, giving us the following definition.
Definition
The expected value of a continuous random variable with probability density function \(f(x)\) is
\[ E[X] \;=\; \int_{-\infty}^{\infty} {x \times f(x) \; d x}\]This can be generalised:
Definition
If \(X\) is a continuous random variable with probability density function \(f(x)\), the expected value of any function \(g(X)\) is
\[ E\big[g(X)\big] \;=\; \int_{-\infty}^{\infty} {g(x) \times f(x) \; d x}\]