There is more than one way to think about matrix multiplication.

By definition, it is not easy to understand. However, there are multiple ways of looking at it, each one revealing invaluable insights.

Let's take a look at them!

↓ A thread. ↓
First, let's unravel the definition and visualize what happens.

For instance, the element in the 2nd row and 1st column of the product matrix is created from the 2nd row of the left and 1st column of the right matrices by summing their elementwise product.
To move beyond the definition, let's introduce some notations.

A matrix is built from rows and vectors. These can be viewed as individual vectors.

You can think of them as a horizontal stack of column vectors or a vertical stack of row vectors.
Let's start by multiplying a matrix and a row vector.

By writing out the definition, it turns out that the product is just a linear combination of the columns, where the coefficients are determined by the vector we are multiplying with!
Taking this one step further, we can stack another vector.

This way, we can see that the product of an (n x n) and an (n x 2) matrix equals the product of the left matrix and the columns of the right matrix, horizontally stacked.
Applying the same logic, we can finally see that the product matrix is nothing else than the left matrix times the columns of the right matrix, horizontally stacked.

This is an extremely powerful way of thinking about matrix multiplication.
We can also get the product as vertically stacked row vectors by switching our viewpoint a bit.
There is another interpretation of matrix multiplication.

Let's rewind and go back to the beginning, studying the product of a matrix 𝐴 and a column vector 𝑥.

Do the sums in the result look familiar?
These sums are just the dot product of the row vectors of 𝐴, taken with the column vector 𝑥!
In general, the product of 𝐴 and 𝐵 is simply the dot products of row vectors from 𝐴 and column vectors from 𝐵!
To sum up, we have three interpretations: matrix multiplication as

1. vertically stacking row vectors,
2. horizontally stacking column vectors,
3. and as dot products of row vectors with column vectors.

When studying matrices, each of them is immensely useful.
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
If you have enjoyed this thread, consider giving it a retweet and following me!

I regularly post deep-dive explanations about seemingly complex concepts from mathematics and machine learning.

Mathematics is beautiful, and I want to show this to you.

• • •

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

Mar 4
There is a mind-blowing application of matrix multiplication: doing recursion (almost) at the speed of light!

By the end of this thread, you'll learn precisely how.

Trust me, if you are into programming and math, you want to know this trick.

↓ ↓ ↓
Let's start with the simplest example for recursion: Fibonacci numbers.

Each Fibonacci number is the sum of the previous one and the one before.

The recursion starts with 0 and 1. Image
In Python, the implementation is rather straightforward.

Can you guess the issue? Image
Read 14 tweets
Mar 2
One common wisdom about gambling is that the house always wins.

This is not just a catchphrase; there is mathematical evidence behind it. If you play against an opponent with much deeper pockets, your chances of winning approach zero.

Read on to see why.

↓ A thread. ↓
To illustrate the problem above, consider a simple example: betting on coin tosses.

The dealer tosses a fair coin. If it lands on heads, you win $1. If tails, you lose $1.

You have 𝑛 dollars, while the casino has 𝑚. In total, there are 𝑁 = 𝑛 + 𝑚 dollars on the table.
You win when you reach 𝑁 dollars. However, if you get to zero, you lose.

The question is simple: what is the probability of winning?
Read 12 tweets
Mar 1
Let's test your probabilistic intuition!

There are 25 people in a room. What is the probability that two of them share the same birthday?

If you think it is low, you'll be surprised to find out that the actual probability is more than 50%.

Here is why!

↓ A thread. ↓
The usual thinking is if there are 25 people and 365 days in a year, then chances should be roughly 24/365 ≈ 6.5%, and if we have 366 people, then it is guaranteed that two of them share birthdays.

However, this is not how probability works.
First, it is much easier to talk about the probability of having no shared birthdays.

This is a common trick, often making the calculations much more manageable.
Read 15 tweets
Feb 15
People are inherently bad at probabilistic thinking.

Our intuition deceives us. We often encounter seemingly contradictory phenomena that go against our expectations.

The most famous example is the Monty Hall paradox. Let's see what it is and how to resolve it!

↓ A thread. ↓
In the ’60s, there was a TV show in the United States called Let’s Make a Deal.

As a contestant, you faced three closed doors, one having a car behind it (that you could take home), while the rest were empty.

You had the opportunity to open one.
Suppose that after selecting door No. 1, Monty Hall, the show host, opens the third, showing that it was not the winning one.

Now, you have the opportunity to change your mind and open door No. 2 instead of the first one.

Do you take it?
Read 14 tweets
Jan 12
You can explain the Bayes formula in pure English.

Despite being overloaded with seemingly complex concepts, it conveys an important lesson about how observations change our beliefs about the world.

Let's take it apart!

↓ A thread. ↓
Essentially, the Bayes formula describes how to update our models, given new information.

To understand why, we will look at a simple example with a twist: tossing a biased coin.
Suppose that we have a magical coin!

When tossed, it can come up with heads or tails, but not necessarily with equal chance.

The catch is, we don't know the exact probabilities. So, we have to perform some experiments to find that out.
Read 14 tweets
Dec 27, 2021
Entropy is not the easiest thing to understand.

It is rumored to describe something about information and disorder, but it is unclear why.

What do logarithms and sums have to do with the concept of information?

Let me explain!

↓ A thread. ↓
I have randomly selected an integer between 0 and 31.

Can you guess which one? You can ask as many questions as you want.

What is the minimum number of questions you have to ask to be 100% sure?

You can start guessing the numbers one by one, sure. But there is a better way!
If you ask, "is the number larger or equal than 16?" you immediately eliminate half the search space!

Continuing with this tactic, you can find the number for sure in 5 questions.
Read 15 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

Don't want to be a Premium member but still want to support us?

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!

:(