1 00:00:00,499 --> 00:00:02,830 The following content is provided under a Creative 2 00:00:02,830 --> 00:00:04,340 Commons license. 3 00:00:04,340 --> 00:00:06,680 Your support will help MIT OpenCourseWare 4 00:00:06,680 --> 00:00:11,050 continue to offer high quality educational resources for free. 5 00:00:11,050 --> 00:00:13,660 To make a donation, or view additional materials 6 00:00:13,660 --> 00:00:17,556 from hundreds of MIT courses, visit MIT OpenCourseWare 7 00:00:17,556 --> 00:00:18,181 at ocw.mit.edu. 8 00:00:24,160 --> 00:00:26,400 PROFESSOR: So far in our discussion of probability, 9 00:00:26,400 --> 00:00:29,210 we've focused our attention on the probability 10 00:00:29,210 --> 00:00:33,220 that some kind of event occurs-- the probability you 11 00:00:33,220 --> 00:00:36,600 win the Monty Hall game, the probability that you get 12 00:00:36,600 --> 00:00:40,870 a heads when you flip a coin, the probability we all 13 00:00:40,870 --> 00:00:44,570 have different birthdays in the room-- that kind of thing. 14 00:00:44,570 --> 00:00:47,760 In each case, the event happens or it doesn't. 15 00:00:47,760 --> 00:00:50,630 It's a zero-one kind of thing. 16 00:00:50,630 --> 00:00:52,710 For the rest of the course, we're 17 00:00:52,710 --> 00:00:56,460 going to start talking about more complicated situations. 18 00:00:56,460 --> 00:00:58,840 Instead of talking about zero-one events, 19 00:00:58,840 --> 00:01:00,890 like winning or losing, we're going 20 00:01:00,890 --> 00:01:04,610 to start talking about how much you win. 21 00:01:04,610 --> 00:01:06,926 Instead of talking about whether or not 22 00:01:06,926 --> 00:01:08,970 you get a heads in a coin flip, we're 23 00:01:08,970 --> 00:01:10,930 going to talk about flipping lots of coins 24 00:01:10,930 --> 00:01:16,080 and asking how many heads did you get? 25 00:01:16,080 --> 00:01:21,420 Now, this involves the notion of a random variable 26 00:01:21,420 --> 00:01:24,990 to count how much or how many in a random situation. 27 00:01:24,990 --> 00:01:27,250 And actually, the name is sort of weird. 28 00:01:27,250 --> 00:01:29,650 It's not a variable at all. 29 00:01:29,650 --> 00:01:33,080 In fact, a random variable is a function from the sample 30 00:01:33,080 --> 00:01:34,190 space to the real numbers. 31 00:01:45,390 --> 00:01:56,220 See random variable R is a function R from the sample 32 00:01:56,220 --> 00:02:00,512 space to the reals. 33 00:02:00,512 --> 00:02:02,470 So this is the random variable, and we'll often 34 00:02:02,470 --> 00:02:05,040 denote that by rv. 35 00:02:05,040 --> 00:02:07,980 This is the sample space of all possible outcomes. 36 00:02:11,190 --> 00:02:12,460 And this is just the reals. 37 00:02:17,460 --> 00:02:19,600 All right, so in other words, a random variable 38 00:02:19,600 --> 00:02:22,150 is just a way of assigning a real number 39 00:02:22,150 --> 00:02:25,440 to each possible outcome. 40 00:02:25,440 --> 00:02:28,085 For example, say that we toss three coins. 41 00:02:36,560 --> 00:02:45,080 We could let R equal the number of heads among the three coins. 42 00:02:45,080 --> 00:02:47,040 And R is thus a random variable. 43 00:02:47,040 --> 00:02:51,920 For example, for the outcome where the first coin is heads, 44 00:02:51,920 --> 00:02:54,050 the second is tails, and the third is heads, 45 00:02:54,050 --> 00:02:57,610 R would be the real number 2, indicating I 46 00:02:57,610 --> 00:02:59,310 got two heads in that outcome. 47 00:03:02,160 --> 00:03:07,300 We could also define another value called M, which we'll say 48 00:03:07,300 --> 00:03:16,680 is 1 if all three coins match, if they're all the same, 49 00:03:16,680 --> 00:03:19,987 and 0 otherwise, if they're not all the same. 50 00:03:23,400 --> 00:03:32,780 For example, M on the outcome heads, heads, tails is 0. 51 00:03:32,780 --> 00:03:36,190 M on the outcome tails, tails, tails 52 00:03:36,190 --> 00:03:38,120 would be 1, because they all are the same. 53 00:03:40,930 --> 00:03:42,120 Is M a random variable? 54 00:03:45,480 --> 00:03:49,370 Yeah, it assigns a value, a real number, to every outcome. 55 00:03:49,370 --> 00:03:52,110 And that value is either 0 or 1, depending 56 00:03:52,110 --> 00:03:53,980 on if all the coins match. 57 00:03:53,980 --> 00:03:56,870 In fact, it's a very special kind of random variable 58 00:03:56,870 --> 00:03:59,520 that's called an indicator random variable, also 59 00:03:59,520 --> 00:04:03,820 known as Bernoulli or characteristic random variable, 60 00:04:03,820 --> 00:04:05,270 because it's zero-one. 61 00:04:08,860 --> 00:04:21,209 An indicator also known as a Bernoulli 62 00:04:21,209 --> 00:04:35,890 or characteristic random variable, 63 00:04:35,890 --> 00:04:44,130 is a random variable whose range or possible values 64 00:04:44,130 --> 00:04:47,910 is just 0 and 1. 65 00:04:47,910 --> 00:04:50,030 So it's a random variable where the real numbers 66 00:04:50,030 --> 00:04:53,140 are 0, 1 that you assign to every sample point. 67 00:04:53,140 --> 00:04:56,920 And it's called a characteristic or indicator random variable 68 00:04:56,920 --> 00:05:00,660 because it indicates which sample points have 69 00:05:00,660 --> 00:05:02,430 a certain property. 70 00:05:02,430 --> 00:05:05,480 In this case, all the coins were the same. 71 00:05:05,480 --> 00:05:07,310 Or it indicates that a sample point 72 00:05:07,310 --> 00:05:09,110 has a certain characteristic, which 73 00:05:09,110 --> 00:05:11,742 is why it's called a characteristic random variable. 74 00:05:11,742 --> 00:05:13,200 And we're going to be talking a lot 75 00:05:13,200 --> 00:05:14,800 about these kinds of random variables 76 00:05:14,800 --> 00:05:17,760 over the next couple of weeks. 77 00:05:17,760 --> 00:05:21,440 Now, in general, a random variable is equivalent to, 78 00:05:21,440 --> 00:05:26,470 or it can define a partition on the sample space. 79 00:05:26,470 --> 00:05:29,710 For an indicator random variable, 80 00:05:29,710 --> 00:05:33,220 it defines a partition with two blocks. 81 00:05:33,220 --> 00:05:38,470 For example, say we look at the sample space with three coin 82 00:05:38,470 --> 00:05:41,080 tosses there. 83 00:05:41,080 --> 00:05:42,180 There's eight outcomes. 84 00:05:42,180 --> 00:05:50,400 There's heads, heads, heads; heads, tails, heads; 85 00:05:50,400 --> 00:05:55,556 heads, heads, tails; tail, heads, heads; 86 00:05:55,556 --> 00:05:56,835 and the reverse of those. 87 00:06:04,470 --> 00:06:07,180 This is the sample space when I toss three coins. 88 00:06:07,180 --> 00:06:09,940 There's eight possible outcomes. 89 00:06:09,940 --> 00:06:12,845 The random variable M defines this partition. 90 00:06:15,700 --> 00:06:20,790 Up top, you have M equals 1, and down below you have M equals 0. 91 00:06:20,790 --> 00:06:23,450 Because these are the outcomes where all the coins match. 92 00:06:23,450 --> 00:06:24,700 These are the ones that don't. 93 00:06:27,820 --> 00:06:30,775 The random variable R defines a different partition. 94 00:06:33,740 --> 00:06:38,320 In that case, the partition has four blocks. 95 00:06:38,320 --> 00:06:44,860 Here is R equals 0, no heads. 96 00:06:44,860 --> 00:06:48,660 This is R equals 1, to one head. 97 00:06:48,660 --> 00:06:51,340 R equals 2, and R equals 3. 98 00:06:54,460 --> 00:06:58,750 So a random variable just sort of organizes your sample space, 99 00:06:58,750 --> 00:07:01,450 partitions it into blocks, defined 100 00:07:01,450 --> 00:07:03,560 by all the elements in the block, 101 00:07:03,560 --> 00:07:05,976 the outcomes in the block have the same value 102 00:07:05,976 --> 00:07:06,975 for the random variable. 103 00:07:09,500 --> 00:07:14,000 And, in fact, every block is really an event. 104 00:07:14,000 --> 00:07:17,040 In particular, we can say that, if you 105 00:07:17,040 --> 00:07:21,530 look at the outcomes for which the random variable 106 00:07:21,530 --> 00:07:24,830 on that outcome equals some value x, 107 00:07:24,830 --> 00:07:32,160 this is simply the event that R equals x. 108 00:07:32,160 --> 00:07:34,900 The random variable is x. 109 00:07:34,900 --> 00:07:37,490 And, of course, an event is just a subset of the sample space. 110 00:07:37,490 --> 00:07:40,345 It's a collection of outcomes that define the event. 111 00:07:42,890 --> 00:07:45,870 And since we know we could talk about probabilities of events, 112 00:07:45,870 --> 00:07:47,900 we can now say things like this. 113 00:07:47,900 --> 00:07:52,610 We can say the probability that a random variable equals 114 00:07:52,610 --> 00:07:57,950 x is simply the probability of that event happening, which 115 00:07:57,950 --> 00:08:03,890 is the sum over all outcomes for which the random variable 116 00:08:03,890 --> 00:08:08,850 equals x for that outcome, summing its probability. 117 00:08:08,850 --> 00:08:12,060 So the probability that the random variable equals a value 118 00:08:12,060 --> 00:08:14,500 is the sum of the probabilities of the sample points 119 00:08:14,500 --> 00:08:17,500 for which R has that value. 120 00:08:17,500 --> 00:08:19,250 All right, this is all really basic stuff, 121 00:08:19,250 --> 00:08:23,200 but important to get down. 122 00:08:23,200 --> 00:08:26,960 So, for example, what's the probability 123 00:08:26,960 --> 00:08:31,372 that R equals 2 in our case with the three coins? 124 00:08:31,372 --> 00:08:35,090 You flip three coins-- let's say the coins are fair and mutually 125 00:08:35,090 --> 00:08:35,860 independent. 126 00:08:35,860 --> 00:08:38,720 We probably need to know that. 127 00:08:38,720 --> 00:08:41,675 What is the probability R equals 2? 128 00:08:41,675 --> 00:08:42,950 AUDIENCE: 3/8? 129 00:08:42,950 --> 00:08:47,780 PROFESSOR: 3/8, because you've got three outcomes, each 130 00:08:47,780 --> 00:08:50,050 with a probability 1/8. 131 00:08:50,050 --> 00:08:52,590 All right, so by this definition, that 132 00:08:52,590 --> 00:08:56,640 would be the same as the probability of heads, heads, 133 00:08:56,640 --> 00:09:01,240 tails; heads, tails, heads; tails, heads, 134 00:09:01,240 --> 00:09:03,160 heads; that's 3/8. 135 00:09:06,760 --> 00:09:10,660 What's the probability that M equals 1? 136 00:09:16,928 --> 00:09:19,300 What's the probability that M equals 1? 137 00:09:19,300 --> 00:09:23,050 M is 1 if all the coins match. 138 00:09:23,050 --> 00:09:27,360 1/4 because you've got two cases there-- heads, heads, 139 00:09:27,360 --> 00:09:31,720 heads-- whoops-- or tails, tails, 140 00:09:31,720 --> 00:09:36,982 tails; and that's 2/8, or 1/4. 141 00:09:36,982 --> 00:09:39,840 Now we can also talk about the probability 142 00:09:39,840 --> 00:09:43,930 that a random variable is in some range. 143 00:09:43,930 --> 00:09:47,180 For example, I could ask, what's the probability 144 00:09:47,180 --> 00:09:49,925 that R is at least 2? 145 00:09:52,525 --> 00:09:58,340 All right, that would mean the sum i equals 2 to infinity, 146 00:09:58,340 --> 00:10:02,230 the probability R equals i. 147 00:10:02,230 --> 00:10:03,035 And what is that? 148 00:10:05,930 --> 00:10:07,150 What's the probability? 149 00:10:07,150 --> 00:10:09,740 R is at least 2. 150 00:10:09,740 --> 00:10:10,480 1/2. 151 00:10:10,480 --> 00:10:12,469 It's the probability that R equals 2, 152 00:10:12,469 --> 00:10:14,010 plus the probability that R equals 3. 153 00:10:14,010 --> 00:10:16,840 There's four outcomes there, each with 1/8, so that's 1/2. 154 00:10:21,300 --> 00:10:24,030 And finally, we can talk about the probability 155 00:10:24,030 --> 00:10:28,770 that R is in some set of values. 156 00:10:28,770 --> 00:10:34,670 So we could say, for example, for any subset 157 00:10:34,670 --> 00:10:38,830 of the real numbers, we define the probability 158 00:10:38,830 --> 00:10:44,100 that R attains a value in that set is simply 159 00:10:44,100 --> 00:10:50,660 the sum over all possible values in the set, 160 00:10:50,660 --> 00:10:52,570 that the probability R equals that value. 161 00:10:55,570 --> 00:11:00,170 So we could ask, what's the probability that, say, we 162 00:11:00,170 --> 00:11:04,950 take A being the set 1, 3. 163 00:11:04,950 --> 00:11:08,120 I could ask for the probability R 164 00:11:08,120 --> 00:11:13,380 is A when it's 1, 3, which is the same as the probability 165 00:11:13,380 --> 00:11:15,220 R is odd. 166 00:11:15,220 --> 00:11:18,210 Because Our could only be 0, 1, 2, or 3. 167 00:11:18,210 --> 00:11:24,494 What's the probability R is odd in this example? 168 00:11:24,494 --> 00:11:26,410 Flip three coins, we're asking the probability 169 00:11:26,410 --> 00:11:31,240 you get an odd number of heads-- one or three heads. 170 00:11:31,240 --> 00:11:32,650 1/2. 171 00:11:32,650 --> 00:11:40,057 Again, you've got four sample points-- here and there. 172 00:11:40,057 --> 00:11:40,640 So that's 1/2. 173 00:11:44,820 --> 00:11:48,125 All right, any questions about the definition? 174 00:11:51,210 --> 00:11:54,130 All right, now, we're only going to worry about the case 175 00:11:54,130 --> 00:11:58,100 when random variables are discrete. 176 00:11:58,100 --> 00:12:02,940 Namely, there's a finite number of values. 177 00:12:02,940 --> 00:12:05,190 If you have continuous random variables, which they'll 178 00:12:05,190 --> 00:12:06,550 deal with in other courses, instead 179 00:12:06,550 --> 00:12:08,010 of doing sums and stuff like that, 180 00:12:08,010 --> 00:12:09,260 you're working with integrals. 181 00:12:09,260 --> 00:12:12,840 But for this course, it's going to be all countable sets, 182 00:12:12,840 --> 00:12:16,770 and usually often finite sets. 183 00:12:16,770 --> 00:12:21,300 Now, conditional probability carries over very nicely 184 00:12:21,300 --> 00:12:22,690 to random variables as well. 185 00:12:22,690 --> 00:12:27,160 For example, we could write down the probability 186 00:12:27,160 --> 00:12:33,974 that R equals 2 given that M equals 1, where R and M are 187 00:12:33,974 --> 00:12:36,140 the same random variables we've been looking at when 188 00:12:36,140 --> 00:12:38,340 you flip the three coins. 189 00:12:38,340 --> 00:12:40,830 What is that probability? 190 00:12:40,830 --> 00:12:43,960 0, the probability of getting exactly two heads when they're 191 00:12:43,960 --> 00:12:46,210 all the same, can't happen. 192 00:12:46,210 --> 00:12:46,990 It's 0. 193 00:12:46,990 --> 00:12:50,590 You can either have three heads or no heads. 194 00:12:50,590 --> 00:12:51,380 So that's 0. 195 00:12:54,920 --> 00:12:57,852 The notion of independence also carries over 196 00:12:57,852 --> 00:12:59,310 to random variables, but you've got 197 00:12:59,310 --> 00:13:00,530 to be a little careful here. 198 00:13:06,670 --> 00:13:12,870 Two random variables, R1 and R2, are 199 00:13:12,870 --> 00:13:26,070 said to be independent if-- and this is a little complicated-- 200 00:13:26,070 --> 00:13:31,392 for all possible values, x1 and x2 201 00:13:31,392 --> 00:13:40,290 in the real numbers, the probability that R1 is x1, 202 00:13:40,290 --> 00:13:46,580 given that R2 is x2, is the same as the probability of R1 203 00:13:46,580 --> 00:13:48,910 equals x1 not knowing anything about R2. 204 00:13:54,060 --> 00:13:57,610 Or there's a special case when this can't happen. 205 00:13:57,610 --> 00:14:02,190 Namely, the probability that R2 equals x2 is 0. 206 00:14:05,020 --> 00:14:08,830 So, for two random variables to be independent, 207 00:14:08,830 --> 00:14:12,720 it needs to be the case that, no matter what happens out here 208 00:14:12,720 --> 00:14:15,910 with R2, and whatever you know about it, 209 00:14:15,910 --> 00:14:19,740 it can't influence the probability for R1 210 00:14:19,740 --> 00:14:22,030 to equal anything. 211 00:14:22,030 --> 00:14:27,790 So no value of R2 influences any value of R1. 212 00:14:27,790 --> 00:14:31,180 So it's the strongest possible thing with independence 213 00:14:31,180 --> 00:14:33,946 for it to apply to random variables. 214 00:14:33,946 --> 00:14:36,570 And there's an equivalent definition, 215 00:14:36,570 --> 00:14:39,260 and we're going to use these interchangeably, just as there 216 00:14:39,260 --> 00:14:43,010 were two definitions for independence of events, 217 00:14:43,010 --> 00:14:45,840 there's the product for them. 218 00:14:45,840 --> 00:14:48,890 So the equivalent definitions says 219 00:14:48,890 --> 00:14:55,500 for all x1 and x2 in the real numbers, the probability 220 00:14:55,500 --> 00:15:02,550 that R1 equals x1 and R2 equals x2 is simply 221 00:15:02,550 --> 00:15:05,680 the product of those probabilities. 222 00:15:05,680 --> 00:15:12,410 Probability R1 equals x1 times the probability R2 equals x2. 223 00:15:15,029 --> 00:15:16,820 And you don't have to worry about that case 224 00:15:16,820 --> 00:15:19,980 where R2 being x2 is 0. 225 00:15:19,980 --> 00:15:24,490 So we can use both of those as definitions of independence 226 00:15:24,490 --> 00:15:27,550 of random variables. 227 00:15:27,550 --> 00:15:29,430 All right, so let's see an example. 228 00:15:29,430 --> 00:15:33,500 We've got R and M. We've talked about two random variables. 229 00:15:33,500 --> 00:15:36,320 Are they independent random variables? 230 00:15:40,610 --> 00:15:42,790 M is the indicated random variable 231 00:15:42,790 --> 00:15:44,630 for all the coins matching. 232 00:15:44,630 --> 00:15:47,180 R is the random variable that tells us how many heads 233 00:15:47,180 --> 00:15:49,210 there were in three coins. 234 00:15:49,210 --> 00:15:50,790 Are they independent? 235 00:15:50,790 --> 00:15:51,510 AUDIENCE: No. 236 00:15:51,510 --> 00:15:54,024 PROFESSOR: No, why not? 237 00:15:54,024 --> 00:15:57,293 AUDIENCE: Because information with what one is narrows down 238 00:15:57,293 --> 00:15:57,934 [INAUDIBLE]. 239 00:15:57,934 --> 00:15:59,100 PROFESSOR: Yes, that's true. 240 00:15:59,100 --> 00:16:01,560 Information about what one value is 241 00:16:01,560 --> 00:16:04,210 influences the probability that the other guy 242 00:16:04,210 --> 00:16:05,240 has a certain value. 243 00:16:05,240 --> 00:16:09,030 In particular, we can find a case of x1 and x2 244 00:16:09,030 --> 00:16:11,020 where this fails. 245 00:16:11,020 --> 00:16:12,910 One case would be the probability 246 00:16:12,910 --> 00:16:21,036 of what we've already done, that R equals 2 and M equals 1. 247 00:16:21,036 --> 00:16:23,930 What was this probability? 248 00:16:23,930 --> 00:16:24,650 0. 249 00:16:24,650 --> 00:16:26,780 If everything matches, you can't have two heads. 250 00:16:26,780 --> 00:16:28,110 That's 0. 251 00:16:28,110 --> 00:16:31,220 That does not equal the probability 252 00:16:31,220 --> 00:16:36,580 of two heads times the probability they all match. 253 00:16:36,580 --> 00:16:40,550 Because this probability, two heads is 3/8, 254 00:16:40,550 --> 00:16:43,045 probability they all match is 1/4. 255 00:16:43,045 --> 00:16:47,510 And 3/8 times a 1/4 is not 0. 256 00:16:47,510 --> 00:16:49,730 So R and M are not independent. 257 00:16:57,470 --> 00:17:00,560 OK, now in general to show two random variables 258 00:17:00,560 --> 00:17:03,070 are not independent, all you gotta 259 00:17:03,070 --> 00:17:08,180 do is find one pair of [? out ?] values for which there's 260 00:17:08,180 --> 00:17:09,700 dependence. 261 00:17:09,700 --> 00:17:12,060 To show their independent, you've 262 00:17:12,060 --> 00:17:15,390 got to deal with all possible pairs of values. 263 00:17:15,390 --> 00:17:17,480 So it's harder show independence in general. 264 00:17:20,720 --> 00:17:24,588 All right, let's do another example, 265 00:17:24,588 --> 00:17:26,569 get a little practice with this. 266 00:17:38,180 --> 00:17:51,730 Say we have two fair independent six-sided die, normal dice. 267 00:17:51,730 --> 00:17:54,590 And the outcome of the first one is D1, 268 00:17:54,590 --> 00:17:58,710 and the outcome of the second roll is D2. 269 00:17:58,710 --> 00:18:04,170 And by independent, I mean here that knowing any information 270 00:18:04,170 --> 00:18:06,040 about what the second die is does not 271 00:18:06,040 --> 00:18:09,020 give you any change in your probability 272 00:18:09,020 --> 00:18:12,690 that the first die has any value. 273 00:18:12,690 --> 00:18:15,500 And now we define another value, S, 274 00:18:15,500 --> 00:18:19,825 to be D1 plus D2, the sum of the dice. 275 00:18:22,490 --> 00:18:23,930 Is S a random variable? 276 00:18:27,920 --> 00:18:32,190 Yeah, for any outcome-- an outcome being a pair of dice 277 00:18:32,190 --> 00:18:36,026 values-- it maps that outcome to a real number, 278 00:18:36,026 --> 00:18:41,700 a number between 2 and 12, OK? 279 00:18:41,700 --> 00:18:43,560 Let's do another one. 280 00:18:43,560 --> 00:18:53,870 Let's let T be 1 if S is 7, namely the sum of the dice 281 00:18:53,870 --> 00:18:55,200 is 7, and 0 otherwise. 282 00:18:59,860 --> 00:19:02,340 T is also a random variable. 283 00:19:02,340 --> 00:19:05,030 In fact, what kind is it? 284 00:19:05,030 --> 00:19:08,550 Yeah, indicator, characteristic, whatever. 285 00:19:08,550 --> 00:19:13,830 It's telling you if the sum of the dice is 7 or not. 286 00:19:13,830 --> 00:19:18,300 All right, now, there's four random variables here. 287 00:19:18,300 --> 00:19:21,440 Each die, which we already have told you, 288 00:19:21,440 --> 00:19:23,370 we're assuming are independent. 289 00:19:23,370 --> 00:19:26,830 The sum and the indicator if the sum is 7. 290 00:19:30,130 --> 00:19:34,990 All right, what about these two values? 291 00:19:34,990 --> 00:19:38,170 Are D1, the first die, and the sum independent? 292 00:19:41,603 --> 00:19:43,998 AUDIENCE: No? 293 00:19:43,998 --> 00:19:45,440 No? 294 00:19:45,440 --> 00:19:47,850 PROFESSOR: No, intuitively they're not. 295 00:19:47,850 --> 00:19:52,020 Because if I know something about the first die, 296 00:19:52,020 --> 00:19:55,710 I probably know something about the sum. 297 00:19:55,710 --> 00:19:59,110 Now to really nail that down, you've 298 00:19:59,110 --> 00:20:02,670 got to give me a value for this, which 299 00:20:02,670 --> 00:20:07,419 influences the probability that obtains some value, right? 300 00:20:07,419 --> 00:20:09,710 That's how you would convince me that, in fact, they're 301 00:20:09,710 --> 00:20:10,209 dependent. 302 00:20:13,600 --> 00:20:15,870 Can anybody give me a value for this 303 00:20:15,870 --> 00:20:18,770 that changes the probability this equals something? 304 00:20:23,320 --> 00:20:24,250 AUDIENCE: Guess? 305 00:20:24,250 --> 00:20:27,330 If it's like 1, then [INAUDIBLE] has to be 6. 306 00:20:27,330 --> 00:20:32,170 PROFESSOR: If this is 1, what value of this 307 00:20:32,170 --> 00:20:35,028 could be influenced? 308 00:20:35,028 --> 00:20:39,930 AUDIENCE: You know that in order for-- the only set of values 309 00:20:39,930 --> 00:20:44,348 S can take now, it can only be from 1 to-- from 2 to 7. 310 00:20:44,348 --> 00:20:45,306 PROFESSOR: From 2 to 7. 311 00:20:45,306 --> 00:20:49,230 In particular now, this can't be 12. 312 00:20:49,230 --> 00:20:51,570 So what I could do is say the probability that S 313 00:20:51,570 --> 00:20:58,780 equals 12 and the first die was 1, what's that probability? 314 00:20:58,780 --> 00:20:59,280 AUDIENCE: 0. 315 00:20:59,280 --> 00:21:01,300 PROFESSOR: 0. 316 00:21:01,300 --> 00:21:03,980 And that does not equal the probability 317 00:21:03,980 --> 00:21:08,380 S is 12 times the probability the first die was 1. 318 00:21:11,240 --> 00:21:13,690 Or we could plug it into the other definition. 319 00:21:13,690 --> 00:21:18,290 The probability that S equals 12 given the first die is 1 320 00:21:18,290 --> 00:21:21,440 is not equal to the probability S equals 12. 321 00:21:21,440 --> 00:21:24,510 And, in fact, probability the first die is 1 is not 0. 322 00:21:24,510 --> 00:21:26,750 So either definition, of course, works 323 00:21:26,750 --> 00:21:29,630 to show that they are dependent. 324 00:21:29,630 --> 00:21:31,350 So S and D1 are dependent. 325 00:21:35,800 --> 00:21:38,430 All you need is one possible pair 326 00:21:38,430 --> 00:21:40,360 of values to show dependence. 327 00:21:40,360 --> 00:21:41,660 That's usually easy to do. 328 00:21:46,350 --> 00:21:52,700 All right, what about D1, the first die, and T, 329 00:21:52,700 --> 00:21:55,695 the indicator for getting a 7? 330 00:21:59,150 --> 00:22:03,310 Are D1 and T independent random variables? 331 00:22:05,815 --> 00:22:08,860 All right, somebody's shaking their head no. 332 00:22:08,860 --> 00:22:12,430 They seem to be dependent because knowing the first die 333 00:22:12,430 --> 00:22:15,660 seems like it should tell you something about the probability 334 00:22:15,660 --> 00:22:19,930 of getting a 7 for the sum. 335 00:22:19,930 --> 00:22:22,140 That's a good first intuition. 336 00:22:22,140 --> 00:22:23,770 In fact, you always want to assume 337 00:22:23,770 --> 00:22:27,070 things are dependent unless you convince yourself otherwise. 338 00:22:27,070 --> 00:22:29,770 It's always a good rule. 339 00:22:29,770 --> 00:22:34,200 Now, in fact, in this case, it is independent. 340 00:22:34,200 --> 00:22:37,910 The probability of getting a 7 is not, it turns out, 341 00:22:37,910 --> 00:22:41,540 influenced by the first die. 342 00:22:41,540 --> 00:22:44,380 Anything else would be, but 7 is not. 343 00:22:44,380 --> 00:22:45,827 Let's see why that is. 344 00:22:45,827 --> 00:22:47,660 And to do that, we'd actually have to check, 345 00:22:47,660 --> 00:22:51,700 I think, 12 cases, all possible values for D1 and T, 346 00:22:51,700 --> 00:22:54,710 but you'll get the idea pretty quick. 347 00:22:54,710 --> 00:22:59,620 The probability that T equals 1, namely you got a 7, 348 00:22:59,620 --> 00:23:00,970 given that D1 equals 1. 349 00:23:00,970 --> 00:23:03,180 What's that? 350 00:23:03,180 --> 00:23:06,965 The probability of getting 7 for the sum given your first die 351 00:23:06,965 --> 00:23:08,760 is a 1, what's that probability? 352 00:23:08,760 --> 00:23:09,540 AUDIENCE: 1/6? 353 00:23:09,540 --> 00:23:13,730 PROFESSOR: 1/6, because the second one better be a 6. 354 00:23:13,730 --> 00:23:19,500 All right, and what's the probability T equals 1? 355 00:23:19,500 --> 00:23:21,425 What's the probability of rolling a 7? 356 00:23:24,810 --> 00:23:26,096 Yeah? 357 00:23:26,096 --> 00:23:27,240 AUDIENCE: 6/36. 358 00:23:27,240 --> 00:23:28,670 PROFESSOR: 6/36. 359 00:23:28,670 --> 00:23:30,160 There's six ways to do it. 360 00:23:30,160 --> 00:23:35,880 1 and 6, 2 and 5, 3 and 4, 4 and 3, 5 and 2, and 6 and 1, 361 00:23:35,880 --> 00:23:39,370 out of 36 possibilities equally likely. 362 00:23:39,370 --> 00:23:42,670 So that worked here. 363 00:23:42,670 --> 00:23:46,240 Now probability of getting a 7 given the second 364 00:23:46,240 --> 00:23:49,605 die-- sorry-- the first die is a 2. 365 00:23:49,605 --> 00:23:50,105 What's that? 366 00:23:53,740 --> 00:23:58,310 Probability of getting a 7 given that your first die is a 2. 367 00:23:58,310 --> 00:24:02,720 1/6, because you've got to have the second die be a 5, 368 00:24:02,720 --> 00:24:05,670 and that happens 1/6. 369 00:24:05,670 --> 00:24:08,740 And that equals the right thing. 370 00:24:08,740 --> 00:24:11,800 In fact, I can keep on going here. 371 00:24:11,800 --> 00:24:18,560 Probability T equals 1, given D1 is anything, 6. 372 00:24:18,560 --> 00:24:20,450 Well, for every value of D1, there's 373 00:24:20,450 --> 00:24:25,690 exactly one value of D2 that adds to a 7. 374 00:24:25,690 --> 00:24:31,060 So it's still 1/6, which is the probability of getting 375 00:24:31,060 --> 00:24:33,770 the 7 in the first place. 376 00:24:33,770 --> 00:24:38,700 Now we've also got to check the probability T equals 0, 377 00:24:38,700 --> 00:24:40,910 given all these cases for D1. 378 00:24:40,910 --> 00:24:43,340 D1 equals 1. 379 00:24:43,340 --> 00:24:43,850 What's this? 380 00:24:43,850 --> 00:24:46,970 The probability of not getting a 7 given the first die is a 1. 381 00:24:46,970 --> 00:24:49,875 What's that? 382 00:24:49,875 --> 00:24:50,780 AUDIENCE: 5/6. 383 00:24:50,780 --> 00:24:53,820 PROFESSOR: 5/6, it's the opposite of this case. 384 00:24:53,820 --> 00:24:54,460 They pair up. 385 00:24:54,460 --> 00:24:59,300 That's got to be 5/6, and that is, of course, 386 00:24:59,300 --> 00:25:02,960 the probability of T equals 0. 387 00:25:02,960 --> 00:25:07,810 And the same is true for all the other five cases. 388 00:25:07,810 --> 00:25:14,200 The probability T equals 0 given any value of D 389 00:25:14,200 --> 00:25:19,910 is 5/6, which equals, the probability T equals 0. 390 00:25:19,910 --> 00:25:22,860 So we check all possible values of T1 391 00:25:22,860 --> 00:25:25,710 and all possible ways of D1, and lo and behold, 392 00:25:25,710 --> 00:25:28,050 it works every time. 393 00:25:28,050 --> 00:25:29,840 So knowing the first die does not 394 00:25:29,840 --> 00:25:33,630 change the probability of getting a 7. 395 00:25:33,630 --> 00:25:35,595 Would it change the probability of getting a 6? 396 00:25:38,150 --> 00:25:41,040 Yeah, because if the first die were a 6, 397 00:25:41,040 --> 00:25:42,960 you know you're going to get more than a 6. 398 00:25:42,960 --> 00:25:46,000 So it just holds true because I picked 399 00:25:46,000 --> 00:25:49,220 it to be an indicator for 7. 400 00:25:49,220 --> 00:25:52,780 Any questions about that? 401 00:25:52,780 --> 00:25:56,900 So if you're ever asked to show things are independent, 402 00:25:56,900 --> 00:25:59,424 you've got to go through all the cases. 403 00:25:59,424 --> 00:26:01,090 If you're asked to show their dependent, 404 00:26:01,090 --> 00:26:06,830 just find one case that blows it up, and you're done. 405 00:26:06,830 --> 00:26:10,090 OK, you can also talk about independence 406 00:26:10,090 --> 00:26:12,466 for many random variables. 407 00:26:12,466 --> 00:26:14,340 And you have a notion of mutual independence. 408 00:26:26,900 --> 00:26:30,080 And this is a little hairy. 409 00:26:30,080 --> 00:26:32,090 It's a natural thing. 410 00:26:32,090 --> 00:26:54,400 R1, R2, up to Rn are mutually independent if for all 411 00:26:54,400 --> 00:27:00,430 the values of all the random variables, so x1, x2, xn. 412 00:27:03,941 --> 00:27:06,190 And we're going to give the product form, because it's 413 00:27:06,190 --> 00:27:08,650 the simpler way to do it here. 414 00:27:08,650 --> 00:27:19,170 The probability that R1 is x1, and R2 is x2, and Rn is xn 415 00:27:19,170 --> 00:27:21,450 equals the product of the individual probabilities. 416 00:27:30,880 --> 00:27:35,420 It's the natural generalization for two variables. 417 00:27:35,420 --> 00:27:37,950 And there's also the equivalent form 418 00:27:37,950 --> 00:27:40,665 in conditional probabilities, but that's a little harrier 419 00:27:40,665 --> 00:27:43,710 to write down, and we generally don't work with that. 420 00:27:49,880 --> 00:27:54,340 Any questions about mutual independence? 421 00:27:54,340 --> 00:27:55,227 Yeah. 422 00:27:55,227 --> 00:27:56,143 AUDIENCE: [INAUDIBLE]. 423 00:28:04,173 --> 00:28:05,664 PROFESSOR: So any subset what? 424 00:28:05,664 --> 00:28:06,580 AUDIENCE: [INAUDIBLE]. 425 00:28:09,860 --> 00:28:11,720 PROFESSOR: Yes, in the conditional form 426 00:28:11,720 --> 00:28:15,770 you check any subset, here you don't have 427 00:28:15,770 --> 00:28:16,940 to worry about the subsets. 428 00:28:16,940 --> 00:28:20,550 You take any possible value for all of them, 429 00:28:20,550 --> 00:28:24,290 so there's no subset notation in this version, 430 00:28:24,290 --> 00:28:25,706 so you can do without it. 431 00:28:25,706 --> 00:28:27,080 That would be equivalent, there's 432 00:28:27,080 --> 00:28:29,371 another form where you look at all the possible subsets 433 00:28:29,371 --> 00:28:31,030 as well, and conditioning on that. 434 00:28:31,030 --> 00:28:32,932 But this is good enough, and this is probably 435 00:28:32,932 --> 00:28:34,890 the simplest way to do the mutual independence, 436 00:28:34,890 --> 00:28:36,150 is like this. 437 00:28:36,150 --> 00:28:38,850 So every variable is included here. 438 00:28:38,850 --> 00:28:41,950 And that will imply the same thing for any subset. 439 00:28:41,950 --> 00:28:45,380 You don't have to check every subset here. 440 00:28:45,380 --> 00:28:47,620 And then you could do that by just summing 441 00:28:47,620 --> 00:28:51,560 over Rn being everything, and that cancels away 442 00:28:51,560 --> 00:28:53,016 to get rid of items. 443 00:28:53,016 --> 00:28:54,640 But you don't have to worry about that. 444 00:28:58,020 --> 00:29:00,540 OK, so we're going to change gears a little bit 445 00:29:00,540 --> 00:29:06,990 now, and talk about the probability distribution 446 00:29:06,990 --> 00:29:10,600 function, which is just a way a sort of writing 447 00:29:10,600 --> 00:29:14,860 down or characterizing the probabilities associated 448 00:29:14,860 --> 00:29:16,625 with each value being attained. 449 00:29:21,920 --> 00:29:33,690 So given a random variable, R, the probability 450 00:29:33,690 --> 00:29:53,360 also known as the point, distribution function, 451 00:29:53,360 --> 00:30:01,580 also denoted pdf, probability distribution function, for R 452 00:30:01,580 --> 00:30:03,700 is, well, it's very simple. 453 00:30:03,700 --> 00:30:07,940 It's just the function f of x, which equals 454 00:30:07,940 --> 00:30:11,320 the probability that R is x. 455 00:30:11,320 --> 00:30:12,940 Very simple. 456 00:30:12,940 --> 00:30:17,170 But now we're characterizing it as a function. 457 00:30:17,170 --> 00:30:20,320 And there's also a notion of the cumulative distribution 458 00:30:20,320 --> 00:30:24,830 function, which is going to be the probability that R 459 00:30:24,830 --> 00:30:27,130 is less than or equal to x. 460 00:30:27,130 --> 00:30:28,231 Let's write that down. 461 00:30:52,800 --> 00:31:12,500 The cumulative distribution function F 462 00:31:12,500 --> 00:31:19,820 for random variable R is simply f 463 00:31:19,820 --> 00:31:25,840 of x is the probability that R is at most x, which is just 464 00:31:25,840 --> 00:31:30,730 the sum over all y less than or equal to x 465 00:31:30,730 --> 00:31:32,510 the probability R equals y. 466 00:31:35,480 --> 00:31:40,930 So the distribution functions characterize the probability 467 00:31:40,930 --> 00:31:43,560 a random variable takes on any value, 468 00:31:43,560 --> 00:31:47,400 and there's certain common ones that just come up all the time. 469 00:31:47,400 --> 00:31:49,190 And so people have done a lot of analysis 470 00:31:49,190 --> 00:31:52,990 about them because they occur so frequently. 471 00:31:52,990 --> 00:31:56,110 And we're going to talk about three of them today. 472 00:32:02,830 --> 00:32:06,860 The first is really simple, and that 473 00:32:06,860 --> 00:32:10,000 is the Bernoulli random variable, 474 00:32:10,000 --> 00:32:11,820 or indicator random variable. 475 00:32:14,430 --> 00:32:29,520 All right, so for an indicator random variable, f 0 is p, 476 00:32:29,520 --> 00:32:36,290 and f 1 is 1 minus p, for sum p. 477 00:32:36,290 --> 00:32:38,817 The probability could be half, if you're flipping a coin. 478 00:32:38,817 --> 00:32:41,400 The probability of heads could be a half, probability of tails 479 00:32:41,400 --> 00:32:42,066 would be a half. 480 00:32:42,066 --> 00:32:45,360 It's just two values, 0 and 1. 481 00:32:45,360 --> 00:32:48,770 And then the cumulative function is very simple. 482 00:32:48,770 --> 00:32:53,130 F 0 is p, big F of 1 is 1. 483 00:32:55,710 --> 00:32:58,225 So that is about as simple of functions as you can get. 484 00:33:03,670 --> 00:33:07,390 The next simplest, and also very common, 485 00:33:07,390 --> 00:33:10,370 is called a uniform random variable. 486 00:33:14,970 --> 00:33:16,380 Let's define that. 487 00:33:26,300 --> 00:33:32,610 For a uniform random variable-- and we 488 00:33:32,610 --> 00:33:35,000 have to define what it's defined on-- 489 00:33:35,000 --> 00:33:42,900 on say the integers from 1 to n, every value is equally likely. 490 00:33:42,900 --> 00:33:46,600 All the integers from 1 to n are equally likely to occur. 491 00:33:46,600 --> 00:33:51,470 And so in this case, n is a parameter of the function. 492 00:33:51,470 --> 00:33:54,750 fn of K is simply 1/n. 493 00:33:54,750 --> 00:33:57,860 Each integer from 1 to n is equally likely. 494 00:33:57,860 --> 00:33:59,260 So it's 1 and n. 495 00:34:03,990 --> 00:34:06,360 All right, what is the cumulative distribution 496 00:34:06,360 --> 00:34:08,920 function for this? 497 00:34:08,920 --> 00:34:13,989 What is big F of n of K for the uniform? 498 00:34:13,989 --> 00:34:18,350 The probability that the random variable 499 00:34:18,350 --> 00:34:22,518 takes a value that's at most K? 500 00:34:22,518 --> 00:34:24,449 AUDIENCE: [INAUDIBLE]? 501 00:34:24,449 --> 00:34:27,199 PROFESSOR: Close, K/n. 502 00:34:27,199 --> 00:34:30,139 And you could think of K being 1. 503 00:34:30,139 --> 00:34:33,469 You have a least the 1 over n probability. 504 00:34:33,469 --> 00:34:35,290 So you have K chances. 505 00:34:35,290 --> 00:34:40,159 It could be 1, 2, 3, 4 up to K, each has a 1/n chance. 506 00:34:40,159 --> 00:34:42,380 Because we've got, the definition 507 00:34:42,380 --> 00:34:47,469 is less than or equal, not less than. 508 00:34:51,020 --> 00:34:53,250 Uniform distributions come up all the time, 509 00:34:53,250 --> 00:34:59,460 rolling a fair die is uniform on 1 through 6 for values. 510 00:34:59,460 --> 00:35:02,560 If I pick a random student in the class, the chance 511 00:35:02,560 --> 00:35:05,940 I pick you is 1 in the size of the class. 512 00:35:05,940 --> 00:35:07,520 We have uniform sample spaces. 513 00:35:07,520 --> 00:35:12,300 Each outcome occurs equally likely. 514 00:35:12,300 --> 00:35:16,340 All right, any questions about uniform? 515 00:35:16,340 --> 00:35:18,552 [INAUDIBLE] 516 00:35:18,552 --> 00:35:20,260 OK, so while we're talking about uniform, 517 00:35:20,260 --> 00:35:24,970 I want to play a game, whose optimal 518 00:35:24,970 --> 00:35:26,980 strategy is going to turn out to be related 519 00:35:26,980 --> 00:35:30,120 to uniform distributions. 520 00:35:30,120 --> 00:35:33,750 Now the game works as follows. 521 00:35:33,750 --> 00:35:37,890 I'm going to have two envelopes here. 522 00:35:37,890 --> 00:35:42,400 And inside each envelope, I've written a number. 523 00:35:42,400 --> 00:35:45,060 And the number in this case is a number 524 00:35:45,060 --> 00:35:47,155 between 0 and 100 inclusive. 525 00:35:50,710 --> 00:35:54,090 It's not a random number, because I wrote it, 526 00:35:54,090 --> 00:35:56,600 and maybe I'm not such a nice guy. 527 00:35:56,600 --> 00:35:59,230 I might have picked nasty numbers to write here. 528 00:35:59,230 --> 00:36:00,910 They are different, though. 529 00:36:00,910 --> 00:36:04,060 The numbers are different in the envelopes. 530 00:36:04,060 --> 00:36:07,260 Now I'm going to pick a volunteer from the class, 531 00:36:07,260 --> 00:36:10,630 and their job is to pick the envelope with the bigger 532 00:36:10,630 --> 00:36:12,200 number. 533 00:36:12,200 --> 00:36:14,910 And if they get the one with the bigger number, 534 00:36:14,910 --> 00:36:19,520 then they get one of these guys for ice cream. 535 00:36:19,520 --> 00:36:22,910 And if they don't get the one with the bigger number, 536 00:36:22,910 --> 00:36:27,340 they get the nerd pride pocket protector. 537 00:36:27,340 --> 00:36:31,030 Now, since you don't know which number I put in which, 538 00:36:31,030 --> 00:36:35,520 50-50 if you get the prize, the $10 gift certificate. 539 00:36:35,520 --> 00:36:37,980 So to give you a little bit of an edge, 540 00:36:37,980 --> 00:36:41,060 I'm going to let you open one of the envelopes 541 00:36:41,060 --> 00:36:43,320 and see what number's there. 542 00:36:43,320 --> 00:36:46,780 Then you have to decide, do you want the number you got, 543 00:36:46,780 --> 00:36:50,210 or do you want the other envelope? 544 00:36:50,210 --> 00:36:52,330 OK? 545 00:36:52,330 --> 00:36:54,850 Is the game clear, what we're going to do? 546 00:36:54,850 --> 00:36:56,740 OK, so need a couple of volunteers. 547 00:36:56,740 --> 00:36:58,950 We're going to do it twice. 548 00:36:58,950 --> 00:37:01,590 All right, somebody way in the back up there. 549 00:37:01,590 --> 00:37:02,520 Any other volunteers? 550 00:37:02,520 --> 00:37:03,520 All right, come on down. 551 00:37:03,520 --> 00:37:05,017 Oh, you've already played before. 552 00:37:05,017 --> 00:37:07,190 (LAUGHTER) You already got. 553 00:37:07,190 --> 00:37:12,510 Who hasn't played before, wants to-- all right, come on up. 554 00:37:12,510 --> 00:37:15,641 Now you want to be thinking about, boy, is there a strategy 555 00:37:15,641 --> 00:37:16,140 here? 556 00:37:16,140 --> 00:37:17,660 Or is this just dumb luck, 50-50? 557 00:37:20,960 --> 00:37:21,965 OK, what's your name? 558 00:37:21,965 --> 00:37:22,590 AUDIENCE: Sean. 559 00:37:22,590 --> 00:37:23,410 PROFESSOR: Sean. 560 00:37:23,410 --> 00:37:25,700 All right, I got two envelopes, Sean. 561 00:37:25,700 --> 00:37:28,170 They are numbers between 0 and 100. 562 00:37:28,170 --> 00:37:33,707 And you can pick one, and we'll reveal the number, 563 00:37:33,707 --> 00:37:34,540 and then you decide. 564 00:37:34,540 --> 00:37:37,081 Do you want the number you got, or do you want the other one? 565 00:37:37,081 --> 00:37:39,510 The goal is to get the bigger number. 566 00:37:39,510 --> 00:37:40,650 So take one and open it. 567 00:37:48,105 --> 00:37:49,099 What did you get? 568 00:37:49,099 --> 00:37:50,587 AUDIENCE: 6. 569 00:37:50,587 --> 00:37:51,087 He got 570 00:37:51,087 --> 00:37:52,590 PROFESSOR: A 6. 571 00:37:52,590 --> 00:37:56,070 The numbers go from 0 to 100. 572 00:37:56,070 --> 00:37:57,880 What do you think Sean should do? 573 00:37:57,880 --> 00:37:59,202 AUDIENCE: Switch. 574 00:37:59,202 --> 00:37:59,701 [INAUDIBLE] 575 00:38:02,250 --> 00:38:04,289 PROFESSOR: What do you think you should do? 576 00:38:04,289 --> 00:38:05,205 AUDIENCE: [INAUDIBLE]. 577 00:38:08,670 --> 00:38:10,650 AUDIENCE: They've got to check the other one. 578 00:38:10,650 --> 00:38:13,085 PROFESSOR: No, no, you can't look at the other one. 579 00:38:13,085 --> 00:38:14,710 And unfortunately, you're going to play 580 00:38:14,710 --> 00:38:16,850 with different envelopes. 581 00:38:16,850 --> 00:38:18,240 What should you do? 582 00:38:18,240 --> 00:38:22,410 6, there's a lot of numbers bigger than 6, Sean. 583 00:38:22,410 --> 00:38:25,920 But they might not be in that envelope. 584 00:38:25,920 --> 00:38:27,730 Might be a 0 in that envelope. 585 00:38:27,730 --> 00:38:28,900 AUDIENCE: That would suck. 586 00:38:28,900 --> 00:38:29,180 PROFESSOR: Yeah. 587 00:38:29,180 --> 00:38:30,110 AUDIENCE: I'll stay. 588 00:38:30,110 --> 00:38:31,220 PROFESSOR: You're going to stay with 6? 589 00:38:31,220 --> 00:38:31,930 AUDIENCE: Yup. 590 00:38:31,930 --> 00:38:32,680 PROFESSOR: All right, he picked 6. 591 00:38:32,680 --> 00:38:34,263 What do you think he should have done? 592 00:38:34,263 --> 00:38:36,350 How many people think he should have switched? 593 00:38:36,350 --> 00:38:37,210 Ooh, Sean. 594 00:38:37,210 --> 00:38:40,010 How many people like Sean's choice? 595 00:38:40,010 --> 00:38:40,700 Not so good. 596 00:38:40,700 --> 00:38:42,033 All right, let's see if you won. 597 00:38:45,470 --> 00:38:46,855 Here we go. 598 00:38:46,855 --> 00:38:48,550 5. 599 00:38:48,550 --> 00:38:50,560 Sean wins the ice cream. 600 00:38:50,560 --> 00:38:52,150 Good work. 601 00:38:52,150 --> 00:38:56,147 Now Sean, what was your thinking here? 602 00:38:56,147 --> 00:38:58,582 AUDIENCE: I was thinking [INAUDIBLE] 603 00:38:58,582 --> 00:39:03,452 in the other envelope, knowing that 6 doesn't tell me 604 00:39:03,452 --> 00:39:05,887 anything about what's in the other one, 605 00:39:05,887 --> 00:39:07,835 so my chances of seeing [INAUDIBLE]. 606 00:39:10,760 --> 00:39:12,900 PROFESSOR: Totally 50-50. 607 00:39:12,900 --> 00:39:15,130 How many people buy that argument? 608 00:39:15,130 --> 00:39:15,756 It's 50-50. 609 00:39:15,756 --> 00:39:17,880 He really has no idea what's in the other envelope. 610 00:39:17,880 --> 00:39:21,160 How many people think there's a better way? 611 00:39:21,160 --> 00:39:21,785 Not too many. 612 00:39:21,785 --> 00:39:23,410 All right, we're going to try it again. 613 00:39:23,410 --> 00:39:24,170 Well done. 614 00:39:24,170 --> 00:39:26,304 I've got different envelopes here. 615 00:39:26,304 --> 00:39:27,470 And tell me your name again? 616 00:39:27,470 --> 00:39:28,095 AUDIENCE: Drew. 617 00:39:28,095 --> 00:39:29,510 PROFESSOR: Drew, OK Drew. 618 00:39:29,510 --> 00:39:31,230 Two envelopes. 619 00:39:31,230 --> 00:39:33,136 Which one would you like to open? 620 00:39:33,136 --> 00:39:34,510 AUDIENCE: They're both labeled B. 621 00:39:34,510 --> 00:39:37,430 PROFESSOR: They're both labeled B. That won't help you there. 622 00:39:37,430 --> 00:39:38,430 All right, he's got one. 623 00:39:41,600 --> 00:39:42,570 Let's see what you got. 624 00:39:49,510 --> 00:39:51,620 92. 625 00:39:51,620 --> 00:39:54,520 Oh my goodness, and we've seen what 5 and 6. 626 00:39:54,520 --> 00:39:55,830 What are you going to do? 627 00:39:55,830 --> 00:39:57,300 92. 628 00:39:57,300 --> 00:39:58,540 What should he do, guys? 629 00:39:58,540 --> 00:39:59,174 AUDIENCE: Stay. 630 00:39:59,174 --> 00:39:59,840 PROFESSOR: Stay. 631 00:39:59,840 --> 00:40:02,780 Oh he's got a big number there. 632 00:40:02,780 --> 00:40:04,160 You're going to switch? 633 00:40:04,160 --> 00:40:06,670 You're giving up a 92? 634 00:40:06,670 --> 00:40:09,480 Ooh, you're sure? 635 00:40:09,480 --> 00:40:10,410 You don't want the 92? 636 00:40:13,140 --> 00:40:15,641 How many people think Drew is going to win? 637 00:40:15,641 --> 00:40:16,890 AUDIENCE: He's trying to lose. 638 00:40:16,890 --> 00:40:18,250 PROFESSOR: A couple people. 639 00:40:18,250 --> 00:40:20,909 Let's see. 640 00:40:20,909 --> 00:40:21,450 AUDIENCE: 91. 641 00:40:24,366 --> 00:40:26,320 It's either 91 or 93. 642 00:40:26,320 --> 00:40:29,870 PROFESSOR: 93, how did you know there was a bigger number? 643 00:40:29,870 --> 00:40:31,229 Wow, very good. 644 00:40:31,229 --> 00:40:31,770 There you go. 645 00:40:31,770 --> 00:40:33,500 What was your strategy? 646 00:40:33,500 --> 00:40:36,580 AUDIENCE: I figured you'd probably pick them within 1. 647 00:40:36,580 --> 00:40:38,068 PROFESSOR: Yeah, that's good. 648 00:40:38,068 --> 00:40:38,984 AUDIENCE: [INAUDIBLE]. 649 00:40:49,972 --> 00:40:52,452 PROFESSOR: Actually, they're both [INAUDIBLE] to 93. 650 00:40:52,452 --> 00:40:54,350 Would you still switch? 651 00:40:54,350 --> 00:40:56,560 AUDIENCE: [INAUDIBLE]. 652 00:40:56,560 --> 00:40:57,600 PROFESSOR: Still switch. 653 00:40:57,600 --> 00:40:58,480 Hmm. 654 00:40:58,480 --> 00:41:00,518 All right, so is it 50-50 then? 655 00:41:00,518 --> 00:41:03,410 Because you see a 92 a 93, you're switching either way. 656 00:41:03,410 --> 00:41:04,300 AUDIENCE: Yeah. 657 00:41:04,300 --> 00:41:05,635 PROFESSOR: 50-50. 658 00:41:05,635 --> 00:41:07,670 All right, how many people still like 50-50? 659 00:41:07,670 --> 00:41:10,880 He can't beat 50-50 here. 660 00:41:10,880 --> 00:41:11,380 Any ideas? 661 00:41:11,380 --> 00:41:12,840 Can you beat 50-50? 662 00:41:12,840 --> 00:41:13,796 Yeah. 663 00:41:13,796 --> 00:41:16,664 AUDIENCE: I just pay attention to your face. 664 00:41:16,664 --> 00:41:19,391 PROFESSOR: I guess I gave it away. 665 00:41:19,391 --> 00:41:22,300 I think I've lost every bet so far in the course here, 666 00:41:22,300 --> 00:41:24,320 even on Monty Hall, every time. 667 00:41:24,320 --> 00:41:27,450 So I guess I have a tell or something here. 668 00:41:27,450 --> 00:41:31,210 Now, in fact, you can beat 50-50. 669 00:41:31,210 --> 00:41:32,530 The information is helpful. 670 00:41:32,530 --> 00:41:34,835 Now, just to be clear, are these numbers 671 00:41:34,835 --> 00:41:37,760 that I wrote down random? 672 00:41:37,760 --> 00:41:38,490 No. 673 00:41:38,490 --> 00:41:40,100 No, I'm trying not to give away-- 674 00:41:40,100 --> 00:41:42,180 my ice cream bill is going through the roof here. 675 00:41:42,180 --> 00:41:43,320 I'm trying to make it hard. 676 00:41:43,320 --> 00:41:45,570 They're very much not random. 677 00:41:45,570 --> 00:41:48,400 There were two smalls and two bigs. 678 00:41:48,400 --> 00:41:51,086 What is random here? 679 00:41:51,086 --> 00:41:52,460 AUDIENCE: Which one he picked is. 680 00:41:52,460 --> 00:41:55,810 PROFESSOR: Which one he saw, that's 50-50, effectively. 681 00:41:55,810 --> 00:41:58,920 So that's random there. 682 00:41:58,920 --> 00:42:03,810 Now his strategy could also be random, but it wasn't. 683 00:42:03,810 --> 00:42:05,710 His strategy was, if he sees a big number, 684 00:42:05,710 --> 00:42:07,320 he's swapping, which is odd. 685 00:42:07,320 --> 00:42:09,914 Most people see the big number, they want to keep it. 686 00:42:09,914 --> 00:42:11,330 You know, I'd have done well today 687 00:42:11,330 --> 00:42:13,621 if I had a really big number and a really small number, 688 00:42:13,621 --> 00:42:15,470 because then I would have won both times. 689 00:42:19,560 --> 00:42:23,530 OK, so to see why there might be a winning strategy, or better 690 00:42:23,530 --> 00:42:27,510 than 50-50, imagine that I had been nice 691 00:42:27,510 --> 00:42:30,020 and put a very small number in one envelope 692 00:42:30,020 --> 00:42:32,640 and a very big number of the other envelope. 693 00:42:32,640 --> 00:42:37,520 Say I had a 5 in one and a 92 in the other. 694 00:42:37,520 --> 00:42:41,230 Can you win then, if you know that? 695 00:42:41,230 --> 00:42:43,280 OK, how do you win if you know there's one less 696 00:42:43,280 --> 00:42:46,100 than 10 and one bigger than 90? 697 00:42:46,100 --> 00:42:47,247 Yeah? 698 00:42:47,247 --> 00:42:49,330 AUDIENCE: If you get the one less than 10, switch. 699 00:42:49,330 --> 00:42:50,705 PROFESSOR: Yeah, and you're going 700 00:42:50,705 --> 00:42:52,820 to win with what probability? 701 00:42:52,820 --> 00:42:53,675 1. 702 00:42:53,675 --> 00:42:55,910 It's a certainty. 703 00:42:55,910 --> 00:43:03,700 All right, well, but I'm not that nice, say. 704 00:43:03,700 --> 00:43:06,190 Say, though, there is a threshold 705 00:43:06,190 --> 00:43:10,720 x, such that one of the numbers is less than x, 706 00:43:10,720 --> 00:43:15,510 and one is bigger than x, and you know x. 707 00:43:15,510 --> 00:43:16,330 Can you win now? 708 00:43:19,600 --> 00:43:22,750 Say you know that one number is less than 47 and 1/2, 709 00:43:22,750 --> 00:43:25,700 and one is bigger than 47 and 1/2. 710 00:43:25,700 --> 00:43:27,380 Can you win? 711 00:43:27,380 --> 00:43:31,030 Yeah, because if you get the one less than 47 and 1/2, 712 00:43:31,030 --> 00:43:31,947 you switch. 713 00:43:31,947 --> 00:43:33,030 And otherwise you'll stay. 714 00:43:33,030 --> 00:43:36,240 So again, you win with certainty. 715 00:43:36,240 --> 00:43:38,730 All right, that's good. 716 00:43:38,730 --> 00:43:40,130 Is there always such an x? 717 00:43:43,400 --> 00:43:46,810 You may not know it, but is there always such an x? 718 00:43:46,810 --> 00:43:48,840 Yeah, because the numbers are different. 719 00:43:48,840 --> 00:43:51,080 Just pick up a real number in between them. 720 00:43:51,080 --> 00:43:54,110 You know, with 92 and 93, there's 92 and 1/2, 721 00:43:54,110 --> 00:43:55,670 is such an x. 722 00:43:55,670 --> 00:43:59,470 Now the only problem is you don't know it. 723 00:43:59,470 --> 00:44:01,920 And there's no way to figure it out that's 724 00:44:01,920 --> 00:44:04,580 within the rules of the game. 725 00:44:04,580 --> 00:44:08,970 Now in life, if you don't know something, 726 00:44:08,970 --> 00:44:12,870 and you can't figure it out, what can you do? 727 00:44:12,870 --> 00:44:13,670 AUDIENCE: Guess. 728 00:44:13,670 --> 00:44:15,340 PROFESSOR: Guess it. 729 00:44:15,340 --> 00:44:18,080 All right, now this turns out to be a really good thing to do, 730 00:44:18,080 --> 00:44:21,757 and especially good in a lot of computer science situations. 731 00:44:21,757 --> 00:44:23,590 If you don't know it, and you can't know it, 732 00:44:23,590 --> 00:44:28,210 well you could try to guess and you might be right. 733 00:44:28,210 --> 00:44:31,570 Now, if you guess x and you are right, 734 00:44:31,570 --> 00:44:34,060 what's your probability of winning? 735 00:44:34,060 --> 00:44:35,970 1. 736 00:44:35,970 --> 00:44:40,220 If you don't guess x, what's your probability of winning? 737 00:44:40,220 --> 00:44:44,100 Say you guess wrong, but you follow the rule that 738 00:44:44,100 --> 00:44:46,100 if it's less than what you guessed, you swap it, 739 00:44:46,100 --> 00:44:47,560 otherwise you don't. 740 00:44:47,560 --> 00:44:51,370 What's your probability of winning that? 741 00:44:51,370 --> 00:44:51,960 P? 742 00:44:51,960 --> 00:44:55,490 Well, yeah, what's P? 743 00:44:55,490 --> 00:44:58,840 It's a nice value of P. 744 00:44:58,840 --> 00:45:00,900 You know, say you guessed-- well, 745 00:45:00,900 --> 00:45:04,719 say you weren't paying attention and you guessed 200. 746 00:45:04,719 --> 00:45:07,010 And your rule is, if you're less than what you guessed, 747 00:45:07,010 --> 00:45:09,650 you're less than 200, you swap, which means 748 00:45:09,650 --> 00:45:12,040 you're just going to swap. 749 00:45:12,040 --> 00:45:14,690 And you started with a random one, so what's 750 00:45:14,690 --> 00:45:17,370 your chance of winning? 751 00:45:17,370 --> 00:45:19,190 A half. 752 00:45:19,190 --> 00:45:21,670 So if you guessed wrong, you didn't lose anything. 753 00:45:21,670 --> 00:45:23,580 You still win with probability a half. 754 00:45:23,580 --> 00:45:27,860 If you guessed right, you win with probability 1, 755 00:45:27,860 --> 00:45:29,610 and there's some chance you guessed right, 756 00:45:29,610 --> 00:45:33,250 so now you've got a strategy that beats 50-50, 757 00:45:33,250 --> 00:45:35,970 because you guessed. 758 00:45:35,970 --> 00:45:39,040 OK, and this is a whole field in computer science 759 00:45:39,040 --> 00:45:41,840 where you get randomized algorithms, where 760 00:45:41,840 --> 00:45:46,760 this strategy depends on a coin flip, on guessing a value. 761 00:45:46,760 --> 00:45:51,360 And it leads to getting potentially a better outcome. 762 00:45:51,360 --> 00:45:53,260 All right, so let's prove that now 763 00:45:53,260 --> 00:45:57,320 and see what the probability is of winning with the guess 764 00:45:57,320 --> 00:45:59,468 strategy and what's a good way to guess. 765 00:46:07,290 --> 00:46:10,780 So we're going to first formalize our random protocol. 766 00:46:21,350 --> 00:46:30,500 All right, so if this is the winning strategy, 767 00:46:30,500 --> 00:46:42,020 well first the envelopes contain y and z, 768 00:46:42,020 --> 00:46:45,730 and they're in the interval 0 to n. 769 00:46:45,730 --> 00:46:47,587 And y is going to be less than z. 770 00:46:47,587 --> 00:46:49,170 That's how we're going to define them. 771 00:46:49,170 --> 00:46:53,290 Now you don't know y and z, but y 772 00:46:53,290 --> 00:46:56,730 is the smaller number in the envelope, z is the larger. 773 00:46:56,730 --> 00:47:01,230 And in our example, n was 100. 774 00:47:01,230 --> 00:47:12,540 Now the player chooses x randomly, 775 00:47:12,540 --> 00:47:18,800 uniformly among all the possible half integers. 776 00:47:21,520 --> 00:47:26,230 So he might pick 1/2, he might pick 1 and 1/2, 2 and 1/2, 777 00:47:26,230 --> 00:47:29,844 all the way out to n minus 1/2. 778 00:47:29,844 --> 00:47:32,010 You know, because if the player picks anything else, 779 00:47:32,010 --> 00:47:33,500 it's useless. 780 00:47:33,500 --> 00:47:35,590 He won't have a chance to win. 781 00:47:35,590 --> 00:47:37,880 But he might, in the case of 5 and 6, 782 00:47:37,880 --> 00:47:40,570 might have picked 5 and 1/2. 783 00:47:40,570 --> 00:47:44,100 And we're going to make our random guess be equally likely 784 00:47:44,100 --> 00:47:48,060 among those n values, because well he doesn't really 785 00:47:48,060 --> 00:47:52,290 know what the numbers are I put in the envelopes. 786 00:47:52,290 --> 00:47:56,976 If he sees 6, he doesn't know if it's 5 or it's 7, OK? 787 00:47:56,976 --> 00:47:59,350 So that's why we're going to pick them all equally likely 788 00:47:59,350 --> 00:48:00,058 and it's uniform. 789 00:48:02,860 --> 00:48:07,850 Now the player is hoping that he picked a value that 790 00:48:07,850 --> 00:48:12,500 splits y and z, OK? 791 00:48:12,500 --> 00:48:15,329 Because then he's going to win. 792 00:48:15,329 --> 00:48:17,620 If he picked an x between the numbers in the envelopes, 793 00:48:17,620 --> 00:48:21,860 and follows the swap, if he got the small number less than x, 794 00:48:21,860 --> 00:48:27,050 he's going to win, all right? 795 00:48:27,050 --> 00:48:41,100 Then the player opens a random envelope, 50-50, 796 00:48:41,100 --> 00:48:47,340 to reveal a number r, which is either y or z, 797 00:48:47,340 --> 00:48:51,730 but the player doesn't know which one. 798 00:48:51,730 --> 00:48:55,690 So one of the numbers gets revealed. 799 00:48:55,690 --> 00:49:03,100 And then the last step is the player swaps 800 00:49:03,100 --> 00:49:08,720 if the number he revealed is less than the guessed split 801 00:49:08,720 --> 00:49:09,220 number. 802 00:49:12,580 --> 00:49:16,400 That's the strategy, and it's a strategy 803 00:49:16,400 --> 00:49:22,720 that depends on a random guess or a random number. 804 00:49:26,302 --> 00:49:27,760 So let's figure out the probability 805 00:49:27,760 --> 00:49:30,060 of winning with that strategy. 806 00:49:30,060 --> 00:49:33,640 And we're going to use the tree method. 807 00:49:33,640 --> 00:49:37,410 Well, the first branch in the tree method 808 00:49:37,410 --> 00:49:40,700 is whether or not-- where the guess wound up. 809 00:49:40,700 --> 00:49:42,770 And there's three cases for how the guess did. 810 00:49:45,320 --> 00:49:48,660 You might have guessed too low, in which case, 811 00:49:48,660 --> 00:49:53,590 x is less than y, and y is less than z. 812 00:49:53,590 --> 00:49:57,130 You might have guessed perfectly, in which case 813 00:49:57,130 --> 00:50:02,570 x is between y and z, equals not possible. 814 00:50:02,570 --> 00:50:04,840 Or you might have guessed too high, 815 00:50:04,840 --> 00:50:08,470 in which case y is less than z is less than x. 816 00:50:08,470 --> 00:50:13,545 All right, so here's low, here's high, and here's 817 00:50:13,545 --> 00:50:17,270 an OK guess, a good guess. 818 00:50:17,270 --> 00:50:21,920 Now what's the probability you guessed low, that you 819 00:50:21,920 --> 00:50:25,130 picked an x less than y? 820 00:50:25,130 --> 00:50:30,140 y is integers, x is the half integers. 821 00:50:30,140 --> 00:50:33,690 What's the probability to assign to that chance, 822 00:50:33,690 --> 00:50:36,925 that you guessed low? 823 00:50:36,925 --> 00:50:39,547 You could use the value of y in your answer. 824 00:50:39,547 --> 00:50:41,630 You don't know y, but we can write it on the tree. 825 00:50:44,790 --> 00:50:47,686 What if y was 1? 826 00:50:47,686 --> 00:50:49,185 The smallest number in the envelopes 827 00:50:49,185 --> 00:50:54,310 is one, what's the probability you guessed below 1? 828 00:50:57,660 --> 00:51:02,950 Not quite 0, one of your possible end guesses 829 00:51:02,950 --> 00:51:05,920 would be too low, namely, a half. 830 00:51:05,920 --> 00:51:10,170 If the smallest number y were 2, what's 831 00:51:10,170 --> 00:51:13,340 the probability you guess below 2? 832 00:51:13,340 --> 00:51:15,070 2/n. 833 00:51:15,070 --> 00:51:19,510 And in general, if y is the smallest value, 834 00:51:19,510 --> 00:51:21,440 you've got y possible guesses that it 835 00:51:21,440 --> 00:51:27,070 would be too low, namely all the half integers less than y. 836 00:51:27,070 --> 00:51:31,920 So the probability you guess low is y/n, 837 00:51:31,920 --> 00:51:34,190 because each one is 1 in n chance. 838 00:51:34,190 --> 00:51:37,250 And there's y that are too low. 839 00:51:37,250 --> 00:51:39,070 What's the probability your guess is good, 840 00:51:39,070 --> 00:51:40,430 that you split y and z? 841 00:51:44,930 --> 00:51:52,310 z minus y over n, because they're-- between these 842 00:51:52,310 --> 00:51:56,910 integers, z and y, there's z minus y half integers. 843 00:51:56,910 --> 00:51:59,792 Each could have been guessed with probability 1/n. 844 00:51:59,792 --> 00:52:01,625 And what's the probability you guessed high? 845 00:52:04,330 --> 00:52:07,560 n minus z over n, because there's 846 00:52:07,560 --> 00:52:11,856 n minus g half integers between z 847 00:52:11,856 --> 00:52:16,570 and n being the last possible one, and minus the half there. 848 00:52:16,570 --> 00:52:19,620 All right, so we've got the first branch. 849 00:52:19,620 --> 00:52:24,620 Now the next branch is the revealed value. 850 00:52:24,620 --> 00:52:29,190 Did you open the smaller one or the larger one? 851 00:52:29,190 --> 00:52:31,430 r equals y means you opened the smaller one. 852 00:52:31,430 --> 00:52:33,300 r equals z means you saw the bigger one. 853 00:52:42,580 --> 00:52:44,995 All right, if I've gone down this branch where 854 00:52:44,995 --> 00:52:47,750 I guessed too low, but I don't know that, yet, 855 00:52:47,750 --> 00:52:49,880 but say I've guessed too low, what's 856 00:52:49,880 --> 00:52:52,120 the probability I opened the smaller envelope? 857 00:52:55,830 --> 00:52:58,500 One half, because you're just picking a random envelope 858 00:52:58,500 --> 00:52:59,870 and opening up. 859 00:52:59,870 --> 00:53:02,790 So these each happen with probability a half. 860 00:53:02,790 --> 00:53:05,066 And that's true no matter what. 861 00:53:05,066 --> 00:53:05,940 They're all one half. 862 00:53:08,530 --> 00:53:13,370 All right, well, now we can compute the probability 863 00:53:13,370 --> 00:53:14,910 of each outcome. 864 00:53:14,910 --> 00:53:19,490 This is y/n times 1/2, is y over 2n. 865 00:53:19,490 --> 00:53:22,920 This is y over 2n also. 866 00:53:22,920 --> 00:53:24,880 This is z minus y over 2n. 867 00:53:27,742 --> 00:53:31,090 z minus y over 2n. 868 00:53:31,090 --> 00:53:32,910 n minus z over 2n. 869 00:53:39,298 --> 00:53:42,030 All right, I got all the sample points. 870 00:53:42,030 --> 00:53:45,530 I got all the probabilities. 871 00:53:45,530 --> 00:53:46,872 Let's figure out if you win now. 872 00:53:46,872 --> 00:53:49,080 And to do that, the first thing we have to figure out 873 00:53:49,080 --> 00:53:49,995 is, do you swap? 874 00:53:52,650 --> 00:53:54,073 Do you swap here? 875 00:53:58,627 --> 00:53:59,460 Well, what happened? 876 00:53:59,460 --> 00:54:04,240 I revealed y, which is bigger than my split value 877 00:54:04,240 --> 00:54:06,270 x, my guessed value. 878 00:54:06,270 --> 00:54:10,890 And so I am guessing I've got the biggest value. 879 00:54:10,890 --> 00:54:13,800 So I don't swap. 880 00:54:13,800 --> 00:54:14,850 So there's no swap. 881 00:54:18,340 --> 00:54:19,060 What about here? 882 00:54:19,060 --> 00:54:20,140 Do I swap here? 883 00:54:23,070 --> 00:54:26,060 I open z, I saw z. 884 00:54:26,060 --> 00:54:29,890 z is bigger than what I think the midpoint is, 885 00:54:29,890 --> 00:54:30,740 so I wouldn't swap. 886 00:54:30,740 --> 00:54:33,830 I only guess if the value I reveal 887 00:54:33,830 --> 00:54:37,142 is less than my guessed midpoint. 888 00:54:37,142 --> 00:54:40,270 If I got a value I see bigger than my midpoint, 889 00:54:40,270 --> 00:54:42,256 I think I've got the big one. 890 00:54:42,256 --> 00:54:45,794 So there's no swap. 891 00:54:45,794 --> 00:54:46,460 What about here? 892 00:54:46,460 --> 00:54:48,490 Do I swap here? 893 00:54:48,490 --> 00:54:50,360 Yes, here I swap because I open up 894 00:54:50,360 --> 00:54:52,714 something that's less than my guessed midpoint, 895 00:54:52,714 --> 00:54:55,005 so I think I've got the small one so I'm going to swap. 896 00:54:59,060 --> 00:54:59,750 What about here? 897 00:54:59,750 --> 00:55:01,620 Do I swap here? 898 00:55:01,620 --> 00:55:03,340 No swap, because I opened up something 899 00:55:03,340 --> 00:55:05,070 that's bigger than midpoint. 900 00:55:05,070 --> 00:55:07,080 What about here? 901 00:55:07,080 --> 00:55:09,760 I swap. 902 00:55:09,760 --> 00:55:11,540 And what about here? 903 00:55:11,540 --> 00:55:13,532 Swap on both of them, because both of them 904 00:55:13,532 --> 00:55:17,370 are smaller than my guessed midpoint. 905 00:55:17,370 --> 00:55:21,210 All right, now let's figure out if you won or you lost. 906 00:55:21,210 --> 00:55:26,522 So here I did not swap and I started with a smaller value. 907 00:55:26,522 --> 00:55:27,230 So what happened? 908 00:55:27,230 --> 00:55:29,715 Did I win or lose? 909 00:55:29,715 --> 00:55:30,850 Lose. 910 00:55:30,850 --> 00:55:33,550 I opened he smaller value and did not swap. 911 00:55:33,550 --> 00:55:35,970 What happened here? 912 00:55:35,970 --> 00:55:36,650 I win. 913 00:55:36,650 --> 00:55:40,020 I open the bigger value and did not swap. 914 00:55:40,020 --> 00:55:42,350 Here what happened? 915 00:55:42,350 --> 00:55:45,950 Win, I opened the small value when I swapped, that's a win. 916 00:55:45,950 --> 00:55:48,330 Here? 917 00:55:48,330 --> 00:55:51,280 I opened the big value, did not swap. 918 00:55:51,280 --> 00:55:53,590 It's a win. 919 00:55:53,590 --> 00:55:57,590 Here I opened a small value and swap, that's a win. 920 00:55:57,590 --> 00:56:02,812 And here I opened a big value and swap, that's a lose. 921 00:56:02,812 --> 00:56:05,610 All right, now we can compute the probability of winning. 922 00:56:08,240 --> 00:56:12,540 The probability of a win is the sum of these four sample 923 00:56:12,540 --> 00:56:22,110 points-- y over 2n plus z minus y over 2n plus 924 00:56:22,110 --> 00:56:29,220 z minus y-- whoops-- over 2n plus n minus z over 2n. 925 00:56:33,090 --> 00:56:38,830 That equals-- z cancels the z, and a y cancels the y, 926 00:56:38,830 --> 00:56:44,820 so I've got n, one left, n left, one z left, 927 00:56:44,820 --> 00:56:49,730 and one negative y left over 2n. 928 00:56:49,730 --> 00:56:50,990 And I can simplify that. 929 00:56:50,990 --> 00:56:55,420 N over 2n is 1/2, plus now what's left over 930 00:56:55,420 --> 00:56:59,430 is z minus y over 2n. 931 00:57:02,140 --> 00:57:06,960 And we know the z and y are different by at least 1. 932 00:57:06,960 --> 00:57:11,270 So this is at least 1/2 plus 1 over 2n. 933 00:57:14,360 --> 00:57:20,280 And so if n is 100, you've got a 50 and 1/2% chance of winning. 934 00:57:20,280 --> 00:57:24,930 If n is 10, the numbers are from 0 to 10, 935 00:57:24,930 --> 00:57:28,220 you've got at least a 55% chance to win, 936 00:57:28,220 --> 00:57:31,430 which is pretty high, OK? 937 00:57:33,990 --> 00:57:35,700 Any questions here? 938 00:57:35,700 --> 00:57:36,700 You see what's going on? 939 00:57:36,700 --> 00:57:39,660 So here's the zone where you guessed right. 940 00:57:39,660 --> 00:57:41,190 You get the win either way. 941 00:57:41,190 --> 00:57:43,630 Here you guess low, and it doesn't make any difference. 942 00:57:43,630 --> 00:57:44,940 You're 50-50. 943 00:57:44,940 --> 00:57:48,690 You guessed high and you're 50-50 again. 944 00:57:48,690 --> 00:57:52,920 So guessing helps. 945 00:57:52,920 --> 00:57:54,500 Any questions about that? 946 00:57:54,500 --> 00:57:55,532 Yeah. 947 00:57:55,532 --> 00:57:58,484 AUDIENCE: So aren't you assuming that-- because you say, 948 00:57:58,484 --> 00:58:01,436 have a range, a greater range of numbers, 949 00:58:01,436 --> 00:58:04,224 that's there's a greater chance that the number is 950 00:58:04,224 --> 00:58:07,840 going fall in that range. 951 00:58:07,840 --> 00:58:10,050 PROFESSOR: I was the nasty guy here. 952 00:58:10,050 --> 00:58:12,720 I picked z and y to be consecutive numbers, which 953 00:58:12,720 --> 00:58:16,575 minimized your chance of doing well with this strategy. 954 00:58:16,575 --> 00:58:18,449 AUDIENCE: Because it seems like we don't know 955 00:58:18,449 --> 00:58:19,574 anything about [INAUDIBLE]. 956 00:58:22,746 --> 00:58:24,245 PROFESSOR: The distribution of what? 957 00:58:24,245 --> 00:58:26,579 AUDIENCE: Of possible other numbers 958 00:58:26,579 --> 00:58:27,620 in envelopes [INAUDIBLE]. 959 00:58:27,620 --> 00:58:30,000 PROFESSOR: Right, you know nothing about the distribution 960 00:58:30,000 --> 00:58:32,120 because there is none. 961 00:58:32,120 --> 00:58:33,530 There's no randomness there. 962 00:58:33,530 --> 00:58:36,900 I picked worst case numbers here. 963 00:58:36,900 --> 00:58:41,700 AUDIENCE: But it's still sort of like a [INAUDIBLE]. 964 00:58:41,700 --> 00:58:43,620 If it's 10, you still have a better chance 965 00:58:43,620 --> 00:58:48,120 to swap than if you [INAUDIBLE] below that. 966 00:58:48,120 --> 00:58:49,460 PROFESSOR: No. 967 00:58:49,460 --> 00:58:52,320 No, any deterministic strategy you pick, 968 00:58:52,320 --> 00:58:54,470 if you don't guess that random x, 969 00:58:54,470 --> 00:58:58,110 you will not do better than 50-50. 970 00:58:58,110 --> 00:59:01,470 The only way you'd beat 50-50 is to, in your mind, 971 00:59:01,470 --> 00:59:07,390 make a random number 13 and 1/2 and flip if you 972 00:59:07,390 --> 00:59:09,780 see less than 13 and 1/2. 973 00:59:09,780 --> 00:59:11,640 If you come in with a strategy that hey, 974 00:59:11,640 --> 00:59:15,350 10 is a small number, out of 100, 975 00:59:15,350 --> 00:59:19,380 and so I'm going to swap if I see a 10, 976 00:59:19,380 --> 00:59:22,600 well, no, because first it could be-- I might have done 977 00:59:22,600 --> 00:59:23,720 9 or 11, either one. 978 00:59:23,720 --> 00:59:26,470 In fact, if I know that's your strategy, 979 00:59:26,470 --> 00:59:29,530 I'm going to make a 9. 980 00:59:29,530 --> 00:59:32,620 And then you're doomed in seeing a 10. 981 00:59:32,620 --> 00:59:34,870 AUDIENCE: So is there a best way to pick that? 982 00:59:34,870 --> 00:59:38,680 PROFESSOR: Yes, I also have an optimal strategy. 983 00:59:38,680 --> 00:59:41,350 In fact, there's two interesting things 984 00:59:41,350 --> 00:59:43,630 about this game which we won't prove. 985 00:59:43,630 --> 00:59:46,500 The first thing we'll prove, we will prove but it's true, 986 00:59:46,500 --> 00:59:50,470 is this is the optimal strategy for you. 987 00:59:50,470 --> 00:59:53,520 And my optimal strategy is to pick 988 00:59:53,520 --> 00:59:57,820 a random value of y between 0 and n minus 1, 989 00:59:57,820 --> 01:00:01,217 and then to make z be one more. 990 01:00:01,217 --> 01:00:03,050 And the way to think about this, and there's 991 01:00:03,050 --> 01:00:06,520 whole classes you can take on game theory, 992 01:00:06,520 --> 01:00:11,170 is that suppose I do pick my guys randomly 993 01:00:11,170 --> 01:00:14,900 by picking a random y uniformly from 0 to n minus 1. 994 01:00:14,900 --> 01:00:18,510 So my smaller number is anything between 0 and 99, 995 01:00:18,510 --> 01:00:22,550 equally likely, and then the bigger number's just one more. 996 01:00:22,550 --> 01:00:24,340 So if I picked 92 for the random one, 997 01:00:24,340 --> 01:00:26,360 the next one's going to be 93. 998 01:00:26,360 --> 01:00:30,350 If that's my strategy, even if I tell you that, 999 01:00:30,350 --> 01:00:35,354 you cannot do any better than getting 1/2 plus 1 over 2n 1000 01:00:35,354 --> 01:00:37,770 probability of winning, no matter what you do in the whole 1001 01:00:37,770 --> 01:00:40,420 world, OK? 1002 01:00:40,420 --> 01:00:43,620 And if you use this strategy here, 1003 01:00:43,620 --> 01:00:47,950 no matter what I do, even knowing that's your strategy, 1004 01:00:47,950 --> 01:00:52,730 I can't keep you from getting this much. 1005 01:00:52,730 --> 01:00:55,620 It's called a minimax solution. 1006 01:00:55,620 --> 01:00:59,170 So my optimal strategy is to pick uniformly in 0 to 99, 1007 01:00:59,170 --> 01:01:00,470 and the next one's one more. 1008 01:01:00,470 --> 01:01:02,880 Your optimal strategy is this. 1009 01:01:02,880 --> 01:01:06,447 Pick a number uniformly in the half integers there, 1010 01:01:06,447 --> 01:01:08,030 and swap if you see something smaller. 1011 01:01:08,030 --> 01:01:10,310 And there's no better strategy. 1012 01:01:10,310 --> 01:01:12,270 In fact, any deterministic strategy, 1013 01:01:12,270 --> 01:01:14,220 you don't do better than 50-50. 1014 01:01:14,220 --> 01:01:20,640 The optimal strategies require randomness for each of us. 1015 01:01:20,640 --> 01:01:27,320 OK, any more questions about what happened here, this game? 1016 01:01:27,320 --> 01:01:28,642 Yeah. 1017 01:01:28,642 --> 01:01:30,205 AUDIENCE: [INAUDIBLE] when you see 1018 01:01:30,205 --> 01:01:32,971 a small number you're going to swap, does that just mean 1019 01:01:32,971 --> 01:01:35,380 [INAUDIBLE]? 1020 01:01:35,380 --> 01:01:39,220 PROFESSOR: Yeah, basically, yeah, that's what it means. 1021 01:01:39,220 --> 01:01:41,650 Effectively, that 50 is your random number. 1022 01:01:41,650 --> 01:01:44,180 If you think OK, if I see less than 50, I'm going to swap, 1023 01:01:44,180 --> 01:01:45,240 bigger than 50 I don't. 1024 01:01:45,240 --> 01:01:46,710 Now you have to decide what happens 1025 01:01:46,710 --> 01:01:49,010 at 50, if you saw exactly 50. 1026 01:01:49,010 --> 01:01:52,819 So you'd probably go in at 49 and 1/2 and 50 and 1/2. 1027 01:01:52,819 --> 01:01:54,610 And so that could be construed as that way. 1028 01:01:54,610 --> 01:01:57,400 But you didn't pick it randomly, and that sort 1029 01:01:57,400 --> 01:02:00,130 of human intuition, to swap so I could 1030 01:02:00,130 --> 01:02:02,980 use that now to design my strategy, 1031 01:02:02,980 --> 01:02:07,780 knowing that your random numbers could be 50 and 1/2, OK? 1032 01:02:10,500 --> 01:02:12,010 No, I'll be 50-50 because what I'll 1033 01:02:12,010 --> 01:02:13,740 do, if I know that's your strategy, 1034 01:02:13,740 --> 01:02:14,990 my numbers will be 1 and 2. 1035 01:02:17,760 --> 01:02:19,480 Well, when you do these analyses, 1036 01:02:19,480 --> 01:02:23,540 you sort of, if it's declared that's it, I can assume that. 1037 01:02:23,540 --> 01:02:25,486 And I might actually guess that. 1038 01:02:25,486 --> 01:02:28,150 In fact, that's why I did pick two very small numbers and two 1039 01:02:28,150 --> 01:02:29,590 very big numbers. 1040 01:02:29,590 --> 01:02:31,170 But given the perverse nature here, 1041 01:02:31,170 --> 01:02:33,830 when you saw the big number, you got rid of it, 1042 01:02:33,830 --> 01:02:37,780 and when you saw the small number, you kept it. 1043 01:02:37,780 --> 01:02:39,820 So you sort of did reverse psychology 1044 01:02:39,820 --> 01:02:43,900 and it worked out, by chance, that it worked out that. 1045 01:02:43,900 --> 01:02:47,047 Normally it would go the other way, I think. 1046 01:02:47,047 --> 01:02:48,880 Of course, you've all seen enough games now, 1047 01:02:48,880 --> 01:02:53,800 you know to do the non-standard thing, I think. 1048 01:02:53,800 --> 01:02:56,409 Now, this kind of thinking comes up all the time 1049 01:02:56,409 --> 01:02:57,700 in computer science algorithms. 1050 01:02:57,700 --> 01:02:59,550 You know, the protocol that's used 1051 01:02:59,550 --> 01:03:02,720 to communicate across a network, ethernet, 1052 01:03:02,720 --> 01:03:05,750 shared bus is randomized. 1053 01:03:05,750 --> 01:03:09,060 Each entity that wants to use the bus flips a random number, 1054 01:03:09,060 --> 01:03:10,040 flips a random coin. 1055 01:03:10,040 --> 01:03:11,430 You could think of it that way. 1056 01:03:11,430 --> 01:03:14,270 And it broadcasts with that probability. 1057 01:03:14,270 --> 01:03:16,150 And if there's a collision, it backs off 1058 01:03:16,150 --> 01:03:18,530 and chooses a smaller probability next time. 1059 01:03:18,530 --> 01:03:21,400 And if it gets through, then it tries to cram a bunch of stuff 1060 01:03:21,400 --> 01:03:24,060 through, until you get a collision again. 1061 01:03:24,060 --> 01:03:26,680 The best algorithms for sorting a list of numbers 1062 01:03:26,680 --> 01:03:29,780 are randomized, quick sort, which you'll see in 6046, 1063 01:03:29,780 --> 01:03:31,800 is a randomized algorithm. 1064 01:03:31,800 --> 01:03:33,170 In fact, it's not dissimilar. 1065 01:03:33,170 --> 01:03:37,017 You guess a random value and split all the numbers 1066 01:03:37,017 --> 01:03:38,100 based on the random value. 1067 01:03:38,100 --> 01:03:41,030 Who's bigger, who's smaller, and then you [INAUDIBLE]. 1068 01:03:41,030 --> 01:03:44,670 You do things like that. 1069 01:03:44,670 --> 01:03:49,900 OK, that's all I'm going to say about uniform distributions. 1070 01:03:49,900 --> 01:03:54,400 Next I want to talk about the binomial distribution. 1071 01:03:54,400 --> 01:03:59,300 And this is the most important distribution 1072 01:03:59,300 --> 01:04:02,510 in computer science, and probably the most important 1073 01:04:02,510 --> 01:04:07,730 in all of discrete calculations in the sciences. 1074 01:04:07,730 --> 01:04:10,480 In continuous distributions, you get the normal distribution. 1075 01:04:10,480 --> 01:04:16,562 But, for discrete problems, the binomial is the most important. 1076 01:04:16,562 --> 01:04:17,910 And there's two versions. 1077 01:04:17,910 --> 01:04:21,820 There's the unbiased binomial distribution 1078 01:04:21,820 --> 01:04:23,301 and then there's the biased one. 1079 01:04:28,462 --> 01:04:30,170 Now this one's a little more complicated. 1080 01:04:30,170 --> 01:04:34,460 You've got a parameter n again, and the distribution function 1081 01:04:34,460 --> 01:04:37,130 on k, probability of getting k is 1082 01:04:37,130 --> 01:04:42,000 n choose k times 2 to the minus n. 1083 01:04:42,000 --> 01:04:48,560 And n is at least 1, and k is between 0 and n. 1084 01:04:48,560 --> 01:05:01,790 And then for the general binomial distribution, 1085 01:05:01,790 --> 01:05:04,140 we have fn of k, the probability of getting 1086 01:05:04,140 --> 01:05:10,270 k is n choose k times-- actually, it's fnp, 1087 01:05:10,270 --> 01:05:12,500 there's another parameter p here. 1088 01:05:12,500 --> 01:05:17,585 p to the k times 1 minus p to the n minus k power. 1089 01:05:17,585 --> 01:05:20,640 And p is a value between 0 to 1 typically. 1090 01:05:20,640 --> 01:05:23,330 It's a probability of something happening. 1091 01:05:23,330 --> 01:05:26,560 So in the general case, you've got nnp. 1092 01:05:26,560 --> 01:05:30,750 The unbiased case corresponds to when p is 1/2. 1093 01:05:30,750 --> 01:05:35,200 Because if p is 1/2, you get 2 to the minus k and 2 the minus 1094 01:05:35,200 --> 01:05:38,600 n minus k, and that's just 2 to the minus n. 1095 01:05:38,600 --> 01:05:40,990 So you can think of this as the case when p is 1/2. 1096 01:05:46,330 --> 01:05:50,100 All right, to give you an example why 1097 01:05:50,100 --> 01:05:54,230 this is so important, why it comes up all the time. 1098 01:05:54,230 --> 01:05:59,030 Imagine that you've got a system with n components. 1099 01:05:59,030 --> 01:06:03,159 And that each component fails with probability p. 1100 01:06:03,159 --> 01:06:05,590 And you want to know the probability of having 1101 01:06:05,590 --> 01:06:07,565 some number of failures. 1102 01:06:15,160 --> 01:06:22,890 So for example, there's n components 1103 01:06:22,890 --> 01:06:32,900 and each fails independently-- in fact, mutually 1104 01:06:32,900 --> 01:06:40,190 independently-- with probability p. 1105 01:06:42,790 --> 01:06:44,620 And p will be between 0 and 1. 1106 01:06:47,450 --> 01:06:51,400 And now we're interested in the number of failures, 1107 01:06:51,400 --> 01:06:54,250 so we'll make R be a random variable that 1108 01:06:54,250 --> 01:06:57,245 tells us the number of failed components. 1109 01:07:02,810 --> 01:07:05,750 And it turns out the answer is simply 1110 01:07:05,750 --> 01:07:09,420 that function, which we'll prove is a theorem. 1111 01:07:09,420 --> 01:07:19,005 The probability that R equals k is simply fnp of k [INAUDIBLE]. 1112 01:07:23,870 --> 01:07:26,310 So the general binomial distribution 1113 01:07:26,310 --> 01:07:29,850 gives you the distribution on the number of failures 1114 01:07:29,850 --> 01:07:32,060 in a system with n components where 1115 01:07:32,060 --> 01:07:34,638 they fail with probability p. 1116 01:07:34,638 --> 01:07:36,120 So let's prove that. 1117 01:07:47,990 --> 01:07:51,920 To do that, we're going to construct our tree again. 1118 01:07:51,920 --> 01:07:55,000 It's a little big because you've got n components. 1119 01:07:55,000 --> 01:07:57,180 But you look at the first component, 1120 01:07:57,180 --> 01:08:00,480 and that can fail or not. 1121 01:08:00,480 --> 01:08:02,430 And it fails a probability p. 1122 01:08:02,430 --> 01:08:05,710 It's OK with probability 1 minus p. 1123 01:08:05,710 --> 01:08:08,132 And you have the second component. 1124 01:08:08,132 --> 01:08:10,740 It can fail or not. 1125 01:08:10,740 --> 01:08:12,390 Again p and 1 minus p. 1126 01:08:20,210 --> 01:08:22,733 And you keep on going until you get to the nth component. 1127 01:08:27,229 --> 01:08:32,850 And that can fail or not, the probability p or 1 minus p, 1128 01:08:32,850 --> 01:08:33,950 in general down here. 1129 01:08:40,140 --> 01:08:42,960 And now we look at all the sample points out here. 1130 01:08:47,120 --> 01:08:54,160 And it's all length and vectors of failure or not. 1131 01:08:54,160 --> 01:08:58,979 So the top sample point here would be n good components. 1132 01:09:01,750 --> 01:09:05,370 All right, the next one would be the first n minus 1 are good, 1133 01:09:05,370 --> 01:09:08,420 the last one failed. 1134 01:09:08,420 --> 01:09:10,170 All the way down to the very bottom, 1135 01:09:10,170 --> 01:09:11,380 you can have all n fail. 1136 01:09:14,871 --> 01:09:17,370 All right, so how many sample points are there in the sample 1137 01:09:17,370 --> 01:09:23,170 space with n components? 1138 01:09:23,170 --> 01:09:24,830 2 to the n, all right? 1139 01:09:24,830 --> 01:09:26,760 Because you've got n positions. 1140 01:09:26,760 --> 01:09:28,960 There's two choices for each value there. 1141 01:09:32,160 --> 01:09:35,010 Now how many of the sample points 1142 01:09:35,010 --> 01:09:40,109 have exactly k failed components? 1143 01:09:40,109 --> 01:09:43,210 Out of the 2 to the n, how many correspond 1144 01:09:43,210 --> 01:09:44,819 to k of the components fail? 1145 01:09:48,779 --> 01:09:51,820 n choose k-- now this goes back to counting. 1146 01:09:51,820 --> 01:09:55,690 Remember the binomial coefficient. 1147 01:09:55,690 --> 01:10:06,960 So there are n choose k sample points have 1148 01:10:06,960 --> 01:10:08,400 k failed components. 1149 01:10:16,350 --> 01:10:18,770 All right, what's the probability of a sample 1150 01:10:18,770 --> 01:10:21,560 point with k failed components? 1151 01:10:24,184 --> 01:10:30,950 Well, I took k branches with a failure. 1152 01:10:30,950 --> 01:10:36,480 Each of those gives me a p, p to the k. 1153 01:10:36,480 --> 01:10:40,900 And I took n minus k branches with no failure. 1154 01:10:40,900 --> 01:10:43,340 Each one of those multiplies by a 1 minus p. 1155 01:10:46,370 --> 01:10:50,080 So no matter how I got my k failures, 1156 01:10:50,080 --> 01:10:54,000 the probability for a particular sample point with k failures 1157 01:10:54,000 --> 01:10:58,170 is just that, because I had p get factored in k times, 1158 01:10:58,170 --> 01:11:00,900 in the failures, 1 minus p get factored 1159 01:11:00,900 --> 01:11:03,381 in n minus k times for the situations 1160 01:11:03,381 --> 01:11:04,630 where it worked out all right. 1161 01:11:07,970 --> 01:11:10,980 So I've got this many sample points. 1162 01:11:10,980 --> 01:11:22,870 Each of them has probability p to the k times 1 1163 01:11:22,870 --> 01:11:25,300 minus p n minus k. 1164 01:11:28,230 --> 01:11:30,420 Any questions about that, why that's the case? 1165 01:11:33,692 --> 01:11:35,650 All right, so now I can compute the probability 1166 01:11:35,650 --> 01:11:38,730 there are k failures. 1167 01:11:38,730 --> 01:11:43,040 The probability that R equals k is simply n 1168 01:11:43,040 --> 01:11:47,870 choose k, number of sample points times their probability, 1169 01:11:47,870 --> 01:11:51,920 since they're all the same for k failures. 1170 01:11:51,920 --> 01:11:55,830 And that, of course, is just the formula 1171 01:11:55,830 --> 01:11:59,290 for the general binomial distribution. 1172 01:11:59,290 --> 01:12:06,146 So that equals fnp of k, which is what we are trying to prove. 1173 01:12:11,570 --> 01:12:14,050 OK. 1174 01:12:14,050 --> 01:12:16,840 Any questions about that? 1175 01:12:16,840 --> 01:12:18,980 So that's why it's important, because there's 1176 01:12:18,980 --> 01:12:22,100 a lot of situations where you're interested in the number 1177 01:12:22,100 --> 01:12:24,330 of-- if you had n possible things, 1178 01:12:24,330 --> 01:12:26,590 what's the chance k of them happen? 1179 01:12:26,590 --> 01:12:30,630 And it's just given by this formula. 1180 01:12:30,630 --> 01:12:36,850 Now you can calculate this, but, if I just told you, 1181 01:12:36,850 --> 01:12:45,310 for example, maybe I'm looking at n is 100 and even p is 1/2, 1182 01:12:45,310 --> 01:12:47,490 you know, what's the probability that we'd 1183 01:12:47,490 --> 01:12:51,690 get 25-- say, what's the probably if getting 1184 01:12:51,690 --> 01:12:54,140 50 failed components? 1185 01:12:54,140 --> 01:12:58,480 Or if I flip 100 coins and they're fair. 1186 01:12:58,480 --> 01:13:00,730 So probability half of getting a heads. 1187 01:13:00,730 --> 01:13:05,680 What's the chance I actually get 50 heads in 100 coins? 1188 01:13:05,680 --> 01:13:10,950 Looking at that, it's not so clear what the answer is. 1189 01:13:10,950 --> 01:13:14,570 In fact, let's test intuition here, for this. 1190 01:13:14,570 --> 01:13:16,140 We're going to take a little vote 1191 01:13:16,140 --> 01:13:19,720 to see how good you are looking at that formula, 1192 01:13:19,720 --> 01:13:23,420 or what your intuition is about the probability of getting 1193 01:13:23,420 --> 01:13:24,695 exactly 50 heads. 1194 01:13:29,240 --> 01:13:34,534 It could be between 1 and 1/2, a half and a tenth, 1195 01:13:34,534 --> 01:13:40,030 a tenth and a hundredth, a hundredth and one thousandth, 1196 01:13:40,030 --> 01:13:44,259 a thousandth and a millionth, and 0. 1197 01:13:44,259 --> 01:13:46,050 I want to know what's the probability, when 1198 01:13:46,050 --> 01:13:48,810 you flip 100 mutually independent coins, 1199 01:13:48,810 --> 01:13:52,370 you get exactly 50 heads? 1200 01:13:52,370 --> 01:13:54,870 How many people think it's at least a half, 1201 01:13:54,870 --> 01:13:57,900 that you get half heads? 1202 01:13:57,900 --> 01:13:58,920 Nobody likes that. 1203 01:13:58,920 --> 01:14:02,640 How many people think it's between a half and a tenth? 1204 01:14:02,640 --> 01:14:03,890 One vote. 1205 01:14:03,890 --> 01:14:06,280 A tenth and a hundredth? 1206 01:14:06,280 --> 01:14:06,780 More. 1207 01:14:08,939 --> 01:14:10,730 Doesn't it have to be at least a hundredth? 1208 01:14:10,730 --> 01:14:12,354 That's sort of the most likely outcome. 1209 01:14:12,354 --> 01:14:16,600 There's only-- how many think a hundredth and a thousandth? 1210 01:14:16,600 --> 01:14:17,350 All right. 1211 01:14:17,350 --> 01:14:19,840 A thousandth and a millionth? 1212 01:14:19,840 --> 01:14:22,040 Whoa, so you've got to believe it is not 1213 01:14:22,040 --> 01:14:25,560 likely to get exactly 50 heads when I flip 100 coins. 1214 01:14:25,560 --> 01:14:28,690 All right, well the answer is actually 1215 01:14:28,690 --> 01:14:30,660 between a tenth and a hundredth here. 1216 01:14:33,730 --> 01:14:34,910 It's about 8%. 1217 01:14:34,910 --> 01:14:36,570 And we're going to compute that. 1218 01:14:36,570 --> 01:14:38,330 But here's another one. 1219 01:14:38,330 --> 01:14:40,370 I flip 100 coins. 1220 01:14:40,370 --> 01:14:46,520 What's the probability of getting at most 25 heads? 1221 01:14:46,520 --> 01:14:48,605 So here, doesn't have to be exactly 25. 1222 01:14:48,605 --> 01:14:53,400 It could be 25, 24, 23, 22, all the way down to no heads. 1223 01:14:53,400 --> 01:14:55,560 So a lot of chances, all right? 1224 01:14:55,560 --> 01:14:57,630 To get at most 25 heads. 1225 01:14:57,630 --> 01:15:00,200 How many people think it's here? 1226 01:15:00,200 --> 01:15:02,770 Some, yeah, you've got a lot of chances. 1227 01:15:02,770 --> 01:15:04,885 How about here? 1228 01:15:04,885 --> 01:15:06,230 Yeah, OK. 1229 01:15:06,230 --> 01:15:09,858 What about between a tenth and a hundredth? 1230 01:15:09,858 --> 01:15:12,940 One person, two people left. 1231 01:15:12,940 --> 01:15:15,930 Between a hundredth and a thousandth? 1232 01:15:15,930 --> 01:15:16,620 Nobody left? 1233 01:15:16,620 --> 01:15:18,050 Anybody here? 1234 01:15:18,050 --> 01:15:20,630 Thousandth and a millionth? 1235 01:15:20,630 --> 01:15:22,340 One person is left, less than a million. 1236 01:15:22,340 --> 01:15:24,630 1 in a million? 1237 01:15:24,630 --> 01:15:25,880 There's the contrarian. 1238 01:15:25,880 --> 01:15:31,310 And you're right, the chance of getting 25 or less heads 1239 01:15:31,310 --> 01:15:34,330 is less than 1 in a million. 1240 01:15:34,330 --> 01:15:39,020 So if somebody does it, his name better be Persi Diaconis. 1241 01:15:39,020 --> 01:15:42,710 To get it consistently to 70, [INAUDIBLE] 25 or fewer heads. 1242 01:15:42,710 --> 01:15:48,160 You get 75 tails or more is extremely unlikely, all right? 1243 01:15:48,160 --> 01:15:50,660 So to see why that's the case, we've 1244 01:15:50,660 --> 01:15:53,900 got to do a little work on this formula. 1245 01:15:53,900 --> 01:15:57,820 Because we're saying that if we sum this up for k ending 100 1246 01:15:57,820 --> 01:16:01,470 and k being 0 to 25, and p being a half, 1247 01:16:01,470 --> 01:16:04,600 it's an incredibly tiny number. 1248 01:16:04,600 --> 01:16:05,922 So let's see why that is. 1249 01:16:05,922 --> 01:16:07,380 And this phenomenon is course going 1250 01:16:07,380 --> 01:16:09,690 to be important in computer science 1251 01:16:09,690 --> 01:16:12,290 because it's going to enable you to tell almost exactly how 1252 01:16:12,290 --> 01:16:15,120 many components are going to fail in a system, 1253 01:16:15,120 --> 01:16:16,617 if they're mutually independent. 1254 01:16:30,624 --> 01:16:33,040 All right, now I'm not going to drag you through the math. 1255 01:16:33,040 --> 01:16:36,760 It's bad enough I'm going to write it on the board. 1256 01:16:36,760 --> 01:16:40,320 There's a bunch of this in the text. 1257 01:16:40,320 --> 01:16:43,560 And instead of k, I'm going to represent by a parameter alpha 1258 01:16:43,560 --> 01:16:46,452 times n to be the integer k. 1259 01:16:46,452 --> 01:16:50,330 All right, this will replace k with a new parameter alpha. 1260 01:16:50,330 --> 01:16:54,190 It's at most, and also it's asymptotically equivalent 1261 01:16:54,190 --> 01:16:58,390 using tilde-- both of those are true-- to this nasty looking 1262 01:16:58,390 --> 01:17:08,900 expression, 2 to the alpha log p over alpha 1263 01:17:08,900 --> 01:17:18,740 plus 1 minus alpha log 1 minus p over 1 minus alpha times 1264 01:17:18,740 --> 01:17:26,000 and n-- that's a big number, it's 100-- over square root 2 1265 01:17:26,000 --> 01:17:31,840 pi alpha 1 minus alpha n. 1266 01:17:31,840 --> 01:17:33,875 And this, of course, alpha is between 0 and 1. 1267 01:17:37,790 --> 01:17:39,970 Now when you do the derivative on this thing, 1268 01:17:39,970 --> 01:17:42,840 it turns out its maximum value is when alpha equals p. 1269 01:17:51,320 --> 01:17:57,580 And when you have alpha equals p, you get log of 1 is 0, 1270 01:17:57,580 --> 01:17:58,640 log of 1 is 0. 1271 01:17:58,640 --> 01:18:03,090 All this messy stuff goes away and we just get that. 1272 01:18:03,090 --> 01:18:10,520 And so in that case, fnp of pn is at most, and also 1273 01:18:10,520 --> 01:18:19,130 asymptotically equal to 1 over square root 2 pi p 1 minus p n. 1274 01:18:21,650 --> 01:18:23,860 And now you can plug in values and compute things. 1275 01:18:23,860 --> 01:18:26,880 For example, if I flip 100 coins, 1276 01:18:26,880 --> 01:18:29,720 and I want to know the probability of getting 50-- 1277 01:18:29,720 --> 01:18:32,240 that means alpha's a half, and they're fair, 1278 01:18:32,240 --> 01:18:38,080 which means p is a half, the answer is 8%. 1279 01:18:38,080 --> 01:18:42,240 So n equals 100 coins, p is a half, then 1280 01:18:42,240 --> 01:18:44,730 the probability of 50 heads. 1281 01:18:49,370 --> 01:18:55,840 I just plug in p is a half here, I get 1 over square root 50 pi, 1282 01:18:55,840 --> 01:19:00,670 which equals 0.080 and so forth. 1283 01:19:00,670 --> 01:19:05,905 So there's an 8% chance of getting exactly 50 heads. 1284 01:19:05,905 --> 01:19:07,280 Now let's look at the probability 1285 01:19:07,280 --> 01:19:10,670 of getting 25 or fewer. 1286 01:19:10,670 --> 01:19:13,548 And we'll see why that is so surprisingly small. 1287 01:19:30,170 --> 01:19:38,160 OK, so for n equal 100 and p equal 1288 01:19:38,160 --> 01:19:42,630 a half an alpha equal a quarter, because we want 25 heads, 1289 01:19:42,630 --> 01:19:46,110 I'll get exactly 25 heads first. 1290 01:19:46,110 --> 01:19:52,460 Probability of 25 heads is at most, 1291 01:19:52,460 --> 01:19:57,900 well that square root thing comes out to about 0.09. 1292 01:19:57,900 --> 01:20:00,230 Then I get 2 to something. 1293 01:20:00,230 --> 01:20:09,380 I get 2 to the minus, all those logs come out the 0.1887 times 1294 01:20:09,380 --> 01:20:12,920 n, which is the kicker, that's 100. 1295 01:20:12,920 --> 01:20:16,730 So I get a 2 to the minus 18th here. 1296 01:20:16,730 --> 01:20:21,080 And that makes this thing be smaller than 1297 01:20:21,080 --> 01:20:26,230 or equal about to 1.913 times 10 to the minus 7. 1298 01:20:26,230 --> 01:20:29,960 So about 1 in 5 million. 1299 01:20:29,960 --> 01:20:32,760 The reason this gets so small is because you 1300 01:20:32,760 --> 01:20:35,872 get the n in that exponent up there. 1301 01:20:35,872 --> 01:20:37,330 And of course, this is all computed 1302 01:20:37,330 --> 01:20:39,560 using Stirling's formula, if you actually want 1303 01:20:39,560 --> 01:20:41,370 to go through the calculations. 1304 01:20:41,370 --> 01:20:46,190 You go start with n choose k, which is your n factorial, 1305 01:20:46,190 --> 01:20:48,980 times over k factorial n minus k factorial. 1306 01:20:48,980 --> 01:20:52,280 Plug in Stirling's formula and you do a bunch of messy stuff, 1307 01:20:52,280 --> 01:20:54,840 and these things pop out. 1308 01:20:54,840 --> 01:20:57,720 And so it gets exponentially small, exponentially fast. 1309 01:20:57,720 --> 01:21:00,270 In fact, if you were to plot this thing, 1310 01:21:00,270 --> 01:21:03,510 if you plot the binomial distribution function, 1311 01:21:03,510 --> 01:21:06,520 it looks something like this. 1312 01:21:17,330 --> 01:21:21,380 All right, so I have 0 to n, and then I 1313 01:21:21,380 --> 01:21:24,957 have pn, which is the maximum. 1314 01:21:24,957 --> 01:21:25,915 Here's the probability. 1315 01:21:25,915 --> 01:21:28,560 It goes 0 to 1. 1316 01:21:28,560 --> 01:21:33,310 And your maximum value is here at 8% in the case of 100 coins, 1317 01:21:33,310 --> 01:21:39,980 and it just zooms down exponential small. 1318 01:21:39,980 --> 01:21:43,110 You can't even draw because it gets so small so fast. 1319 01:21:43,110 --> 01:21:50,840 This height here is about 1 over root n. 1320 01:21:50,840 --> 01:21:55,920 And this width here of the hump, is about root n. 1321 01:21:55,920 --> 01:22:01,470 And these things zoom down to 0, exponentially fast. 1322 01:22:01,470 --> 01:22:04,220 And so that's what the binomial distribution looks like. 1323 01:22:04,220 --> 01:22:12,110 And so it says that you are very likely to be very close to pn 1324 01:22:12,110 --> 01:22:15,494 heads, or pn things happening. 1325 01:22:15,494 --> 01:22:17,660 And I won't go through the math now-- probably do it 1326 01:22:17,660 --> 01:22:20,300 in recitation tomorrow-- of computing 1327 01:22:20,300 --> 01:22:23,770 at most 25 heads, which is the cumulative distribution 1328 01:22:23,770 --> 01:22:25,222 function. 1329 01:22:25,222 --> 01:22:26,930 And this comes up in all sorts of places. 1330 01:22:26,930 --> 01:22:29,920 Like you have a noisy communications channel, 1331 01:22:29,920 --> 01:22:33,620 and every bit as dropped with 1% chance. 1332 01:22:33,620 --> 01:22:35,340 If you have 10,000 bits, you'd like 1333 01:22:35,340 --> 01:22:40,000 to know, what's the probability I lost 2% of them 1334 01:22:40,000 --> 01:22:42,990 when I have 1% failure rate? 1335 01:22:42,990 --> 01:22:46,050 The chance of losing 2% out of 10,000 1336 01:22:46,050 --> 01:22:49,500 is like 2 to the minus 60 if they're mutually independent. 1337 01:22:49,500 --> 01:22:52,001 So no chance of losing 2%. 1338 01:22:52,001 --> 01:22:52,876 All right, very good. 1339 01:22:52,876 --> 01:22:55,730 We'll do more this in recitation tomorrow.