Probability
Source: Concepts adapted from Ace the Data Science Interview — Chapter 5 (“Probability”) by Kevin Huo & Nick Singh. Rewritten in original wording for this course.
Probability is one of the skills interviewers probe hardest — especially conditional probability, Bayes’ rule, and matching the right distribution to a story. Finance loops lean on expectation and betting-style decisions; stats rounds dig deeper on top of these foundations.
This lesson covers the interview core: conditionals and total probability, counting, random variables, common distributions, and Markov chains. Each section ends with a concept quiz plus a compute quiz — randomized story problems (map the context to , , , , …; answers to at most 2 decimals). Use New story for another scenario.
Conditional probability and Bayes’ rule
You often want — the chance of once you know happened. Bayes’ rule rewrites that as:
- — prior
- — likelihood
- — posterior
If , then and are independent: learning does not change . They can also be conditionally independent given :
Interview habit: any “given that…” probability is a Bayes hint. Rare-disease testing is the classic trap — a “highly accurate” test still needs the base rate. In ML, many models are about choosing a good conditional distribution of the target given the data.
Conditional probability & Bayes
1 / 6In Bayes’ rule, P(A|B) is called the…
Pick an answer to see if you are right.
Compute: Bayes’ rule
1 / 3A medical clinic screens for a rare condition that affects about 1.0% of people in this population. Their lab test correctly flags 99% of true cases, but also falsely flags 10% of healthy people. Someone just tested positive. What is the probability they actually have the condition? Round to 2 decimals.
Enter a number (at most 2 decimal places).
Law of total probability
If partitions the sample space (disjoint, cover everything), then:
Think of a tree of outcomes: weight each branch by its probability, then sum. Common DS framing: purchase probability averaged over customer segments.
Law of total probability
1 / 2The law of total probability expresses P(A) as…
Pick an answer to see if you are right.
Compute: total probability
1 / 350% of shoppers today are first-time visitors; each of them buys with probability 0.2. Returning shoppers buy with probability 0.1. What’s the overall purchase probability for a random shopper? Round to 2 decimals.
Enter a number (at most 2 decimal places).
Counting: permutations vs combinations
Counting shows up as “how many ways…?” or as the denominator/numerator of a probability (“four cards of the same suit”).
-
Order matters → permutations:
Example: password character sequences.
-
Order does not matter → combinations:
Example: choosing a set of restaurants from a map.
First decide whether order matters, then apply the right formula. The same ideas appear in combinatorial and graph problems.
Counting
1 / 5Order the usual interview checklist for a counting problem (top = first).
OrderDrag the handle to rearrange — top should be first.
- 1Decide whether order / labels matter
- 2Apply P(n,k) or C(n,k) (or multiply choices)
- 3Read the story (password, committee, hands, …)
Drag items into the correct order (or use ↑↓), then check.
Compute: permutations & combinations
1 / 3A map shows 12 nearby restaurants. You want to pick 3 of them for a weekend crawl (order of the set doesn’t matter). How many choices? (Integer)
Enter a number (at most 0 decimal places).
Random variables, PMF, PDF, and CDF
A random variable is a numeric outcome with a distribution. It is discrete (countable values) or continuous (uncountable range).
| Type | Distribution function | Notation idea |
|---|---|---|
| Discrete | Probability mass function (PMF) |