Transcription
Welcome back. So we are talking about probability, which is essentially computing how likely some event A is to happen. In the simplest case of, you know, poker hands, coin flips, dice rolls, the way we compute these probabilities is to count all of the ways that this event can happen, divided by all of the total number of things that could happen.
So, for example, if I flip a coin 10 times, my event A might be: I get at least five heads. What's the probability of getting at least five heads given 10 coin flips? So I would have to compute—I'd have to enumerate all of the ways I can get five heads, at least five, or six, or seven, or eight, or nine, or 10 heads. And I'd have to enumerate all of the possible ways I could flip a coin 10 times, all of the possible outcomes, and count them. If I did that, I would get the probability of that event happening.
Now, at some point very quickly, these numbers start to become too large to count easily and too large to enumerate easily. There are far too many poker hands to just list all the poker hands and count the probability of getting a straight flush or a full house. So we need to be a little bit more clever in how we count the likelihoods of these events happening. And that's really—like basic probability is all about counting in a clever way. This is super, super closely related to the field of combinatorics. In fact, the word combinations is kind of what we're talking about here: How many combinations of the ways that I could flip 10 coins give me more than five—five or more heads? How many combinations of coin flips are there possible? So largely, this is about counting combinations.
And so I'm going to start with some really simple examples, um, and just a couple of rules and heuristics. Once you master those couple of counting methods or formulas, you're going to be able to compute almost all probabilities in poker, in dice, in backgammon—um, most of the simple kind of games. You'll be able to get a really, really good feeling and intuition for these probabilities, and you'll be able to calculate things much more easily than just enumerating and counting. Okay. Um, good. So I'm just going to start with some really simple examples.
So the first example is: we're going to do coin flips, and we're going to do poker hands, and maybe we'll do things like, you know, how many different unique license plates or Lotto numbers are there, things like that. So, and I'm actually not even going to count probabilities yet. I'm just going to count the number of things that can happen. That's usually the first step: How do I enumerate all of the possible things that can happen? Once you get good at enumerating those things that can happen, and the ways that your event, or your—the thing you're looking for happens, then calculating the probability is easy; you just divide them. Okay.
So we're going to compute the number of sequences of 10 coin flips—of 10 coin flips. So I'm going to flip a coin. I have my very fair coin here. I'm going to flip it 10 times. Going to—okay, it's a heads. I'm going to do it 10 times. Heads, let's see, heads again. Do you think it's a fair coin? That's a statistics question. And I'm going to do that 10 times, and I want to count how many unique sequences of head—of—of coin flips could there possibly be. That's actually the denominator here. Okay, how many unique sequences of coin flips are there? And this is actually a big number. I don't want to enumerate all of them. I could—I could say, okay, well, I could have heads and heads and heads and dot, dot, dot, dot, dot, 10 times—10 heads—and then heads and heads and heads, dot, dot, dot, nine heads and a tails, and I could enumerate all of those, but I need way more than this one whiteboard, and it would be tedious and boring and prone to error. You don't want to count, you know, on your fingers. You don't count on your fingers. You don't count these. We compute how many of these are in a really simple way. I said number of sequences; this means that order matters. I'm going to make a little note of that here. We're saying that order matters. We'll come back to that in a minute. But that means that if my first coin flip is a heads and my second is a tails, that's different than tails heads. Heads tails is different than tails heads. Order matters in sequences.
And so let's say I have 10 coins. Each of these coins is—is independent, meaning there are two outcomes for the first coin; there are two outcomes for the second coin; two outcomes for the third coin, dot, dot, dot, two outcomes for the 10th coin, and they're all independent. So the number of possible outcomes is 2 to the power 10. So the number equals 2 to the power 10. There are 10 samples and two possibilities per sample, and so I just multiply them. The number of things, you know, I could have heads or tails and heads or tails and heads or tails and dot, dot, dot, and you can very quickly—you can make a little tree of the first one, the second one, the third one, and you can convince yourself that this is kind of exponentiated. It's 2 to the power 10 is the total number. So this is when order matters. Let's do another example.
So another example: let's talk about how many five-card hands I could deal off of the top of a 52-card deck. Okay, so—um—a deck of 52 cards; that's what I'm starting with. How many—how many five-card runs can I deal off of that deck? How many five-card runs can I deal off the top of a deck? Okay. And I'm saying this specifically: It's not actually how many hands can I deal. So a poker hand of five cards—the order doesn't matter. It doesn't matter if I get a king then a queen or a queen then a king; it just matters what my five cards are. Here I'm saying that the order actually matters. King, queen, 3, 5, 7 is different than queen, king, 3, 5, 7. Order matters in this scenario. You are the kind of arbiter of what scenario you're counting based on what problem you're trying to solve. So here, um, we're going to say that we have five cards: 1, 2, 3, 4, 5. And for each of these cards—the first card dealt—the first card, there's 52 possible choices. It could be any one of 52 cards. So there's 52 choices here. But once I've dealt that card, there's only 51 cards left for the next choice. Once I have dealt one card, there's only 51 cards left in the deck. So now there's only 51 possible cards for the second card, and once I dealt that one, there's only 50 cards left for the third card, and 49 for the fourth card, and 48 for the fifth card. This is called without replacement. I'm going to put this in parenthesis because this is really important. This is without replacement. And you'll notice that the number—for each sample—the—the—the pool of things I'm sampling out of get smaller and smaller. So some of the lottery—some of the, you know, Powerball lottery—when you pull a number out, it doesn't get replaced, and so the pool gets smaller and smaller. So it would be like this: without replacement. Dealing cards is typically without replacement, whereas in this coin flip, each of those coins we assume it's a fresh new coin. Getting a head on the first coin doesn't mean I can't get a head on the second coin. So we call this with replacement. Okay, good. Okay, perfect. And these have very different probabilities. So without replacement, you'll notice that the probability is 52 * 51 * 50 * 48 * 49 * 48. That's the number of these ordered five-card hands that you could deal off the top of a deck. And there's shorthand for this. We would say that this is equal to 52 factorial divided by 47 factorial. And I'll just remind you that n factorial is n * n - 1 * n - 2 times dot, dot, dot, times 3 * 2 * 1. This is one of the most useful shorthands in probability, in combinatorics. The factorial of an integer is that integer times one smaller times one smaller, dot, dot, dot, all the way down to one. So 5 factorial is 5 * 4 * 3 * 2 * 1. 6 factorial is 6 * 5 * 4 * 3 * 2 * 1. 52 factorial is 52 * 51 * 49 * 48 * 47 all the way down. And if I divide it by 47 factorial—in fact, this is a good kind of homework problem for you, or just like pause the video and do this—write out 52 factorial divided by 47 factorial, and you'll see that all of them—a lot of them cancel out, and all that you're left with is 52 * 51 * 50 * 49 * 48. Good. Okay, perfect. So we are—um—doing good here. So now I'm going to codify this into some formulas. This was for a very specific—this was for 10 coin flips; this was for 52 cards sampled into five-card hands. What if I wanted to make this more general? What if I have—I'm sampling—I have n choices, and I'm sampling r elements from those n choices? So here my coin flips, n would equal two. There are two—there's heads and tails, so n equals 2, and r equals 10. There are 10 kind of independent trials. So the number here is r—sorry—n to the power r. I have two choices, and I'm sampling it 10 times. There's 2 to the 10th. Down here, this is without replace—with replacement. Without replacement, in the poker example, the number is—uh—okay, so number of choices is 52, so it's n factorial divided by n - r factorial. So it's the number of choices—the number of cards in my deck—that's 52 factorial divided by 52 - 5 factorial. Five was the number of cards I'm sampling. These are super, super useful formulas. Okay, this is all—uh—when order matters. Order matters in both cases. And I'm just going to give you one last thing to think about: If order doesn't matter—uh—if order doesn't matter. So now let's say I have five cards. I have king, queen, queen, 2, 3, 7. That's identical to king, 2, queen, 7, 3. Let's say that those are the same, you know, if I get dealt a poker hand, I get to move the cards around and find the best hand I have—make it a straight or a full house or a flush or whatever. So the order of an actual hand doesn't matter. The order of a run of a sequence matters; the order of a hand doesn't matter. This number—and this is called—so this is when order doesn't matter—doesn't—I just wrote it—or if order doesn't matter, then I take this number, which is n factorial / n - r factorial, and I divide it by another r factorial. So the difference between order mattering and order not mattering is dividing by this r factorial. And the way you can convince yourself of it is: is I count all of these unique sequences to be equal if they have the exact same cards inside the sequence. If I can shuffle them and they're the same, and so there are r factorial ways of permuting—this is called permutation—there are r factorial permutations of these five cards. There are five factorial ways of permuting these five cards uniquely, and we would say that those are all equivalent hands. This hand is equivalent to this hand; it's equivalent to flipping those two. The order doesn't matter, and there are r factorial ways of permuting that hand and still having it be the same hand. And so that basically means that when I'm counting these sequences, for each—um, you know, sequence—there are r factorial equivalent hands with the same cards. So I want you to slow down and think about that. This is a really, really important point. This is the difference between—um—kind of total sequences where order does matter and total hands where order doesn't matter. And this is a really, really important number. This number is called n choose r. Sometimes we write it as n choose r. It's a really important shorthand we use to calculate—um, you know—hands of r samples out of n choices without replacement. So this is something you're going to have to think about; you're going to have to try a lot of examples; build intuition; get good at doing this. And if you do, you'll be able to—you know—calculate these odds in your head. You'll be able to calculate the odds when you're playing backgammon more easily.
Some examples to think about: License plates is a good one. So this is just an example you can do—um—as kind of a homework: Let's say—um—my license plates—let's say that I have a license plate where it's four letters and two numbers. So these are letters—uh—from A to Z; there's 26 of them. These are numbers—let's say—from 0 to 9; there's 10 of them. How many total possible license plates are there? Okay, well, you know, there are—so let's first off think: Does order matter in a license plate? Clearly yes, order matters. So we're not going to use this formula; we're going to use one of these formulas. Order matters. And is it with replacement or without replacement? If I have a K for my first letter, can I have a K for my second letter? I don't know, like—um—that might be a decision based on the state or, you know, I think realistically, yes, you could use the same letter twice. I can have AABB99; that's a totally legit license plate. So I think it's order matters with replacement. So you could compute this under those assumptions of order mattering with replacement. Also, you could run the thought experiment: What if they don't let me use the same letter twice or the same number twice? Now we're without replacement. How do you compute that probability? Okay. Um, and things like that. So, and then another one: Let's assume that it is with replacement, so I can have AAAA11, for example. What's the probability that I don't have a repeated letter? What's the probability that all four letters are unique? That's the kind of thing you can count and the kind of thing you can compute now that you have these basic tools of factorials and powers—with replacement, without replacement, order matters, order doesn't matter. Almost everything—uh, you know—in basic probability is a generalization of this idea here. So very soon we're going to start looking at much more complicated distributions. You know, if I wanted to compute the number of—you know—the—of sequences of a thousand coin flips, I would never enumerate them, but I could use this formula. So we're going to start using these to build more sophisticated probability models that model more real-world scenarios very soon. Thank you.