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!

tivadardanka.com/book/
Another (very interesting) explanation: expected value as center of mass!

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Tivadar Danka

Tivadar Danka Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @TivadarDanka

16 Dec
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 Image
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 Image
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!

3/11 Image
Read 11 tweets
9 Dec
Just released a new chapter in the early access of my Mathematics of Machine Learning book!

It is about computing determinants in practice. Sadly, this is often missing from linear algebra courses, so I decided to fill this gap.

↓ Here's the gist. ↓
The determinant of a matrix is essentially the product of

• the orientation of its column vectors (which is either 1 or -1),
• and the area of the parallelepiped determined by them.

For 2x2 matrices, this is illustrated below.
Here is the thing.

In mathematics, we generally use two formulas to compute this quantity.

First, we have a sum that runs through all permutations of the columns.

This formula is hard to understand, let alone to implement.
Read 10 tweets
8 Dec
Math Twitter!

I have an annoyingly simple problem that has been bugging me for years. It is about the 3-regular infinite tree graph with a root.

Can we collaboratively solve this problem? I'll explain below.

(Retweet so this reaches as many smart people as possible.) Image
The 3-regular infinite tree with a root (3RT) is very simple to define.

The root vertex has two children, and besides that, every vertex has two more. This goes on infinitely.

You get the pattern. This is illustrated below. Image
It is easy to see that 3RT is a planar graph; that is, you can draw it on the plane without any edges intersecting.

I am particularly interested in drawing the 3RT inside a bounded set of the plane without any edges intersecting.
Read 7 tweets
7 Dec
I was recently invited to join the Underfitted DAO.

By default, I am skeptical about crypto projects, so I had a LOT of questions.

After a long conversation with @haltakov and @svpino, I am convinced.

Here is why.

The best way to get experience and knowledge in machine learning is to build things.

If you build things, you should be compensated in proportion to the value you create.

In practice, this is often not the case. Not in open source, not in the industry.

What can change this?
Well, DAO-s have this potential. Of course, the concept may not live up to the expectations, but their fundamental idea holds a lot of promise.

In a DAO, contributions are rewarded with tokens. Decisions are made by voting, where all token-holders can participate.
Read 6 tweets
6 Dec
What is recursion?

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?

3/13
Read 13 tweets
19 Oct
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.

📺 Computer vision
🗣️ NLP
🎮 Reinforcement learning
🗄️ Data engineering
📊 Visualization
☁️ Deployment
A few thoughts before we start.

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.
Read 29 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(