 Welcome to our lecture on the binomial distribution. Permutation is a particular arrangement. For example, if I ask you how many ways can you range letters A, B and C? Well, I'm listing all the permutations or arrangements. A, B, C is different from A, C, B different arrangements. You can also do this B, A, C or B, C, A, B or C, B, A. So you really have six ways to arrange the letters A, B, C. Using a calculator, you'll see it will be 3 permutation, 3. Okay, now we know 3 permutation, 3 is 6. Well, how do we know that? Okay, first N is how many objects, in this case letters? How many we have? There were three letters, A, B and C. Then we have R, which is going to be the number of slots, the three slots. Okay, so let's look at this. We have three letters, A, B or C. So in the first slot, we have a choice. We put an A, a B or a C. Suppose in slot one, we used an A. Now in slot two, we have a choice of B or C. Suppose we use the B for slot two. Well, that's left to C. So there's your first arrangement, A, B, C. If you start over with an A and then a slot two, you put a C. And nothing left, except for a B, which goes to slot three, A, C, B. Suppose you started with a B in slot one. Well, in slot two, you can put an A or a C. Let's see who started with an A in slot two. B, A, now all that's left is C. You've got B, A, C. If in slot two, you put the C after the B, so you have B, C. You must have an A that's all left. You've got B, C, A. This is called a tree diagram, actually, if you can do it, you'll see. So that's how we know that three permutation three ends up being three factorial. Three times two times one. So three permutation three is three factorial. If you look at your scientific calculator, you'll see an NPR key. P stands for permutations. N is the number of distinct objects before we had A, B, and C. So these are the objects you want to arrange, and R is the number of slots or spaces. So the previous example, we had three objects, A, B, C, to range in three slots, and that becomes three permutation three, which is three factorial, which is three times two times one, which is six. The general formula for permutation is NPR is N factorial divided by N minus R factorial. Thus, when N equals R, then NPN is just N factorial. And the way you read a factorial is shown to you, but let's do it with numbers. Ten factorial is ten times nine times eight times seven times six times five times four times three times two times one, which is more than three million. It's three million, six hundred, twenty-eight, eight hundred. So it's a large number. Six factorial is six times five times four times three times two times one or seven, twenty. It's actually surprising how large these numbers become. If you try fifty factorial, it's going to mean a credibly large number. Let's look at some problems. How many ways can you assign five workers to five different tasks? Well, that's five P five, which is five factorial, five times four times three times two times one, which is one twenty. Again, you have a factorial key, so you can just get it directly. One twenty. How many ways, example two, how many ways can you arrange ten different books in your bookcase? And suppose it only has room for five books, that's like the slots, spaces. So we have ten per mutation five, remember the second number is the slots. So it's ten per mutation five, and that turns out to be ten times nine times eight times seven times six. The five four three two one is cancelled out by the denominator. But if you just put it in your calculator, you get thirty thousand two forty. For example three, how many ways can eight cars line up single file in front of a toll booth? You can resume this space for eight. So it's eight per mutation eight, because there are eight spaces and there are eight cars, which is eight factorial, which is forty thousand three hundred and twenty. The fourth example, how many ways can you arrange twelve guests around the table as twelve chairs? Well, the chairs are now like the slots, so the spaces. So N is twelve, the twelve guests, you want to put them around the table as twelve chairs? That's twelve per mutation twelve, which is twelve factorial. And look at the incredible number that is, four seventy nine million six hundred. And now you can see why so many family feuds occur when it comes to seating family members at weddings or bar misfits or whatever family event you have. So many ways to arrange them and if your family is like my family, somebody is always going to say, why did you seat me next to Jane? You know I haven't talked to her in seven years. Why did you seat my daughter next to Ellen? You know they don't get along, things like that. But look how hard it is. You know twelve per mutation twelve is more than four hundred seventy nine million. Well now we're going to talk about permutations and combinations. Permutations, the arrangement of the items is important. Each unique sequence is another permutation. Thus ABC is not the same as BCA, which is not the same as CBA. You just change around the arrangement the way it's ordered and it's a different permutation. So you get generally a larger number than you're looking at combinations. The combinations ABC, BCA, CBA are not counted as three separate arrangements. It's the same combination. You still got ABC, the same three letters are in ABC, BCA and CBA. So let's see how this works. So for example, if I ask you how many different groups of three can be selected from seven people? Let's call the people A, B, C, D, E, F, G, they're seven people. And now once you select B, D and E, the fact that they can be arranged six different ways, B, D, E, E, D, B, E, D, it doesn't matter. It's all irrelevant. It's the same three. So obviously you can get a smaller number. So that's the difference between a permutation and a combination. Note you have both keys. You can do an NPR or NCR on your calculator. This is the formula for combination. N, C, not P, now it's a C. NCR is N factorial over R factorial times N minus R factorial. So it's the same as the permutation formula except now you're dividing, you're shrinking it, in fact, by dividing it by R factorial. So that's why we see that NCR is NPR over R factorial. Anyway, you don't have to worry about all this. You have the NCR key on your calculator to solve any combination problem. Make sure you have a calculator that has that key. Okay, you shouldn't even buy a calculator that doesn't have NPR and NCR on it. They're very cheap now. So for example, how many different groups of three can be selected from seven people? Sampling in general is a combination problem. So if you want to get groups of three from seven, again, you don't care how they're ordered. Once you get the three, that's it. Okay, so seven, combination three, which is seven factorial divided by three factorial times four factorial, and you put this into your calculator, you should get 35. How many different hands can one draw from a deck of 52 cards in a game of seven-card rummy? Again, you don't care about how it's ordered. You just want to see how many different decks from a deck of 52, how many hands of seven can you get? Okay, that's 52. That's N, combination seven. That's like your slots. 52, combination seven. That's 52 factorial over seven factorial times 45 factorial. If you do it in your calculator, you'll find it's 133,784,560 different hands you can get in seven-card rummy. Let's try the next example. How many samples of size six can be drawn from a population of size N equals 50? Well, this is simply 50, combination six, 50 factorial over six factorial times 44 factorial. Using your calculator, you'll get the answer 15,890,700. And that's, it's very simple. Once you learn how to use your calculator, you have no problem. The biggest problem you'll have is deciding is it a permutation or a combination. And that's easy to figure out. Do we care about the arrangement or not? If you don't care about arrangement and once you have ABC, it's the same as BCAC, then you're basically looking at a combination. Now we're ready to learn about the binomial distribution. The binomial distribution is used when the sampling process works as follows. There are only two outcomes. There's two possible outcomes. These two outcomes have to be mutually exclusive. We're going to call these outcomes success and failure, even though you might not consider a defective product to success. It's just a terminology to use. Okay, so here are some examples where you just got two outcomes. Heads, tails. If you flip a coin, the only two things are going to happen. A head or a tail. Or you pass a course or fail a course. If you take a course, pass, fail. You're getting a P or an F. Or, as I mentioned before, defective, not defective. Dead or alive. Hit or miss. So when you have two outcomes only and they're independent events, which means, and you'll see more clearly in the third condition, the probability of success or failure is constant from trial to trial. For example, the probability of getting a head on a coin toss is the same on every toss of the coin. Even if you've got, let's say, four heads in a row already. You've got head, head, head, head. Guess what the probability of a head is on the fifth toss? It's still 50%. Even if you've got ten heads in a row. Head, head, head, head, head. Imagine having a ten in a row and most of us will say, well, now they'll probably change. No, it's a fair coin. Even on the 11th toss, guess what? The probability is still 50%. And again, you'll remember that there are two outcomes, because the word buy means two. Right? So when you see binomial distribution, you know it's got to be two outcomes. The formula for the binomial distribution. This is what you need to know. Obviously, you need to know n, p, and x. Okay, p is the probability of success. Again, success doesn't have to be a good thing. It's just an arbitrary term. Once you know p, since there are only two outcomes, you know what 1 minus p is. Okay? So I tell you it's a 5% chance of a defective product. That means 95% chance it won't be defective. So once you know p, you know 1 minus p. x is the number of successes out of n. Well, if you have x successes, n minus x will be the number of failures, because it must add up to n. And here is the formula called the binomial distribution. The probability of x successes is n combination x, p to the x, 1 minus p to the n minus x. And a quick check when you do this and you write it out, make sure that pn1 minus p add up to 1 and make sure x and n minus x add up to n. If you do that check, you won't make any mistakes. Well, there you see the formula again for the binomial. The probability of x successes, n combination x, p to the x, 1 minus p to the n minus x. We can figure this out mathematically. The mean or the expected value of binomial distribution, mu is just np. The variance turns out to be n times p times 1 minus p. So just keep that in mind. You'll see common sense will tell you the mean is np. Here is another problem involving coin tossing. Coin tossing of the classic binomial. Two outcomes, head to tail. The probability never changes. It's always half, 50%. Okay, if you toss a coin 12 times, what's the probability you'll get six heads? Okay. Now, but those of you who know a little bit of math know that the expected value is supposed to get six heads on average. If you keep doing it over and over again, you will average out to six out of 12 tosses. How do you know that? np. Mu is np. So 12 times p over half, you should get six heads. That's the most likely outcome. But let's see what the probability turns out to be. Many people think it's 50%. It's not. The highest that probability, six heads, but it's not 50%. The probability of getting six heads in 12 tosses will not be 50%. And let's prove it. 12 combinations, six. And there you see that in the parentheses 0.5 and 0.5. That's the probability of the head and probability of the tail, obviously. Or you want to call it success and failure. And notice the exponents are six and six, because you want six heads, which means you automatically have six tails. It works out to 0.2256. And by the way, with 100 tosses, we know mathematically, mu equals np, 100 times a half. So you're supposed to get 50 heads. That's the most likely outcome. But the probability of getting 50 heads in 100 tosses works out to only 0.0796. Again, just check the formula. You'll see it's a low probability, 0.0796. It's the most likely thing that's going to happen. But it actually happens. You toss a coin 100 times. Sometimes you'll get 49 heads. Occasionally you'll get 50. Sometimes you'll get 51. It'll average out to 50 heads. That's what mu is, like a long-term average. Expected value, we talked about that. Okay, one more problem. Suppose you know that 60% of the students at CUNY are female. CUNY is the city university of New York. If you're not from Brooklyn or Manhattan or Queens. So what is the probability that in a randomly selected group of 25 students, there'll be exactly 15 females? Now notice, by the way, if you want to get mu, which you expect to see, it takes mu equals np, or 25 times 0.60. That's the most likely thing you should be. Most likely outcome. But let's use the binomial. So x is 15 out of n25. And you see the two probabilities, 0.60, that's the probability of female. And we're assuming there are only two categories. Again, you know things have changed. And it's not just two categories. Well, let's pretend there's two categories, female and male. So we have 0.60 and 0.40. And then we have 1 out of 15 females. So 0.60 to the 15th power. 0.40 to the 10th power. And again, the 25th combination 15 is obvious. And when you solve that, you'll see the probability is 0.1612. Here's another example. Suppose the probability of passing the organic chemistry course at your college is 40%. Which is, of course, 0.40. What is the likelihood in the class of 45 students taking the organic chemistry course? That 22 will pass. Now remember, you only need n, p and x. Well, n is 45. We're asking about 22 out of 45. So x is 22. And the p, let's say 40%, that's 0.40. So it's 45 combination 22 times 0.40 to the 22 power times 0.60 to the 23. As a check, look at the two probabilities. 0.40 and 0.60, it adds up to 1. Okay, that's logical. Let's look at the two exponents. 22 passed. That's 45, that means 23 failed. So we have 22 plus 23 is 45. It has to add up to n. So that's logical. That's where you check your work. So the answer is going to be 0.0572. Let's look at another problem. A machine produces parts that are very difficult to make. Three-dimensional printers are now being used to make kidneys. That's difficult. It turns out 1 out of 20 is defective. That's your p right there, 1 out of 20. And you have to throw those parts out. So I ask you, what is the probability you buy a sample of 10 parts or a batch of 10 parts? You got 10 parts. What is the likelihood it'll have zero defectives? Okay. This is a standard binomial. When you see two outcomes and they're independent. So we know p. p is 0.05. Okay. We know n. I said that we have a batch or a sample of 10 parts. And we want to know what x equals 0. Okay. So there it is. 10 combination 0. n combination x. 0.05 is the probability of a defective. That's 1 out of 20 is 0.05. You want zero defectives, that's 0. And 0.95 to the 10. And as again as a check, look at the two probabilities of the parentheses. 0.05 and 0.95, they add up to 1. So you make a mistake there. And zero defectives, 10 non-defectives, 0 and the 10 as the exponents add up to n, which is 10. So your logic is good. Now look into your calculator and you've got this. You could actually do it if you have a scientific calculator straight across. First to the n, c, r thing. In this case you don't have to do it because 10 combination 0 is 1. You can do it in your head. And anything to the 0 power at the point of 5 is 1. So you don't even have to go crazy with that. That's 1 and 1. All you got to do is 0.95 to the 10th power. That's all you got to do for this kind of problem. And your answer is 0.5987. All right. Here's the problem. It works a little bit differently. We're still using the binomial, but we have to use it in a little bit of a different manner than before. Suppose we have a smartphone that's produced with eight critical components, and each one of those eight parts has a 1% chance of being defective. It sounds pretty good, but we'd still like to know what's the probability that a randomly selected smartphone will not work properly? Okay. If any one of those eight parts is defective, it won't work properly. But think about it. If two of those parts are defective, it won't work properly. If three, if four, if five, and certainly if all eight parts are defective, it won't work properly. So this is a little bit more of a complicated problem where you can get the probability for each of those situations, the probability that x is equal to 1, is equal to 2, is equal to 3. And then you add them all up because those are mutually exclusive. And the sum total of all of those probabilities is the answer to the question, what's the probability that a randomly selected smartphone will not work properly? We're going to show how that works and then hopefully figure out a hack to do it a little bit differently and a little bit easier. Let's take a look at the work here, what we have to do to solve this problem. The probability that the smartphone will not work properly is the probability that there's one defective, as you can see, 0.07457 plus the probability of having two defectives, 0.00264 plus the probability of three defectives, 0.0005 plus the probability of four defectives and this number is so, so small that it's in effect zero. And the same thing holds for the probability of five defectives, six defectives, seven defectives, and eight defectives. When you add up all of those binomial probabilities, you have 0.07726. So the answer to the question, what's the probability that the smartphone will not work properly? It's 7.73%. 7.73% of the phones coming off the assembly process will not work properly because of defects in these eight components, possible defects, probable defects. Now take a look at something else. The next item here, what is the probability that the phone will work perfectly? Well, that's easy. We don't have to get a million probabilities and add them up. The probability that the phone will work perfectly is the probability of zero defects, which we haven't done yet. It's not one of the probabilities on the right side of the screen. The probability of zero defects applying the binomial formula is eight combination zero, which is one. P to the zero, which is also one. And then the only thing you actually have to compute, 0.99 raised to the power of eight, which is equal to 0.92274. Well, look at that. That makes my job a lot easier. Instead of getting all of those binomial terms and adding them up and getting the sum of all the binomial probabilities of the various ways that we could get a defect, we could just get the probability that there is no defect. The phone works perfectly. And that's not what we want, of course. But if we take one minus that, one minus 0.92274, that's everything else. That's the probability that it will not work perfectly. And it turns out one minus 0.92274 is indeed 0.07726. So this is a kind of a problem where you are asked for a probability you know the binomial distribution is involved, but you have to figure out what you want to compute to make life easier for yourself. And then work with that in order to get the answer to the problem. We'll see another example of this coming up. Let's look at a problem. Let's pretend an air conditioner made by a certain company is made of 20 distinct parts. And let's assume each part independently has a 0.004 probability of being defective. That's another way of saying four chances and a thousand of being defective. And you're going to assemble this 20 different parts and each part has a 0.004 probability of being defective. What is the probability that a randomly selected air conditioner will not work perfectly? What does not working perfectly mean? That's the trick to this question. Not working perfectly means, well, one defective part, it doesn't work well. How about if it has two? It also doesn't work well. Three? It also doesn't work well. How about if all 20 don't work? You're going to have a very bad air conditioner. All 20 parts are not working. So now we know P equals 0.004 and is 20. And I ask you what is the probability that it won't work well? So you're really looking at that it has anywhere from 1 to 20 defective parts. And I'm going to show you a trick how to solve this problem. Well, the best way to solve this problem is not to solve it for not working. Because what does not working mean? It could have one defective, it could have two, it could have three, it could have four, it could have five, and it certainly won't work well if all 20 parts are defective. Let's try to use a different approach. Let's first solve for the problem of what is the probability that it works perfectly and what does working perfectly mean if something consists of 20 parts? It means you have 20 parts, all 20 are good and zero defectives. So that would be the solution for a perfect air conditioner. 20 parts, zero defectives. So that's 20 combination zero, 0.004 to the zero power, that's the defective side, zero defectives. And 0.996, that's the probability each part works perfectly to the 20 power because you want all 20 parts to work perfectly. That works out to, remember the 20 combination zero is just one. 0.004 to the zero is one. All you got to do is 0.996 to the 20 power, you get 0.923 and that answers the question of the air conditioner working perfectly. All 20 parts are good, no defectives. Now you want to know what that wasn't the question. The question is that it doesn't work well. What does not working well mean? At least one defective. Two certainly not going to work well. So you just take one minus the 0.923 and that's 0.077 and that answers the question that the air conditioner does not work well. In other words, there's a 7.7% chance that a randomly selected air conditioner made by the company will not work perfectly. Now how do you improve quality? That's the reason we're doing these problems to let you think logically. Of course you can try to improve the defect rate and change it and work hard on that. But what many companies have discovered reduced the number of parts. Today you can make a computer out of like 15 parts. The fewer parts you have, the less likely something will not work well. So now you have a key idea regarding quality control. Try not to make things with fewer parts and of course you try to reduce the defect rate for each of those parts and then you'll have a better product. Once you have studied the material, find as many problems as you can. You'll find them in all different areas of the website and you'll find them in all different kinds of books and we even have it in the boot camp. Do lots and lots of problems. Do your homework problems and anything else you can lay your hands on. It will become second nature to you.