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 it comes 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? 🤔
We are about to find out!
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 1/2.
(Similarly, tails/tosses also converge to 1/2.)
So, your average earnings per round are -1/2. This is the expected value. So, you'll lose in the long run.
(By the way, 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, we can quantify the outcome of your experiments. (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 experiment's outcome with 𝑋 and its possible values with 𝑥ᵢ, we get back the formula in the first tweet.
It looks much easier now!
Having a deep understanding of math will make you a better engineer. I want to help you with this, so I am writing a comprehensive book about the subject.
If you are interested in the details and beauties of mathematics, check out the early access!
Even looking at the definition used to make me sweat, let alone trying to comprehend the pattern. Yet, there is a stunningly simple explanation behind it.
Let's pull back the curtain!
First, the raw definition.
This is how the product of A and B is given. Not the easiest (or most pleasant) to look at.
We are going to unwrap this.
Here is a quick visualization before the technical details.
The element in the i-th row and j-th column of AB is the dot product of A's i-th row and B's j-th column.