Probability for Computer Scientists
The math of uncertainty: how to reason about randomness, which is what every AI system ultimately does.
AI tutor is turned off for this class
Use the CS109 lectures, notes, and assignments below to keep learning.
Lesson overview
The math of uncertainty: how to reason about randomness, which is what every AI system ultimately does.
Teacher script · 45 min
- 0–5
Hook
Probability sounds mystical but starts as counting: a fair die has 6 faces, so each has a 1-in-6 chance. The probability of something is just 'ways it can happen' divided by 'ways anything can happen.' Most confusion disappears once you carefully count both.
- 5–15
Explore
Students do the activity in pairs: A test is 99% accurate for a rare disease (1 in 10,000). You test positive. Are you likely sick? (Surprisingly, no; work out why with counts.)
- 15–30
Explain
A 'random variable' is a number whose value is uncertain: a dice roll, tomorrow's downloads. A distribution describes how its outcomes spread out. A few shapes (uniform, binomial, normal) describe a lot of the world, and knowing their mean and variance lets you predict and bound behavior.
- 30–40
Connect to the summit
Read aloud the "From the summit" section below. Ask students which ideas from today they recognize in it.
- 40–45
Check
Run the formative check below. Anyone who can explain a key term in their own words has it.
Student activity
A test is 99% accurate for a rare disease (1 in 10,000). You test positive. Are you likely sick? (Surprisingly, no; work out why with counts.)
Slides
Formative check
- 1.In your own words, what is "Conditional probability"? (Looking for: The chance of A given that you already know B happened.)
- 2.In your own words, what is "Bayes' rule"? (Looking for: The exact formula for updating a belief after seeing new evidence.)
- 3.In your own words, what is "Random variable"? (Looking for: A numeric outcome that's uncertain until observed, like a dice roll.)
Carry-away concepts
- Conditional probability
- The chance of A given that you already know B happened.
- Bayes' rule
- The exact formula for updating a belief after seeing new evidence.
- Random variable
- A numeric outcome that's uncertain until observed, like a dice roll.
- Expectation
- The long-run average value of a random variable.
From the summit · the Stanford source
You master probability from counting through random variables, distributions, and Bayesian inference, then apply it to machine learning.
This module is based on a Stanford course.