Probability Fundamentals


Probability Fundamentals

Michael
Good afternoon, everyone. Before we get into probability, a couple of course notes: Problem Set One is out and due Friday, with a short grace period. Section assignments are going out today; if you need to swap times, check the course post. And there’s a new, optional feature in the problem-set app that pairs students for a short video chat. It’s an experiment, not part of your grade.

Maria
And the bigger academic reminder is that last week we built counting tools: permutations, combinations, and putting objects into groups. Counting can produce enormous numbers—for example, the number of possible orderings of 52 distinct cards is 52 factorial. Today we’ll use those counting ideas to reason about probability.

Michael
Let’s start with the third probability axiom. For two mutually exclusive events, the probability that either one happens is the sum of their probabilities. Mutually exclusive means there is no outcome that belongs to both events.

Maria
So if event E contains seven outcomes out of 50 equally likely outcomes, and event F contains four different outcomes out of those same 50, then the probability of E or F is seven-fiftieths plus four-fiftieths: eleven-fiftieths. The key is that those outcome sets don’t overlap.

Michael
Right. The same addition rule works for any collection of mutually exclusive events. But if events overlap, adding their probabilities directly would count the shared outcomes twice, so the mutually exclusive condition matters.

Maria
Here’s a useful consequence: the probability that an event does not happen is one minus the probability that it does happen. E and not E are mutually exclusive, and together they cover the entire outcome space. Their probabilities therefore add to one, which gives us the complement rule.

Michael
That rule can make a counting problem much easier. Suppose Stanford has 17,000 people, you know about 100 of them, and 268 people are chosen uniformly at random. Rather than count every way at least one friend could appear, start by counting the easier event: none of your friends appear.

Maria
The total number of possible groups is 17,000 choose 268. To get a group with no friends, choose all 268 people from the 16,900 people you don’t know. So the probability of seeing no friend is 16,900 choose 268 divided by 17,000 choose 268.

Michael
That ratio is about 0.20. So the chance of seeing at least one friend is one minus 0.20, or about 0.80. The general strategy is to ask whether the event or its complement is easier to count.

Maria
Now let’s introduce conditional probability—the probability of an event after we’ve learned that some other event has happened. Imagine rolling two dice and being told their sum is four. The possible ordered outcomes are one-three, two-two, and three-one.

Michael
Before we know anything about the roll, there are 36 equally likely ordered outcomes, and three have a sum of four. So the probability of a sum of four is three out of 36, or one-twelfth.

Maria
But suppose we learn that the first die is two. Now only six outcomes are possible: two-one through two-six. Exactly one of them, two-two, sums to four. So the probability of a sum of four, given that the first die is two, is one-sixth.

Michael
The observation shrinks the sample space to outcomes consistent with what we know. It also shrinks the event we’re counting to outcomes that are both consistent with that observation and part of the event we care about. If the first die is one or three instead, the conditional probability is also one-sixth.

Maria
We write the probability of E given F as P of E given F, with a vertical bar between the events. It means we’re asking for the probability of E in the world where F is known to have happened. The definition is P of E given F equals P of E and F divided by P of F, as long as P of F is not zero.

Michael
Rearranging that definition gives the chain rule: P of E and F equals P of F times P of E given F. You can also write it as P of E times P of F given E. Both versions express the probability that both events happen.

Maria
It’s important not to confuse the two questions. P of E and F asks for the chance both happen, without saying either one has already happened. P of E given F asks for the chance of E after we know F happened. And P of E or F asks whether at least one happens.

Michael
The order matters for conditional probabilities. The chance a baby cries given that she has pooped is not generally the same as the chance she has pooped given that she cries. Those describe different situations and condition on different information.

Maria
Netflix gives us another way to picture conditioning. The probability that a user watches a particular movie can be estimated by counting what fraction of users watched it. But a more informative question is: what is the probability they watch Life Is Beautiful, given that we know they watched CODA?

Michael
For that conditional probability, we count users who watched both movies and divide by users who watched CODA. Learning that someone watched CODA can change our estimate for another movie—up or down. Conditional probabilities let us update what we believe when we observe relevant information.

Maria
You can ask that question about any two events, even movies that seem unrelated. The answer may show that the observation makes the event more likely, less likely, or doesn’t change it. Probability gives us a way to quantify the relationship, even before we explain why it exists.

Michael
Let’s practice the chain rule with a baby example. Suppose there’s a 50 percent chance the baby has pooped, and, given that she has pooped, there’s a 50 percent chance she cries. The probability she both poops and cries is 50 percent times 50 percent, or 25 percent.

Maria
That multiplication works because the second probability is conditional on the first event. And we can extend the chain rule: the probability that three events all happen equals the probability of the first, times the probability of the second given the first, times the probability of the third given the first two.

Michael
In words, we move step by step: first event, then second event in the world where the first happened, then third event in the world where the first two happened. Multiplying those successive conditional probabilities gives the probability that all three occur.

Maria
Now suppose we want the probability that the baby cries, but we only know the chance she poops and the chance she cries given poop. We’re missing what happens in the other case: the chance she cries given no poop.

Michael
That leads to the law of total probability. The baby can cry in either of two mutually exclusive situations: she cries and has pooped, or she cries and hasn’t. Add those two probabilities to get the overall probability that she cries.

Maria
Using the chain rule on each case, P of crying equals P of crying given poop times P of poop, plus P of crying given no poop times P of no poop. The two background cases—poop and no poop—cover the whole space.

Michael
For example, if the chance of poop is one-half, the chance of crying given poop is one-half, and the chance of crying given no poop is one-eighth, then the chance of no poop is also one-half. The total chance of crying is one-half times one-half, plus one-eighth times one-half: five-sixteenths.

Maria
Notice that knowing the crying chance in one situation doesn’t tell us the crying chance in the other. The two conditional probabilities are separate pieces of information. The law of total probability combines them by accounting for every possible background case.

Michael
The same method works for bacteria. Let M mean a bacterium has a mutation and S mean it survives. Suppose 10 percent have the mutation, 20 percent of mutated bacteria survive, and 1 percent of bacteria without the mutation survive.

Maria
To find the overall probability of survival, split into the two cases: survival with a mutation and survival without one. That gives P of S equals P of S given M times P of M, plus P of S given not M times P of not M.

Michael
Substitute the values: 0.20 times 0.10, plus 0.01 times 0.90. That’s 0.029, so the probability a bacterium survives is 2.9 percent. A reliable approach to these word problems is to define the events, list the probabilities given, then choose a rule that connects them to the probability you want.

Maria
And inside the world where a condition is known to be true, the probability rules still apply. For example, given that a bacterium has a mutation, it either survives or doesn’t, so those two conditional probabilities add to one.

Michael
Often, though, the question we really care about reverses the direction of the information. We know the chance of an observation given a state of the world, but want the chance of that state given the observation. Bayes’ theorem gives us a way to make that reversal.

Maria
Bayes’ theorem follows from writing the chain rule in two ways. P of E and F equals P of E given F times P of F, and it also equals P of F given E times P of E. Equating those expressions and rearranging gives P of F given E equals P of E given F times P of F, divided by P of E.

Michael
If P of E is hard to find directly, we can expand it with the law of total probability. Since F and not F cover all possibilities, P of E equals P of E given F times P of F, plus P of E given not F times P of not F. That gives the expanded version of Bayes’ theorem.

Maria
In that formula, P of F is often called the prior: our probability of F before observing E. P of F given E is the updated probability after we see the evidence. The conditional probabilities describing how likely the evidence is in each case help us update that prior.

Michael
Spam detection is a classic example. Let F mean an email is spam and E mean it contains the word “dear.” We may know the fraction of email that is spam, the chance spam contains “dear,” and the chance non-spam contains “dear.” Bayes’ theorem combines those to answer the question we actually care about: the chance an email is spam given that it contains “dear.”

Maria
A medical test shows why the prior matters. Suppose 0.5 percent of the population has a disease, a test correctly returns positive for 98 percent of people who have it, and 1 percent of people without it get a false positive. We want the probability someone has the disease given that the test is positive.

Michael
Bayes’ theorem puts the probability of a true positive in the numerator: 0.98 times 0.005. In the denominator, we add all the ways to test positive: that true-positive probability, plus the false-positive probability, 0.01 times 0.995.

Maria
That comes out to about 0.33, or one chance in three. It can feel surprising, because the test is quite accurate. But the disease is rare, so the much larger group without the disease produces enough false positives that they make up most of the positive results.

Michael
Picture a thousand people. About five have the disease, and around 98 percent of them test positive—roughly five people. Of the 995 without it, about one percent, or roughly ten people, test positive. Among all the positive results, only about one-third come from people who actually have the disease.

Maria
That’s why a test result is evidence, not always a conclusive answer. Bayes’ theorem combines the test’s behavior with how common the condition is in the first place. The same idea is useful in data analysis and computer science, where we observe evidence and update beliefs about something we can’t directly see.

Michael
One final practice question: suppose three-quarters of a group know a concept. People who don’t know it have a one-in-four chance of guessing a multiple-choice answer correctly, and people who do know it sometimes make mistakes. How would we find the chance someone knows the concept, given that they answered correctly?

Maria
Use Bayes’ theorem. The prior is the chance the person knows the concept. The likelihood is the chance of a correct answer given that they know it, and we also need the chance of a correct answer given that they don’t. Then the denominator combines those two routes to a correct answer using total probability.

Michael
So the core toolkit is: count equally likely outcomes when that’s appropriate; use the complement when it’s easier; condition by restricting attention to what you’ve observed; use the chain rule to connect joint and conditional probabilities; use total probability to split into cases; and use Bayes’ theorem to reverse the direction of conditioning.

Ask anything
We've read this whole study set, so questions about it get the best answers.