What do you get when you let a monkey randomly smash the buttons on a typewriter?
Hamlet from Shakespeare, of course. And Romeo and Juliet. And every other finite string that is possible.
Don't believe me? Keep reading. ↓
Let's start at the very beginning!
Suppose that I have a coin that, when tossed, has a 1/2 probability of coming up heads and a 1/2 probability of coming up tails.
If I start tossing the coin and tracking the result, what is the probability of 𝑛𝑒𝑣𝑒𝑟 having heads?
To answer this, first, we calculate the probability of no heads in 𝑛 tosses. (That is, the probability of 𝑛 tails.)
Since tosses are independent of each other, we can just multiply the probabilities for each toss together.
By letting 𝑛 to infinity, we obtain that the probability of never tossing heads is zero.
That is, we are going to have heads come up eventually with probability 1.
Instead of coin tosses, we can talk about arbitrary events.
If an event has a nonzero probability and you have infinite attempts, 𝑖𝑡 𝑤𝑖𝑙𝑙 ℎ𝑎𝑝𝑝𝑒𝑛 with probability 1.
Now, let's apply that to our monkey, infinitely typing away at the typewriter.
What is the probability that six random consecutive keystrokes result in the string "Hamlet"?
First, each keystroke matching the right character is 1/(number of keys).
Because the keystrokes are independent, the probability of a given string is the product of the probabilities for each keystroke matching the individual character.
Now, let's calculate the probability that the entire Hamlet play by Shakespeare is typed randomly.
Since the entire play has 194270 characters, and there are 100 possible keys to hit, this probability is extremely small.
Still, it is larger than zero.
Thus, if our monkey keeps typing infinitely, the entire Hamlet play will appear somewhere. (Along with every other finite string you can imagine.)
However, this takes a 𝑣𝑒𝑟𝑦 long time on average.
If the probability of a given string occurring is 𝑝, the expected number of attempts to randomly generate it is 1/𝑝.
So, if 𝑝 is as small as randomly typing the entire Hamlet play, then 1/𝑝 is going to be astronomical.
(If you are not familiar with the concept of expected values, take a look at the simple explanation I posted a while ago.)
It states that given infinite time, a monkey randomly smashing the keys of a typewriter will type any given text.
Next time when you say, "even a monkey can do it", be careful. Monkeys can do a lot.
Recently, I have been thinking about probability a lot.
In fact, I am writing the probability theory chapters of my book, Mathematics of Machine Learning. The early access is just out, where I publish one chapter every week.
Data similarity has such a simple visual interpretation that it will light all the bulbs in your head.
The mathematical magic tells you that similarity is given by the inner product. Have you thought about why?
This is how elementary geometry explains it all.
↓ A thread. ↓
Let's start in the beginning!
In machine learning, data is represented by vectors. So, instead of observations and features, we talk about tuples of (real) numbers.
Vectors have two special functions defined on them: their norms and inner products. Norms simply describe their magnitude, while inner products describe
.
.
.
well, a 𝐥𝐨𝐭 of things.
If I toss a fair coin ten times and it all comes up heads, what is the chance that the 11th toss will also be heads? Many think that it'll be highly unlikely. However, this is incorrect.
Here is why!
↓ A thread. ↓
In probability theory and statistics, we often study events in the context of other events.
This is captured by conditional probabilities, answering a simple question: "what is the probability of A if we know that B has occurred?".
Without any additional information, the probability that eleven coin tosses result in eleven heads in a row is extremely small.
However, notice that it was not our case. The original question was to find the probability of the 11th toss, given the result of the previous ten.
The early access of my Mathematics of Machine Learning book is launching today!
One chapter per week, we go from basics to the internals of neural networks. We are starting with vector spaces, the scene where machine learning happens.
Here is why they are so important!
🧵 👇🏽
As you probably know, data is represented by vectors.
Data points are just tuples of measurements. In their raw form, they are hardly useful for us. They are just blips in space.
Without operations and transformations, it is difficult to predict class labels or do anything else.
Vector spaces provide a mathematical structure where operations naturally arise.
Instead of a blip, just imagine an arrow pointing to the data point from a fixed origin.
Even though most of us are introduced to the subject through this example, fitting functions to a training dataset seemingly doesn't give us any deep insight about the data.
This is what's working behind the scenes!
🧵 👇🏽
Consider a simple example: predicting the value 𝑦 from the observation 𝑥; for instance 𝑦-s are real estate prices based on the square footage 𝑥.
If you are a visual person, this is how you can imagine such dataset.
The first thing one would do is to fit a linear function 𝑓(𝑥) = 𝑎𝑥 + 𝑏 on the data.
By looking at the result, we can see that something is not right. Sure, it might capture the mean value for a given observation, but the variance and the noise in the data is not explained.