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!
Why is matrix multiplication defined the way it is?
When I first learned about it, the formula seemed too complicated and counter-intuitive! I wondered, why not just multiply elements at the same position together?
Let me explain why!
↓ A thread. ↓
1/11
First, let's see how to make sense of matrix multiplication!
The elements of the product are calculated by multiplying rows of 𝐴 with columns of 𝐵.
It is not trivial at all why this is the way. 🤔
To understand, let's talk about what matrices really are!
2/11
Matrices are just representations of linear transformations: mappings between vector spaces that are interchangeable with addition and scalar multiplication.
Let's dig a bit deeper to see why are matrices and linear transformations are (almost) the same!
A concise guide from zero to one. 100% knowledge, 0% fluff. 🠓
1/13
Functions, the central objects of mathematics and computer science, are just mappings of inputs to outputs.
A convenient (albeit quite imprecise) way to define them is to describe their effect. An explicit formula is often available, which we can translate to code.
2/13
However, giving an explicit formula is not always easy or possible.
For instance, can you calculate the number of ways we can order a deck of n cards by shuffling its cards?
The single best way to get into machine learning is to build something with it.
Here is an extensive list of hands-on projects that you can start right now. Take inspiration, learn tools, and find the topics you are passionate about.
Read on and go create something awesome. ↓
I am grouping the projects into the following categories.
These hands-on projects work the best when you
• follow along and do the coding as well,
• understand why and how things work,
• and try to bring what you built to the next level.