Courses › Statistics and Econometrics
Probability and random variables
Probability rules, discrete and continuous random variables, expected value and variance, joint and conditional distributions, and covariance.
Data are noisy. Two surveys of the same city give different average rents; two weeks at the same café give different sales. Probability is the language for that noise. It lets you say how likely an outcome is, what to expect on average, and how much results are likely to bounce around.
This module covers the rules of probability, conditional probability and Bayes’ rule, random variables and their expected values and variances, and the joint behaviour of two random variables: covariance, independence and conditional expectation. Conditional expectation in particular is the idea that regression is built on.
By the end of this module you will be able to
- Apply the complement, addition and multiplication rules, and compute conditional probabilities.
- Use Bayes’ rule and explain why base rates matter.
- Compute the expected value and variance of a discrete random variable, including binomial ones.
- Find probabilities for continuous random variables as areas under a density.
- Compute covariance and conditional expectations from a joint distribution and use the rules for sums of random variables.
What this module covers
- The rules of probability
- Bayes’ rule and base rates
- Discrete random variables
- Continuous random variables
- Two random variables: joint distributions and conditional expectation
- Problem set with step-by-step solutions
- Module quiz
Lesson 2.1 Free lesson
The rules of probability
A random experiment is anything with an uncertain outcome: the next customer’s order, tomorrow’s exchange rate, whether a flight leaves on time. The sample space is the set of all possible outcomes, and an event is any collection of outcomes. A probability P(A) is a number between 0 and 1 that measures how likely event A is; the probabilities of all outcomes add to 1.
Three basic rules
- Complement: P(not A) = 1 − P(A).
- Addition: P(A or B) = P(A) + P(B) − P(A and B). Subtracting the overlap avoids counting it twice. If A and B can’t both happen (they are mutually exclusive), the overlap is zero.
- Multiplication: P(A and B) = P(A) × P(B | A), where P(B | A) is the probability of B given that A happened.
Conditional probability
Conditioning means restricting attention to cases where something is known to be true:
Events A and B are independent if knowing one tells you nothing about the other: P(B | A) = P(B), or equivalently P(A and B) = P(A) × P(B).
Worked example: Coffee and pastries
At a café, 60% of customers order coffee, 25% order a pastry, and 15% order both.
Probability a customer orders coffee or a pastry: 0.60 + 0.25 − 0.15 = 0.70. So 30% order neither.
Probability of a pastry given coffee: P(pastry | coffee) = 0.15/0.60 = 0.25.
That equals the overall pastry rate of 0.25, so coffee and pastry orders are independent here: knowing someone bought coffee doesn’t change the chance they buy a pastry. Check: 0.60 × 0.25 = 0.15, the probability of both.
Probabilities can be interpreted as long-run frequencies (a fair coin lands heads half the time in many tosses) or as degrees of belief. For this course the frequency view is enough: a probability of 0.3 means that, across many repetitions of the same situation, the event happens about 30% of the time.
Common mistake
Confusing P(A | B) with P(B | A). Most people who buy a sports car are men, but that doesn’t mean most men buy sports cars. The two conditional probabilities can be wildly different, which is the subject of the next lesson.
Key ideas
- P(not A) = 1 − P(A); P(A or B) = P(A) + P(B) − P(A and B).
- Conditional probability restricts attention to cases where the condition holds: P(B | A) = P(A and B)/P(A).
- Independence means P(B | A) = P(B), so joint probabilities multiply.
- A probability is a long-run frequency across many repetitions.
Practice questions: Probability and random variables
Try these, then open each answer to check your work.
- 1.P(A) = 0.5, P(B) = 0.4 and P(A and B) = 0.2. What is P(A or B)?
- 0.2
- 0.7
- 0.9
- 1.1
Show answer
Answer: B. 0.5 + 0.4 − 0.2 = 0.7.
- 2.Using the probabilities in Question 1, are A and B independent?
- No, because P(A or B) is less than 1
- No, because P(A and B) is not zero
- Yes, because 0.5 × 0.4 = 0.2
- Yes, because P(A) is larger than P(B)
Show answer
Answer: C. Independence requires P(A and B) = P(A)P(B), which holds: 0.5 × 0.4 = 0.2.
- 3.A test flags 99% of a rare condition and falsely flags 5% of others. If the condition affects 1% of people, P(condition | flagged) is closest to:
- 0.17
- 0.50
- 0.95
- 0.99
Show answer
Answer: A. 0.99(0.01)/(0.99(0.01) + 0.05(0.99)) = 0.0099/0.0594 = 0.167. The low base rate makes most flags false.
Problems with step-by-step solutions
- 4.40% of a gym’s members take yoga classes, 30% take spin classes, and 10% take both. What is the probability a member takes at least one of the two? Neither?
Show step-by-step solution
- P(yoga or spin) = 0.40 + 0.30 − 0.10 = 0.60.
- P(neither) = 1 − 0.60 = 0.40.
- 5.In Problem 1, what is the probability a yoga member also takes spin? Are the two independent?
Show step-by-step solution
- P(spin | yoga) = 0.10/0.40 = 0.25.
- The overall spin rate is 0.30. Since 0.25 ≠ 0.30, they are not independent: yoga members are slightly less likely to take spin. Check: 0.40 × 0.30 = 0.12 ≠ 0.10.
Get the full module
The complete module adds every lesson, interactive graphs, a full problem set with step-by-step solutions, and a quiz. The academy opens in January 2027: join the waitlist for the founding price (lifetime access for $179).
Join the waitlist Try a full module free
More practice: free practice questions for this course.