In an introductory probability class, the expected value of a random variable X is defined as
where fX is the probability density function of X. I’ll call this the analytical definition.
In a more advanced class the expected value of X is defined as
where (Ω, P) is a probability space. I’ll call this the measure-theoretic definition. It’s not obvious that these two definitions are equivalent. They may even seem contradictory unless you look closely: they’re integrating different functions over different spaces.
If for some odd reason you learned the measure-theoretic definition first, you could see the analytical definition as a theorem. But if, like most people, you learn the analytical definition first, the measure-theoretic version is quite mysterious. When you take an advanced course and look at the details previously swept under the rug, probability looks like an entirely different subject, unrelated to your introductory course. The definition of expectation is just one concept among many that takes some work to resolve.
I’ve written a couple pages of notes that bridge the gap between the two definitions of expectation and show that they are equivalent.