Expected value is one of the most fundamental concepts in probability theory and machine learning.
Have you ever wondered what it really means and where does it come from? The formula doesn't tell the entire story right away.
Let's unravel what is behind the scenes!
First, let's take a look at a simple example. Suppose that we are playing a game. You toss a coin, and
- if it comes up heads, you win $1,
- but if it is tails, you lose $2.
Should you even play this game with me? 🤔
After 𝑛 rounds, your earnings can be calculated by the number of heads times 1 minus the number of tails times 2. If we divide total earnings by , we obtain the average earnings per round. What happens if approaches infinity?
As you have probably guessed, the number of heads divided by the number of tosses will converge to the probability of a single toss being heads. In our case, this is . (Similarly, tails/tosses also converges to .)
So, your average earnings per round are . This is the expected value, calculated by
You definitely shouldn't play this game. How can we calculate the expected value for a general case?
Suppose that, similarly to the previous example, the outcome of your experiments can be quantified. (Like throwing a dice or making a bet at the poker table.) The expected value is just the average outcome you have per experiment when you let it run infinitely.
The formula above is simply the expected value in English. If we formally denote the variable describing the outcome of the experiment with and its possible values with we get back the formula from the beginning:
It looks much easier now, isn't it?