If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Example: Combinatorics and probability

Probability of getting a set of cards. Created by Sal Khan and Monterey Institute for Technology and Education.

Want to join the conversation?

  • blobby green style avatar for user Krishna Israney
    While calculating # of hands with 1's , we use 32x31x30x29x28 as the numerator which seems obvious. However since the arrangement of 1's and the remaining cards does not matter , should the denominator not be 9 factorial ?
    (79 votes)
    Default Khan Academy avatar avatar for user
    • leaf blue style avatar for user Cameron Christensen
      No. I was initially confused here as well. Here's the reasoning, I think:

      We know our hand will have four 1s in it. This is given. If the size of our hand were just four cards, there would be exactly one way to do this. That would be easy. Unfortunately, we have 5 other cards in our hand as well, which make this more complicated (and interesting).

      Sal took this idea (the idea that there is only one way way to have all of the ones if our hand only had four cards), and he built from there. The question then became how to fill the other five "slots" in our hand, which turns out to be (32*31*30*29*28)/(5!). We can essentially ignore the four 1s because we already accounted for them by assuming we had them from the outset.


      A simpler example:
      A simpler example might examined a 2-card hand (perhaps we're playing blackjack or something). Using a standard deck of cards, what would the probability be of having the four of hearts in your 2-card hand? Well, you can start by assuming you have the four of hearts, then figure out how many options you would have for the other card in your hand. This would tell you the total number of hands you could have (52 minus the four of hearts = 51). Then, just divide this by the total number of possible hands and you have your answer.

      This is essentially the same thing Sal did, but instead of assuming he had just one card in his hand at the outset, he assumed he had all four 1s. Then, all he had to do was figure out how many 9-card hands he could have based on that assumption.

      Yikes! That explanation got kinda long! I hope it helped :-)
      (121 votes)
  • male robot hal style avatar for user toviabd85
    wouldn't it be easier to explain it this way: ((4 C 4) * (32 C5)) / (36 C 9) = 2/935?
    (100 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user mwholz65432
    Isn't the number of ways to arrange a hand with 4 1's and 5 non-1's be 9 factorial rather than 5 factorial?
    (15 votes)
    Default Khan Academy avatar avatar for user
    • blobby green style avatar for user Philip Moseman
      SAL is CORRECT and I can prove it...

      The event he explained is getting all four 1's in a hand of 9, out of 36 cards numbered 1 through 9 and of four suits. If it is correct, then the odds of getting three 1s, two 1's, one 1's, and zero 1's should all be calculated in the exact same way.(1)
      Then, when all the possibilities are added together, they should have a 100% chance of success.(2)
      Each of these events are mutually exclusive and cover the range of ALL possible hands:
      4, 3, 2, 1, and 0 ones in a hand. (3)
      *
      I believe we all agree:
      36*35*34*33*32*31*30*29*28 / 9*8*7*6*5*4*3*2*1
      covers all the possible hands.
      This can be written as, "36 choose 9." Which is found by 36! divided by 27! and 9!
      OR
      36! / ( [36-9]! * 9! )
      AND
      It could also be written 36 choose 27... since we are in a sense choosing 27 cards NOT to be in the hand. (Written much the same way).
      I am not trying to confuse anyone! All these previous statements (*) are equivalent and are all equal to 94,143,280. They all mean the exact same thing and will make this MUCH easier to write.

      What Sal is doing when he says 1*1*1*1 for the four 1's in the hand, is 4 choose 4. Or counting how many ways to choose 4 cards for 4 slots, all at once.
      This is written out mathematically as:
      4!/( [4-0]! * 0!)
      Because 0! = 1 (and only just because) we wind up with 4!/4! which is equal to 1.
      1*1*1*1 = 1
      And your intuition should tell you, there is only one way to "4 choose 4."

      Intuition is so-so. You should really remember how the formula works (that is all Liebniz did...)
      For example, we can't 4 choose 9, because then you end up with (-5)! which is undefined, but you can do 4 choose 0; only because 0! = 1. So your intuition doesn't work... neither does math evidently, because how can you choose 4 cards to fill 0 slots and not 9 and multiply 0 by something to equal 1???
      That's Leibniz for you! And I should also remind you this was invented as a way to cheat at cards.

      So, then we have 32 cards left to freely choose from. There are 5 slots to place them in A.K.A. 32 choose 5.
      You then do permutations of 4 choose 4 times 32 choose 5. Which is real exciting, because 4 choose 4 = 1.

      Yes, this is exactly what Sal has proposed. (4)

      So we use the same logic for all the possible hands: 4, 3, 2, 1, and 0 ones.
      4 choose 4 * 32 choose 5
      4 choose 3 * 32 choose 6
      4 choose 2 * 32 choose 7
      4 choose 1 * 32 choose 8
      4 choose 0 * 32 choose 9

      (It is an excellent question that you asked.)
      When you add each of the 4 possible hands above you get 94,143,280.
      I did not fudge on this one either! I got it right the first time! I am strongly convinced that Sal is correct...
      (32 votes)
  • blobby green style avatar for user Stuart B.
    I am perplexed. I would have thought that the probability is: The number of ways four ones could combine in 9 cards divided by the total number of combinations which could occur. I understand that the denominator should be 36! / (9! x 27!). But why isn't the numerator 9! / (4! x 5!) ? That given numerator would be the number of ways one could combine four ones into 9 cards regardless of order. That number over the total number of combinations possible regardless of order should give the probability of getting four ones. That comes out to 9 / 6,724,520. Why is my numerator incorrect? I just don't get it. Please help and explain. Thanks.
    (13 votes)
    Default Khan Academy avatar avatar for user
    • blobby green style avatar for user baba.sariffodeen.1
      I hope I can shed some light on this.

      Let's start at the beginning. We want to know the probability of getting all four 1's in our hand of nine cards. And just to be clear, imagine you are holding some cards in your hand... You would still have the same cards in your hand even if you switch a few around. Does this make sense? For example, say I have a Queen, a Jack and a Spade. If I switch these around in my hand, I still have those three cards to play the game, right? THAT's what Sal means when he says 'the order does not matter'... Okay so let's continue.

      We have 36 cards, and 9 'places'. The total number of possible ways we can get 36 things in 9 places is: 36!/27! But since we would be over-counting as the order does not matter, we need to divide through by 9!. This gives us the 36! / (27! x 9!) that you say you understood.

      So let's move on to the numerator.

      We have 36 cards. We want four of the 1's in our hand. Since order does not matter (same logic as above), there's really only one way I will have four 1's (treat them as quadruplets that we can treat as one entity for the time being). So for example...

      1, 1, 1, 1, something else, something else, something else, something else, something else

      The remaining 5 places we need to look at. Providing we have the four 1's, we must see how many outcomes there are for the remaining 32 cards in 5 places. That is 32!/ (32-5)!. But again, we would be over-counting since order does not matter. And therefore we must divide by a futher 5!. This then becomes 32! / (32 - 5)! x 5!

      SO TO FINALLY PUT EVERYTHING TOGETHER:

      [ 32! / (32-5)! x 5! ] ALL DIVIDED BY [ 36! / (36-9)! x 9!] GIVES US 2/935 !
      (31 votes)
  • purple pi purple style avatar for user Bill Slobotski
    I really didnt follow this video very well after having followed all of Sal's probability videos up to this point. I tried to solve this problem doing it in a way that seemed logical to me, and voila I got the same answer Sal did!

    Basically, I calculated the odds of drawing 4 ones out of 36 cards, and multiplied that result times (9 choose 4), which is the number of ways that these 4 can be organized in 9 positions.

    1. The probability of drawing the 1st one is 4/36
    2. The probability of drawing the 2nd one is 3/35
    3. The probability of drawing the 3rd one is 2/34
    4. The probability of drawing the 4th one is 1/33

    Multiplying these 4 numbers together and then multiplying this result with (9 choose 4), which is 126 will give you 2/935 , the same number Sal got.

    I now need to see how a method that is totally logical to me fits into the method that he did which isnt obvious at all! The beauty of logic and math!
    (18 votes)
    Default Khan Academy avatar avatar for user
    • duskpin ultimate style avatar for user Anwar
      Here's a simpler way to solve this problem without using combinatorics at all. We want 4 specific cards out of 36 in a hand of 9 cards: 1♥️, 1♦️, 1♠️, and 1♣️.

      1. What is the probability of getting 1♥️ in 9 cards? We have 36 different cards, only one of them is 1♥️, and 9 chances to get it. It's 9 out of 36 or 9/36.

      2. Now what is the probability of getting 1♦️? These are dependent events because we don't put the cards back into the deck. So, if the first event happens we would have 35 cards left in the deck and 8 spots to fill in our hand. That's 8 out of 35 or 8/35.

      3. If events 1 and 2 happen, we would have 34 cards left and 7 empty spots in our hand. The probability of getting 1♠️ would be 7 out of 34 or 7/34.

      4. Similarly, given the events 1, 2, and 3, the probability of getting 1♣️ would be 6 out 33 or 6/33.

      We want 4 of these events to happen and we don't care about the rest of the 5 cards in the hand, so we multiply the 4 probabilities: 9/36 * 8/35 * 7/34 * 6/33 = 2/935. The same would apply to any 4 unique cards out of 36 in a hand of 9 cards.
      (19 votes)
  • blobby green style avatar for user juan.gotsis
    I don't understand why this video uses a different methodology than in previous problems. I’ll use a couple of examples to illustrate my confusion:

    A) When we're asked to find the probability of exactly 3 heads after 5 flips of a coin, we figure out the # of successes using the combination 5 nCr 3 (5 choose 3). The intuition being that there are 5 events and we need 3 heads.

    B) On the other hand, in this card problem when we want to find the # of successful outcomes we use the combination 32 nCr 5 (32 choose 5). The intuition being that AFTER our 4 cards have been drawn, there are 5 cards that can complete the hand and make up a combination.

    It seems to me that by following the logic in A) and applying it to B), we should be using the combination 9 nCr 4 (9 choose 4); intuition being that there are 9 events and we need 4 cards of “1’s”.

    So, why is it that we are using a different resolution?
    (9 votes)
    Default Khan Academy avatar avatar for user
    • mr pink red style avatar for user Jean Rambo
      I had trouble understanding this too, but I think I know why we can't use the method "A".

      You could use 5 nCr 3 for the flip of coins problem because you wanted to identify all the positions three Heads could be arranged in. You then divided this by the total number of possible outcomes of five flips and you're done.

      Now, for the cards problem, if you say 9 nCr 4, you're saying one of two things:
      1 - The number of arrangements four 1s can be in, in a 9 card hand; which does not matter, because we only care as long as there's 1 arrangement, unlike the coin flips problem.
      2 - The number of possible four card combinations for a hand of 9 cards; which we are not looking for.

      You see, 9 nCr 4 does not account for the fact that for the other 5 spots that make up your hand, there could be any of the other 27 cards still in the deck. This has to be taken into consideration if you're looking for the total number of hands that have four 1s, because this total depends on all the possible combinations of cards that those last 5 spots can have.

      It was hard for me to grasp it. I hope this explanation helped :(
      (5 votes)
  • female robot ada style avatar for user Candicane
    I'm so confused. What's the difference between in order and not in order?? He mentioned that at .
    (5 votes)
    Default Khan Academy avatar avatar for user
    • purple pi purple style avatar for user zella
      If order matters in the problem, I'm pretty sure it's classified as a permutation. If it doesn't, it's combinations. The difference is whether or not the numbers must be in order, like if I have three heads, Head A, B, and C, and their places in the problem are not interchangeable.
      (5 votes)
  • leaf red style avatar for user Tommy
    The last part confused me for a moment, but:
    (32*31*30*29*28) / (5*4*3*2*1)
    is the same as:
    32! / 5!(32-5)!
    Is this right?
    (3 votes)
    Default Khan Academy avatar avatar for user
  • duskpin sapling style avatar for user Nathan Young
    Before Sal explained. I came up with 9C4/36C4 which value is the same as the video. I worked out in a difference approach. First I found that the probability of getting first 4 1s and 5 of any other cards (in order) is 1/36C4 (4/36 for the 1st card, 3/35, 2/34 and 1/33 for 2nd, 3rd and 4th. And for the next 5 non-1 cards always going to be 1). And multiply by the difference ways that the 4 1-cards of 9 cards can be rearrange, which is 9C4.

    Am I right for doing it this way?
    (4 votes)
    Default Khan Academy avatar avatar for user
  • leaf blue style avatar for user jmquinn
    If the first 4 cards in the hand that is dealt to me are 4s, this makes sense. But what if the last 4 cards are the 1s? Why is the last step/combination wrong if we go with 36C5 instead of 32C5?
    (3 votes)
    Default Khan Academy avatar avatar for user
    • mr pink red style avatar for user Jean Rambo
      It is the same whether the four 1s are in the beginning, the end, or anywhere in between. Why? Because what determines the combination of hands that have four 1s in them is the total combinations of cards that the remaining 5 spots of the hand can make up. Remember, for each combination of those remaining 5 spots, there are four 1s attached to them; thus making a different hand with four 1s each time.

      Also, you can't say 36 nCr 5 because you are counting within those 36 the four 1s that you already discounted from the deck by saying that you choose only 5 (which is the number of spots left when you already have four 1s).

      Hope this helped.
      (3 votes)

Video transcript

A card game using 36 unique cards, four suits, diamonds, hearts, clubs, and spades, with cards numbered from 1 to 9 in each suit. So there's four suits. Each of them have nine cards, so that gives us 36 unique cards. A hand is a collection of nine cards, which can be sorted however the player chooses. So they're essentially telling us that order does not matter. What is the probability of getting all four of the 1's? So they want to know the probability of getting all four of the 1's. So all four 1's in my hand of 9. Now this is kind of daunting at first. You're like, gee you know, I've got nine cards and I'm taking them out of 36 and I have to figure out how do I get all of the 1's. But if we think about it just very, very, in very simple terms, all a probability is saying is, the number of events-- or I guess you could say-- the number of ways in which this action or this event happens. So this is what the definition of the probability is. It's going to be the number of ways in which event can happen and when we talk about the event, we're talking about having all four 1's in my hand. That's the event. And all of these different ways, that's sometimes called the event space. But we actually want to count how many ways that, if I get a hand of 9 picking from 36, that I can get the four 1's in it. So it is the number of ways in which my event can happen and we want to divide that into all of the possibilities-- or maybe I should write it this way-- the total number of hands that I can get. So the numerator in blue is the number of different hands where I have the four 1's and we're dividing the total number of hands. Now let's figure out the total number of hands first, because on some level this might be more intuitive and we've actually done this before. Now, the total number of hands, we're picking nine cards. And we're picking them from a set of 36 unique cards. And we've done this many, many times. Let me write this, total number of hands, or total number of possible hands. That's equal to-- you can imagine, you have nine cards to pick from. The first card you pick, it's going to be 1 of 36 cards. Then the next one is going to be 1 of 35. Then the next one is going to be 1 of 34, 33, 32, 31. We're going to do this nine times, one, two, three, four, five, six, seven, eight, and nine. So that would be the total number of hands if order mattered. But we know-- and we've gone over this before-- that we don't care about the order. All we care about are the actual cars that are in there. So we're overcounting here. We're overcounting for all of the different rearrangements that these cards could have. It doesn't matter whether the Ace of diamonds is the first card I pick or the last card I pick. The way I've counted them right now, we are counting those as two separate hands. But they aren't two separate hands, so order doesn't matter. So we have to do is, we have to divide this by the number of ways you can arrange nine things. So you could put nine of the things in the first position, then eight in the second, seven in the third, so forth and so on. It essentially becomes 9 factorial times 2 times 1. And we've seen this multiple times. This is essentially 36 choose 9. This expression right here is the same thing-- just you can relate it to the combinatorics formulas that you might be familiar with-- this is the same thing as 36 factorial over 36 minus 9 factorial-- that's what this orange part is over here-- divided by 9 factorial or over 9 factorial. What's green is what's green and what is orange is what's orange there. So that's the total number of hands. Now a little bit more of a nuanced thought process is, how do we figure out the number of ways in which the event can happen, in which we can have all four 1's. So let's figure that out. So number of ways-- or maybe we should say this-- number of hands with four 1's. And just as a little bit of a thought experiment, imagine if we were only taking four cards, if a hand only had four cards in it. Well if a hand only had four cards in it, then the number of ways to get a hand with four 1's, there'd only be one way, one combination. You'd just have four 1's. That's the only combination with four 1's, if we were only picking four cards. But here, we're not only picking four cards. Four of the cards are going to be 1's. One, two, three, four. But the other five cards are going to be different. So one, two, three, four, five. So for the other five cards-- if you imagine this slot-- considering that of the 36 we would have to pick four of them already in order for us to have four 1's. Well, we've used up four of them, so there's 32 possible cards over in that position of the hand. And then there'd be 31 in that position of the hand. And then there'd be 30 because every time we're picking a card, were using it up. And now we only have 30 to pick from. Then we only have 29 to pick from. And then we have 28 to pick from. And just like we did before, we don't care about order. We don't care if we pick the 5 of clubs first or whether we pick the 5 of clubs last. So we shouldn't double count it. So we have to divide by the different number of ways that five cards can be arranged. So we have to divide this by the different ways that five cards can be arranged. The first card or the first position can be any one of five cards, then four cards, then three cards, then two cards, then one cards. So the number of hands with four 1's is actually just this number. You're actually looking at all of the different ways you can fill up the remaining cards. These four 1's are just going to be four 1's. There's only one way to get that if the remaining cards that's going to give all of the different combinations of having four 1's. So this will be a count of all of the different combinations because all of the different extra stuff that you have will be all of the different hands. Now we know the total number of hands with four 1's is this number. And now we can divide it by the total number of possible hands. And I didn't multiply them out on purpose so that we can cancel things out. So let's do that. Let's take this and divide by that. So let me just copy and paste it. Let's take that and let's divide it by that. But dividing by a fraction is the same thing as multiplying by the reciprocal. So let's just multiply by the reciprocal. So let's multiply-- so this is the denominator. Let's make this the numerator. So let me copy it and then let me paste it. So that's the numerator and then that's the denominator up there. Because we're dividing by that expression. So let me-- whoops. Let me put that there. Let me get the select tool and then let me make sure I'm selecting all of the numbers. Let me copy it and then let me paste that. It's a little messy with those lines there, but I think this'll suit our purposes. This'll suit our purposes just fine. So when we're multiplying by this, we're essentially dividing by this expression up here. Now this we can simplify pretty easily. We have a-- well actually I forgot to do-- this should be 9 factorial. This should be 9 times 8 times 7 times 6 times 5 times 4 times 3 times 2 times 1. Let me put that in both places. Actually let me just-- let me clear that both places. Clear. Don't want to confuse people. Clear. I'm sorry if that confused you when I wrote it earlier. This would be 9 factorial. 9 times 8 times 7 times 6 times 5 times 4 times 3 times 2 times 1. Let me copy and paste that now. Copy and then you paste. It That's that, right there. And then we have this in the numerator. We have 5 times 4 times 3 times 1 in the denominator. So this will cancel out with that part right over there. And then we have 32 times 31 times 30 times 29 times 28. That is going to cancel with that. That and that cancels out. So what we're left with is just this part over here. Let me rewrite it. So we're left with 9 times 8 times 7 times 6 over-- and this will just be an exercise in simplifying this expression-- 36 times 35 times 34 times 33. And let's see, if we divide the numerator and denominator by 9, that becomes a 1, this becomes a 4. You can divide the numerator and denominator by 4, this becomes a 2. This becomes a 1. You divide numerator and denominator by 7, this becomes a 1, this becomes a 5. You can divide both by 2 again and then this becomes a 1. This becomes a 17. And you could divide this and this by 3. This becomes a 2 and then this becomes an 11. So we're left with, the probability of having all four 1's in my hand of 9 that I'm selecting from 36 unique cards is equal to-- in the numerator, I'm just left with this 2 times 1 times 1 times 1-- so it's equal to 2 over 5 times 17 times 11. And that is-- so drum roll, this was kind of an involved problem-- 5 times 17 times 11 is equal to 935. So it's equal to 2 over 935. So about roughly 2 in a thousand chance or 1 in a 500-- roughly speaking, this isn't exact odds-- you have a roughly 1 in 500 chance of getting all four of the 1's in your hand of 9 when you're selecting from 36 unique cards.