The Math Behind the Machine/ Unit 14 · Thinking in Probabilities Checks 0/1 Sign in
Unit 14 of 20 · by Prof. Saurabh

Thinking in Probabilities

Every unit so far gave a crisp answer: this line, this projection, this side of the street. The real world rarely does. It gives maybes — a 70% chance of rain, a test that is right most of the time, a score that is "probably a cat". This unit teaches the language of maybes. You will see that uncertainty has a shape, that the covariance ellipse of Unit 12 was a bell curve all along, that "minimise the squared error" secretly meant "make the data least surprising", and how a machine turns raw scores into honest probabilities — the tools every network after this one is built on.

≈ 120 min read + play 16 interactive widgets · 5 in 3D · a classifier you can train 20 inline checks 🧾 18 proofs, folded away — open "if you want the algebra" when you are ready ✍ 14 solved practice problems

← Unit 13 · Support Vector Machines

drag the scene to orbit
1

Why a machine needs probabilities

Imagine this

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 Ax=bA\mathbf x=\mathbf b: here is x\mathbf x. Project onto a line: here is the shadow. Unit 13's support vector machine says "+1+1" or "−1-1".

But look at how the SVM says it. A point deep inside the blue group gets "+1+1". A point that only just grazes the street also gets "+1+1". 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.

The Galton board: one bead is a surprise, a crowd is a shapeEvery bead bounces left or right at every peg. You cannot predict one bead. You can predict the pile.

Try: Drop 1 bead a few times — each lands somewhere new. Then drop 2000 and watch a bell rise out of the chaos, hugging the dashed outline. Now push the peg bias to the right: the whole bell slides, but it keeps its shape.

12
0.5
—

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 212=40962^{12}=4096 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.

The realization

P(X=k)=beads in slot kall the beadsP(X=k)=\frac{\text{beads in slot }k}{\text{all the beads}}

A random variable XX turns an uncertain outcome into a number. You cannot know the next value of XX. You can know its distribution: how the chances are spread over the possible values. The shape of the pile is the knowledge.

Pause & predict

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.

  1. Uncertainty has a shape (§1–§3): distributions, their balance point and spread, and Bayes' rule for turning evidence around.
  2. 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.
  3. Learning = the least surprising world (§7–§9): likelihood, fitting by maximum likelihood, and the discovery that least squares was maximum likelihood all along.
  4. 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.

Free preview · Unit 14 of 20

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).

Unlock Unit 14

  1. 2

    Distributions: where the probability lives

  2. 3

    Bayes: turning evidence around

  3. 4

    The bell curve, and why it keeps showing up

  4. 5

    The Gaussian in many dimensions

  5. 6

    Making Gaussian data: stretch a round cloud

  6. 7

    Likelihood: turning the question around

  7. 8

    Fitting a Gaussian by maximum likelihood

  8. 9

    Least squares falls out

  9. 10

    Softmax: turning scores into probabilities

  10. 11

    Surprise and entropy

  11. 12

    Cross-entropy and KL: paying for the wrong belief

  12. 13

    Cross-entropy is the classifier's likelihood

  13. 14

    What to carry forward

  14. 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.