Week 10 · Probability for machine learning
Read the words of the video
- When you toss a coin many times, you expect about half heads and half tails. But the exact sequence is always a surprise! Our world is full of such uncertainty. Probability is like a special language that helps us understand and talk precisely about these uncertain events. It lets us make smart guesses about what might happen next.
- This week, we learn key tools. Probability rules help us combine events. Random variables are numbers decided by chance, with averages and how spread out they are. We'll explore common patterns called distributions and see why averaging data helps us understand the world better with powerful mathematical guarantees.
- Imagine a rare disease, affecting only one in a hundred people. A test is usually right for sick people, but sometimes gives false alarms for healthy ones. If your test is positive, Bayes' rule helps us calculate that your actual chance of being sick is still quite low, around 15%, because the disease itself is so uncommon.
- For your exams, remember key questions like the Chebyshev mark problem and the bulb lifetime example. Practice binomial variance and conditional probability with Bayes' rule. You've now built a strong toolkit to tackle uncertainty, understand data, and make informed predictions. Keep exploring these exciting ideas!
The one-minute story
Toss a coin 100 times and you will see about 50 heads, but never exactly "head, tail, head, tail". The world is uncertain, and data is a messy, noisy sample of it. Probability is the language for talking about that uncertainty precisely, and machine learning is full of it: "the model says 83% spam", "the average error is about 2 give or take 0.3", "with 95% confidence the true value is in this range".
This week is a tool kit:
- the rules of probability (and Bayes' rule, which lets you flip "what I saw" into "what is probably true");
- random variables, their average (expectation) and spread (variance);
- the handful of distributions you will meet again and again;
- four big results that say why averaging data works: Markov, Chebyshev, the law of large numbers, the central limit theorem.
By the end of this week you can:
- use probability rules, conditional probability, independence and Bayes' rule;
- compute expectation and variance, and use joint and marginal densities;
- work with Bernoulli, binomial, uniform, exponential and normal distributions;
- bound probabilities with Markov and Chebyshev, and explain the law of large numbers and central limit theorem.
Words you need
- Event - something that might happen ("the die shows an even number").
- Probability - a number from 0 (impossible) to 1 (certain).
- Random variable - a number whose value is decided by chance.
- Expectation - the long-run average value.
- Variance - how spread out is around its average. Standard deviation .
- Density - for a continuous variable, the height of the curve whose area gives probability.
- Independent - knowing one tells you nothing about the other.
- i.i.d. - "independent and identically distributed": repeated trials of the same experiment.
Idea 1: The rules of probability
- , and .
- Complement: .
- Either-or: .
- Conditional: , "the chance of once we know happened".
- Independent events: .
- Bayes' rule: .
Bayes' rule flips a question around. A doctor knows "if a person has the disease, the test is positive 90% of the time". But you want to know the opposite: "my test is positive, so how likely is it that I really have the disease?" Bayes' rule converts one into the other, using how common the disease is to begin with.
Question. 1% of people have a disease. A test is positive for 90% of sick people but also for 5% of healthy people. You test positive. What is the chance you are sick?
Solution.
- , , .
- .
- .
Only about 15%, because the disease is rare, so most positives are false alarms from the huge healthy group. This idea (a prior belief updated by evidence) returns in MLT's Bayesian estimation and Naive Bayes.
Question. A fair coin is tossed twice. : first toss is heads. : second toss is heads. : both tosses are the same. Are independent?
Solution. ( = HH or TT).
- . ✓
- . ✓
- . ✓
Every pair is independent. But , while . They are not mutually independent. A classic trap.
Idea 2: Random variables, expectation and variance
A discrete random variable takes separate values with a probability mass function . A continuous one has a density , and (area under the curve). The total area is 1.
- Linearity (always true): and .
- .
- If are independent: .
- Covariance . Independent covariance , but covariance 0 does not imply independent.
Two variables together
A joint density describes both at once. The marginal of is what you get by integrating away: .
Question. on the unit square , (and 0 elsewhere). Find , the marginal of , and .
Solution.
- Total probability is 1: .
- Marginal: for .
- .
Since , the two variables are independent here.
Idea 3: The distributions you must know
| Name | Describes | Mean | Variance |
|---|---|---|---|
| Bernoulli() | one yes/no trial | ||
| Binomial() | number of yeses in independent trials | ||
| Uniform | "anything in equally likely" | ||
| Exponential() | waiting time until something happens | ||
| Normal | the bell curve |
Exponential details: density for ; . It is memoryless: if you have already waited minutes, the chance of waiting more is the same as if you had just arrived: .
Normal details: about 68% of the mass lies within of , 95% within , 99.7% within . Linear changes stay normal: ; and for independent normals, means add and variances add.
Question. (a) The waiting time for a bus is exponential with mean 5 minutes. Find and the 95th percentile. (b) A job's completion time is uniform on with mean 15 minutes. Find and , then .
Solution.
(a) Mean . . The 95th percentile solves : , so minutes.
(b) . . For the conditional probability, restrict to : the remaining range is , length 8, and the part above 16 has length 4: .
Question. 20% of 400 students own a laptop. If we count the owners, what are the mean and variance of that count?
Solution. Binomial with , . Mean , variance (so ).
Idea 4: Four results that explain why data works
Markov and Chebyshev: bounds with almost no information
Markov (for , knowing only the mean): for any
Chebyshev (knowing mean and variance ): for any
Markov: "The average person in the class is 12 years old, so at most one-sixth of them can be 72 or older." There just isn't enough "age" to go round. Chebyshev: "If most people are close to the average, few can be very far." Both give guarantees that hold for any distribution, which is why they are conservative.
Question. (a) Daily sales have mean 50 (and cannot be negative). Bound . (b) Marks have and . Bound the chance that a mark differs from 70 by more than 16.
Solution. (a) Markov: . (b) , so : .
The law of large numbers and the central limit theorem
Take independent repeats of the same experiment with mean and variance , and average them: . Then and .
- Weak Law of Large Numbers (WLLN): as grows, gets close to . Chebyshev makes it precise: .
- Central Limit Theorem (CLT): for large , , whatever shape the original distribution had. This is why bell curves show up everywhere.
Question. Bulb lifetimes are exponential with per year. The average of 50 bulbs is . Give a lower bound for .
Solution. One bulb: , . For the mean of 50: variance . The interval is , so by Chebyshev . Hence .
Your turn
A factory has two machines. Machine A makes 60% of items with 2% defective; machine B makes 40% with 5% defective. An item is defective. What is the chance it came from B?
Need a hint?
Bayes: .
Show the full solution
. .
takes values with probabilities . Find and .
Need a hint?
.
Show the full solution
. . .
and are independent. What is the distribution of ?
Need a hint?
Mean: use linearity. Variance: and add (independent).
Show the full solution
Mean . Variance . So .
A variable has mean 100 and standard deviation 10. What is the best Chebyshev bound on ?
Need a hint?
.
Show the full solution
, so the bound is .
Waiting times are exponential with mean 4 minutes. You have waited 6 minutes already. What is the probability you wait at least 2 more?
Need a hint?
Use memorylessness.
Show the full solution
. The 6 minutes already waited are irrelevant.
Exam radar
Probability fills the second half of the End Term:
- Chebyshev in 23 paper summaries, Markov in 20, WLLN in 9, CLT in 9, normal distribution in 12, conditional probability in 10.
- Repeated numbers: Chebyshev with , deviation 16 (8 times); WLLN with exponential bulbs , (6 times); Markov bounds on sales/defects/processing time; binomial variance for 20% of 400; fair coin twice, independence of (6 times).
- Trending up in 2025 to 2026: exponential waiting times (percentiles, intervals, memorylessness), uniform completion times, joint-density integrals, and spam-style probability stories.
- Markov needs a non-negative variable. Chebyshev needs mean and variance, and its bound is for the two-sided event .
- Chebyshev's is the standard deviation, not the variance; the sample-mean version uses .
- Pairwise independence mutual independence.
- Covariance independent.
- For remember . For independent sums, variances add; standard deviations do not.
- Exponential: mean is , not .
Quick quiz
Markov's inequality for a non-negative X with mean 10 says P(X at least 50) is at most...
- 0.5
- 0.2
- 0.02
- 5
For independent X and Y, Var(2X + 3Y) equals...
- 2 Var(X) + 3 Var(Y)
- 5 Var(X) + 5 Var(Y)
- 4 Var(X) + 9 Var(Y)
- 6 Var(X) Var(Y)
An exponential waiting time has mean 5. The rate lambda is...
- 5
- 0.2
- 25
- 0.5
Select all TRUE statements. (select all that apply)
- Independent random variables have zero covariance.
- The central limit theorem makes sample averages roughly normal for large n.
- Zero covariance guarantees independence.
- Chebyshev's inequality needs the variable to be non-negative.
Recap
- Rules: complement, either-or, conditional, independence, Bayes. Pairwise mutual independence.
- ; ; independent variances add.
- Distributions: Bernoulli, binomial (, ), uniform, exponential (mean , memoryless), normal.
- Markov ; Chebyshev ; WLLN: averages converge; CLT: averages are approximately normal with variance .
- ; Bayes
- ;
- Binomial: , ; Uniform: , ; Exponential: , ,
- ; independent sum: means and variances add
- Markov: ; Chebyshev:
- Sample mean: , ; WLLN:
- MLT week 8 - Generative models: Naive Bayes: Naive Bayes is Bayes' rule plus the probability tools from MLF week 10.
Practise with real exam questions
These come straight from past papers (with the real figures and the official answer key). Open 45 real questions on this week All End Term papers