Why a machine needs probabilities
It is the monsoon. Two weather forecasters work in your town.
The first one says "rain" every single morning. The second one says things like "70% chance of rain" or "20% chance of rain".
You check the second one's record. On the days she said 70%, it rained on about 7 days out of 10. Now her numbers mean something. A farmer can decide whether to sow today. You can decide whether to carry an umbrella. The first forecaster is never quite wrong, but he is never useful.
Every unit so far gave crisp answers. Solve : here is . Project onto a line: here is the shadow. Unit 13's support vector machine says "" or "".
But look at how the SVM says it. A point deep inside the blue group gets "". A point that only just grazes the street also gets "". Same answer, same confident voice. The machine cannot say "probably blue, but I am not sure".
The world is full of such "probably". Will it rain? Is this patient sick? Is this photo a cat? The honest answer is a number between 0 and 1. So we need a language for uncertainty. That language is probability, and this whole unit teaches it.
Start with one word. A random variable is a rule that turns an uncertain outcome into a number. Toss a coin and write 1 for heads, 0 for tails. Roll two dice and write their sum. Measure tomorrow's rainfall in millimetres. Each time, you cannot know the number in advance. But you can say how likely each number is.
Here is a machine that makes a random variable. It is called a Galton board. A bead drops in at the top and meets a peg. It bounces left or right, like a coin toss. Then it meets another peg, and another — twelve rows of them. At the bottom it falls into a slot. The slot number is simply how many times it bounced right.
Where will one bead land? Nobody can say. But drop two thousand, and something surprising happens.
Why a bell? Count the routes. To reach slot 0 a bead must bounce left twelve times in a row: there is only one such route. To reach the middle slot, 6, it needs six lefts and six rights in any order, and there are 924 different orders. Out of all routes, 924 end in the middle. So about 23% of the beads land there, and almost none at the edges.
No bead knows about bells. Each one just flips a coin at each peg. The shape comes from counting. That is the first big idea of this unit: a single outcome is unpredictable, but the pattern of many outcomes is not. The pattern is called a distribution, and it is the thing we can know.
A random variable turns an uncertain outcome into a number. You cannot know the next value of . You can know its distribution: how the chances are spread over the possible values. The shape of the pile is the knowledge.
A forecaster said "70% chance of rain" on 100 different days. When is she doing her job well?
The road ahead. The unit has four acts.
- Uncertainty has a shape (§1–§3): distributions, their balance point and spread, and Bayes' rule for turning evidence around.
- The Gaussian (§4–§6): the bell curve, why it keeps appearing, what it looks like in many dimensions (Unit 12's ellipse!), and how a computer draws samples from it.
- Learning = the least surprising world (§7–§9): likelihood, fitting by maximum likelihood, and the discovery that least squares was maximum likelihood all along.
- Scores into probabilities (§10–§13): softmax, surprise and entropy, cross-entropy and KL, and a classifier that trains itself with the cleanest gradient in machine learning.
In one sentence: A random variable turns an uncertain outcome into a number, and although one outcome cannot be predicted, the distribution of many outcomes can — the shape of the pile is the knowledge.
That was section 1. The rest of the unit opens when you unlock it.
13 more sections and the practice arena — 16 widgets, 20 checks and 14 solved problems in the whole unit (this preview had 1 widget and 1 check).
- 2
Distributions: where the probability lives
- 3
Bayes: turning evidence around
- 4
The bell curve, and why it keeps showing up
- 5
The Gaussian in many dimensions
- 6
Making Gaussian data: stretch a round cloud
- 7
Likelihood: turning the question around
- 8
Fitting a Gaussian by maximum likelihood
- 9
Least squares falls out
- 10
Softmax: turning scores into probabilities
- 11
Surprise and entropy
- 12
Cross-entropy and KL: paying for the wrong belief
- 13
Cross-entropy is the classifier's likelihood
- 14
What to carry forward
- 15
Practice arena — fourteen problems, solved in full
Unlock this unit for ₹299, or all seven paid units for ₹999 — one-time payment, full refund within 7 days. See pricing.