Probability and Uncertainty in AI
Transcript
PROFESSOR: OK. All right, let's get started. How is everybody? STUDENT: Great. PROFESSOR: I'm glad. Today, we're going to talk about probability. Probability is going to be the basis for how we model and compute under uncertainty and artificial intelligence. So if we take a step back-- if we take a step back and think about what we've done so far in this class-- we've thought a lot-- mostly-- there have been some exceptions [INAUDIBLE] there were probabilities. In reinforcement learning, there was some learning. But mostly, what we've done in this class is we've thought about symbolic ways things can chain together and how to do reasoning using computation along those kinds of models. What we're going to start to talk about today is something we've mostly ignored
to date, which is uncertainty. There's a lot of things that happen in the real world where either you can't or you don't want to have a fully detailed model that explains every last thing to the point where what's left is deterministic. Often, your model is incomplete or incompletable. And that shows up as uncertainty about what's going to happen. Things can be out of your control, or they can simply be things that you can't compute. So this middle part of the course, we're going to talk about probabilistic reasoning, which is our main formal mechanism for talking about and reasoning about uncertainty. And then, in the last, part of the course, we're going to talk about machine learning, which is-- you can think about that as how we learn the parameters that go into the probabilistic models or models in general that we'll be talking about now. So probabilistic reasoning is used for a lot of things. If you remember back, the brief history of AI,
the first-- kind of in the first decades of AI, we tried to write down lots of rules and chain them together. And that gave rise to interesting kinds of computations, particularly for things like games that actually do work according to those kinds of logical rules. But then that didn't scale because of uncertainty, and we needed methods to cope with that uncertainty. That's what we're going to talk about now with probabilistic reasoning. And a lot of the recent advances in, say, the past decade in artificial intelligence have to do not just with reasoning about uncertainty, but about learning about how the world works through data, through experience. And that will be the last part of the course. So today, in some sense, is going to be a preview of all the things we're going to be seeing and working with and all of the techniques and ideas for the next several lectures. So on one hand, we're going to see all kinds of stuff today. On the other hand, pieces of it are
going to seem familiar because you've all seen some kinds of probability or statistics in other courses. And we're going to lay all that out today. So in some ways, today is going to be the most sweeping lecture. And in other ways, it's going to be the most nitty gritty kind of computational low-level lecture there is in this class. And so please keep in mind that the stuff we're going to use today-- that we're going to see today, we're going to use over and over again. So the goal for today is to really know all the stuff we talk about today cold so that when you see these things you just intuitively get what they are. And so this is something that it's worth making sure that by next lecture, anything that's new today, you've really sort of gotten a chance to wrestle with it and internalize it. You're going to see this stuff a lot for the next few weeks. We're going to talk about random variables, which is our key method of modeling uncertain outcomes.
We're going to talk about joint and marginal distributions. We're going to talk about how to compute conditional distributions, which are the quantities we actually care about-- uncertain values given evidence. And we're going to talk about a lot of the mechanics that form the basis of the graphical model infrastructure that we'll use over the next few lectures, both for models that don't have time, and models that do, for which you will have hidden Markov models later. All right. So here we go. We'll begin with Ghostbusters. So I'm going to show you a demo. This is like CS 188 Ghostbusters. The probability is sound. The spectral theory is totally made up. OK. Let's see. We're going to play Ghostbusters as a class. And this is going to illustrate both what's involved in accumulating and managing evidence and uncertainty, and also how frustrating it is to not have something to help us compute posterior probabilities of variables we care about given evidence.
So the way this game works is, on this board somewhere, there is a ghost. OK. You'll see later versions of this in your projects for which there can be more ghosts. But, for now, there's one ghost on this board, and it's somewhere. Our job is to figure out where it is. We get one shot. We click bust, and we're either right or wrong, and we get an appropriate utility. We can also take sensing actions. So we can drop a little probe, and it will tell us about the density of spectral ammunitions or something like that. And we get a color back. What does the color mean? The color is going to be red. That means we're right on top of a ghost here, all the way down to green, meaning ghosts seem to be distant. But there's going to be noise. Before I do anything, I want to show you the noise model. The noise here is given by a bunch of probabilities. You can see on the bottom, of color given distance. So, for example, if the ghost is three away,
the probability that you get a red is 0.5. So everything is uncertain. And sometimes you're right on top of the ghost and you get a green, and sometimes it's clear across the board and you get a red. And that's super frustrating. So let's play. All right. I will sense here. All right. Ghost is sort of nearby. I'll sense here. You can see my score is dropping because it costs 1 point every time I sense. I'm going to sense here. OK. Maybe we're getting close. Let's dig around here. All right. All right. OK. Is it there? Is it there? Well, who knows, right? Maybe.
All right. Apparently-- you know what? I bet uncertainty is off. No. There we go. All right. So we got a bunch of sensor readings here. And at some point-- OK, there's this trade, right? At what point should I stop paying for sensing moves and just bust? That's a value of information computation. It's a super cool concept, and we're not going to do it today. Today, we're just going to stop. OK. So I've decided to stop. I'm going to bust. What should I do? Well, where do you think I should bust?
CS 180, a guided search here. Should I bust here? No. How about here? No. I'm just trolling now. How about here? Yeah OK. Let's do it. Ready? We got him. OK. Good. All right. So that is Ghostbusters. And we got 228 points because we got him, but we sensed a whole bunch of times. All right. So let's look at that one more time. I just can't get enough. OK. All right, let's look at this one more time. Right now, if I asked you, hey, where's that ghost, what would you say? Well, first of all, you don't know. You can't know. You don't have the-- you don't have enough evidence to know. So you would say something like, I don't know where that ghost is. It's somewhere. Each location might be equally likely if that's how the game is set up. OK. So your prior distribution here says uniform probability. But then once I start getting some sensings, some sensor readings here-- at this point, where do you think the ghost is? You know, maybe it is more likely to be
kind of left or kind of top. That sort of heat map in your mind, how likely each square is given the evidence you have, that's the posterior distribution. That's what we'd like to be able to compute on the basis of the evidence. We don't have the tools to do it yet. We'll get a lot of those tools today and even more of them in the next couple of classes so that we can say precisely, exactly what probability is in each square. And then, if I get enough of them, maybe-- OK, I still have no idea. All right. So I'm going to bust. I'm going to go for it. Miss. Close. OK. There we go. You don't always win at Ghostbusters. All right. So that's the basic idea. That's going be a running example through a lot of this-- is that there is some quantity you don't know. In this case, that quantity is the position of the ghosts. And that will be represented by a random variable in your model. There are other quantities, like the results from the sensor probes, which you do know. In addition, you know how the things that you know
are connected up probabilistically to the things you're curious about. And then you do some computation in order to compute the probabilities you want. That's what probabilistic inference is about, and we're going to lay the groundwork for that now. So here's a general situation. You're going to have a model. What is a model here? A model is going to be a collection of variables. These are going to be random variables, because sometimes you know their value, but sometimes you don't. When you know the value of a random variable, that's evidence right? It's not uncertain anymore. So there's going to be the observed variables. And you're going to know certain things about the state of your world. Here, that's sensor readings. But if we were doing medical diagnosis, the random variables that you observed as evidence might be symptoms or lab tests or something like that. There are going to the unobserved variables. And these are all the things you don't
know the value of-- for example, in this case, where the ghost is. But there are other items or variables like what reading you would get at a different location. In a medical diagnosis case, there might the unobserved variables like other tests you didn't perform but still could. So there's the evidence. There's the query variables that you actually really care about right now. And then there are going to be other variables that may also be unobserved. And you need to figure out how to work with them as you do your probabilistic reasoning. And then, finally, you've got this model. And what the model is here-- that's a word we use a lot in AI. And what the model means here is it's a description about how the known variables relate to the unknown ones. Today, that's going to take the form of a giant joint distribution, which is a big look-up table of probabilities. And as we go further into this unit, we'll get more and more sophisticated
ways of specifying compact models that let us do very complicated and powerful queries. Problematic reasoning is going to be a framework for managing our beliefs and knowledge. That means taking all those relationships you know about between the variables, taking the evidence you have, and then doing computations to produce quantities that you can use to make decisions. For example, the decision of where is the ghost most likely to be, or what is the expected utility of doing a sensing action at a certain location. Those are going to be things that we need to know probabilities conditioned on our evidence in order to do well-founded decisions. All right. Any questions before we start? Because we're about to do a tour of probability and probabilistic concepts that's going to serve you well for the rest of this course. Yep? STUDENT: Will we also consider uncertainty on sensors and stuff like that? PROFESSOR: Are we also going to consider uncertainty over sensors and things like that?
So in the formulation here, that uncertainty will show up in the random variables that represent those sensors. So if I had a deterministic ghost sensor, the probability of green, given the ghost is 6 squares away would be, maybe, 1. It would be deterministic. Probability 1 means deterministic. A noisy sensor might say, well, at that distance, you're 90% likely to get a green but 3% likely to get an orange. That's noise in the sensor. Now, a lot of sensors are real valued kinds of things. Like, I take a laser measurement or something, and I get a distance back, and it might be slightly off. So the format of the noise in a sensor is going to vary based on what kind of distribution . And that's something we'll talk a little bit more as we go. Yes? STUDENT: [INAUDIBLE] PROFESSOR: Will this week's material be on the exam? I think so. We'll see. We'll tell you clearly where it's stopping. The exam doesn't exist yet. [LAUGHTER] OK.
All right. Starting with probability and probabilistic concepts. First concept, random variables. These are actually a lot like something from CSPs, which were variables. A random variable is an aspect of the world which you care enough about to put in your model. You give it a name. Like, for example, the variable R might represent whether or not it's raining. T-- in this running example, we're going to have a-- that might be whether it's hot or cold. D might be how long it takes to drive to work. L might be where's the ghost. And so we're going to put variables in our model. And these are things either that we can observe, or that we might want to infer about, or other variables that help us write down how the world works in a probabilistic way. We write these down with capital letters. They're just like variables in the CSP in the sense that they have domains. So, for example, R-- is it raining-- might have the domain True or False.
All right. You guys have been seeing true and false forever, but there's an important shorthand we have in Cs 188, which is that, when possible, when names aren't ambiguous, we have a shorthand where we write something like R equals true. Instead of writing, R equals true, which takes a lot of space-- and I can't spell-- instead of writing, R equals true, we're just going to write plus R. OK. So plus means true. Minus means false. And the lower case r means the variable we're talking about here is the capitol version of that letter, so capital R. So you can think of this as true and false with typing so that we can write things more compactly and more clearly. So we might have a variable like T, hot or cold, that takes on values hot and cold. Now, it's binary but not Boolean.
We might have variables that are continuous values. So something like, how long will it take to drive to work, could be real value that could be a time. You could have things that are discrete valued but not binary, maybe even structured in their value. So whereas the ghost might be some enumeration of positions on the board, 0-1, 0-2, and so on, x-y positions. OK. So we can give these variables big domain, small domains, continuous discrete. In this class, we will almost always be talking about discrete domain variables. All these same concepts we talk about work in the continuous case, but the mechanics are more complicated. So all your sums turn into integrals, and you've got to think a lot more about some kind of corner cases where things get degenerate. OK. So it's just like CSPs. We've got variables that talk about the important properties in the model. And they have values in a domain. What's new is we now have probabilities that are associated with the values.
So, for example, for temperature here, we might be hot or cold. We might have a probability distribution over that random variable. And here, the probability distribution assigns a number to each outcome. And those numbers have certain properties like they're positive, they sum to 1. OK. So here, 50-50, that's a uniform probability over the outcomes hot and cold. Here is weather, right? This is not-- it's still discrete, but it's not binary anymore. So this one says sun has probability 0.6. Rain has probably 0.1. Fog has probability 0.3. And there is an outcome meteor that has probability 0. OK. To give you a sense of what a probability distribution over four values looks like, there is actually a-- this is a well-formed probability distribution, but it's actually a big no-no to put 0s in your probability distribution. So I probably wouldn't do this if I was building a real robot weather crisis model or something. I would probably replace that with something
like some appropriate small number. Because once you put a 0 in your probabilities, all kinds of weird stuff can happen. And what you generally want to say is, well, that's very unlikely, but should evidence come in to my observations that is consistent with that outcome and not with the others, I eventually want to conclude it anyway. So you only put 0 in for things that can never, never, never, never, under any kind of evidence, happen. For the slides, it's nice to have 0s. But that's a big no-no in real models. All right. So unobserved random variables have distributions. So they look like this. A distribution is a table of these values. So when we talk about a distribution, that's a table. When I write a distribution, I like to write something like P of capital W. When I see a capital, that means-- it's like an array. I have a value for every value in the domain of that random variable. When I write something like P of W equals rain, that's not an array anymore.
That's now a single scalar value. So a probability is a single number. So, in this case, P of W is this whole table. P of W equals rain is this one entry in that table and therefore is associated with a scalar rather than a table, or vector, or matrix, or whatever of numbers. All right. The properties, in order to be a legal licensed probability distribution, all the entries have to be positive, and they have to sum to 1. 0 is allowed but usually a bad idea in practice.
And we'll talk about why later. All right-- oops-- let's erase this first. We have a shorthand notation-- don't let it confuse you-- which is that we often drop the variable equals when it's unambiguous. So of T is the only thing that can be hot, we'll sometimes write something like P of hot or P of cold if T is the only thing that can be cold. But if there are multiple variables that can be hot or cold or true or false, we have to write the variable names as well. That's why we have that other notation before where we might write P of plus R to indicate variable R has the value true. This only works if domain entries are unique, which we'll try to do for examples. All right. Joint distributions-- joint distributions are the heart of probabilistic models. They have all the information about the domain, about all the variables, about all the interactions between the variables. But they're very big. So we avoid actually computing them in their full glory
whenever we can. They're sort of like search spaces. They're too big to actually write down. But if you use them in the right way, you can sort of do anything you need to in a probabilistic mode. So a joint distribution over a set of random variables-- it could be 1, or it could be 2, or could be N-- specifies a real number-- the probability-- for every assignment. And assignment is just like it was in CSPs. It is an outcome for each value assigned to each variable. So we might write this as the long way, variable X1 has value lowercase x1. Variable X2 has value lowercase x2. But much more often, we use the shorthand. So this probability over these N variables is one number. If I put capital letters there, it's a big N dimensional array that has a number for each outcome. So here is the joint probability over the variable T for temperature-- which is binary here in this model-- and W for weather, which is also binary.
And so their joint probability has the outcomes hot sun, hot rain, cold sun, cold rain. This should feel like a truth table. It's the same thing, except now there's a probability assigned for each of those. From this, I can now answer any question you want about temperature and whether in this model. I can answer questions like, how often is it sunny? Well, it's hot and sunny 0.4 of the time, and it's cold and sunny 0.2 of the time. So how often is it sunny? 0.6. I can go to this table and compute any derived quantity I want. This joint distribution has to obey some rules, but they're pretty lax. The rules are just positive numbers and sum to 1. The actual numbers in which numbers are bigger than others specify what's likely, what correlations exist between the variables, what the probabilistic dependencies are, and will become much more important when we start breaking these tables up into graphical models.
Problem with joint distributions-- on one hand, they're your key to answering any question about a domain you can ask-- probability of this given that, and so on-- is their size. So let's say you have variables like up here. And each one has a domain of size D. How big will this table be? Any guesses? STUDENT: ND. PROFESSOR: ND. We have ND as a guess. Anything else? I heard D to the N. Anything else? Well, let's think about it. What does this table do? So I've got each of these variables-- one variable, X1, X2, X3, X4. And for every assignment to that sequence, I get a number. So as that sequence gets one more element-- let's say it gets another true-false element at the end-- how many more numbers do I need? Twice as many, because I have all the values where it's true.
And I have all the values where it's false. So this is going to be exponential. You have one number for each variables assignment. And that means that it's going to be exponential in the number of variables. That's usually your sign that something is going to get very expensive and very bad. So for any real model that has-- real graphical models can easily have thousands of variables. You can never write this joint distribution in the same way that you can never write out the whole search space. But that didn't matter to us back in Search, because we only needed, sort of, the part of the search space we found during our search process. We started at the top, and we were selective about creating and instantiating the search. It's going to work a little differently here, but as we get more tools over the next several lectures, we're going to be very careful to not build the whole joint distribution. We'll only build the corners we need in a, sort of, on-the-fly, in-demand way.
But today, we're going to do the gory, expensive, brute force thing so that we can make sure we understand all the concepts there. So joint distributions get very big very quickly. OK. Probabilistic models-- what is a probabilistic model? Well, it's just a joint distribution. That's it. A probabilistic model is a joint distribution over some random variables. They're going to have random variables which have their domains. The assignments here are called outcomes, and the joint distributions say not whether they're possible like in a CSP, but whether they're likely. So this probabilistic model over temperature whether says that hot and sun together is reasonably common, but hot and rain together isn't very common.
These probability models are normalized. You're going to see this word a lot. Normalized means when you add everything up, you get 1. It's one of the properties you need to be a legal distribution. And ideally, only certain variables directly interact. The thing that's going to be the foundation for our ability to do efficient inference over very big models is that the interactions are-- not every variable connects to every other variable. For today, that won't matter. But that will be very important starting next lecture. This should look a lot like a CSP. So what's the difference between something like a distribution over T and W here with hot and sun and cold and rain versus a CSP over those same variables? They're actually very, very similar. The differences-- a CSP can be thought of as a giant-- specifying a giant truth table. For each assignment to all of the variables, it's either true, meaning it passes the CSP's constraints.
Or it's false, meaning it's illegal according to the constraints. Now, we never wrote CSPs out like this. You would take those 300 countries and their colors, and you would write this giant exponential sized assignment to all of the colors to the map. And then you would write at the end, T or F. We didn't do that. We broke into little pieces that says, these two can't be the same, and these two can't be the same. And we're going do the same thing with probabilistic models. We're going to say the probability of this variable depends on this variable in the following way. But, again, not today. Couple more basic definitions, and then we're going to start to derive interesting computations from these things. Events-- an event is a set of outcomes. Remember, an outcome is a complete assignment to all the variables. OK. So if I say the probability of some event, and there are multiple assignments that match that event, I have to add them up.
In general, when you collapse together probabilities, you talk about the sum of their probabilities, because you don't know the probability of anything in that bundle happening. So from the joint probability, we can calculate the probability of any event, many of which we don't care about. But there is a certain class of events that we're going to care about all the time that we'll get into in a second here. So let's look at the probability that it's hot and sunny. Well, that's this row. So computing that event-- it's a single outcome. I can look it up on the table. But the probability that it's hot is not directly in this table. It has to be derived from this table. So I can take this table, and I can say, well, that row is a case where it's hot. But so is this row. And how do I get the total probability of hot under this model? I add them up. In this case, I would get 0.5. OK. This particular event where one of the columns mattered and the others didn't, this is a marginal.
We'll talk about these in a second. But this is a common kind of event we think about-- is a case where we care about some variables' values but not others. But we can do all kinds of stuff. Like, we could do, instead of hot and sunny. That's a single outcome. Hot. That is a collection of outcomes there that ignore one of the variables. Or we can talk about hot or sunny. That's the top three rows of this table. And if I add up all their probabilities, I get 0.7. OK. So as my events get bigger, their probability is going to grow. OK. Any questions on that?
Almost all the time in this class, the events you care about are partial assignments. So something like T equals hot, or W equal sun, or T is hot, and W equals rain, and not these kind of "or" events, kind of a bunch of arbitrary things, or together. We tend to not actually use those. All right, let's do a quiz. We're not going to do, like, a stop and discuss quiz. We're just going to do a really quick eyeball the thing and give yourself a couple seconds. So what is the probability according to this probabilistic model, which is a joint distribution of X and Y? What's the probability of X and Y both being true, or plus X plus Y? 0.2. We looked it up in the table. All right. What's the probability of plus X?
0.5. You get that by adding up these two rows. Another way I can talk about this is I can say, those two rows are consistent with plus X. We're going to use this term, consistent with probabilities, a lot. And you'll notice we talked about consistency in Search. That had to do with heuristics and a certain kind of triangle inequality. We're talking about consistency in CSPs, and that means something entirely differently. This is going to mean something entirely different here. We talk about consistent with probabilities. We're talking about matching variable values that are known. So the rows here in red are the ones that are consistent with plus X, meaning they match that partial assignment. All right. So I could also talk about the event minus Y or plus X. What would that be? It's also this. That's 0.6. OK great. Marginal distributions-- a marginal distribution is one of the harder names to remember. They're called marginal distributions
because they used to publish certain kinds of distributions that have two variables as a two-dimensional table. And they would sum up for you the rows and the columns. And when you have a two-dimensional table and you sum up all of the rows, those sums would go at the end in the margins. That's where that derives from. So a marginal distribution is a subtable. So if I take a probability-- if I take a joint distribution, it says for every combination of multiple variables what their probability is. A marginal distribution is a smaller table in which some of the variables have been eliminated. When you eliminate variables, rows collapse together. Like if I eliminate W here, hot sun and hot rain collide. They're both P of T equals hot. When things collide, you add them together. That process is called marginalization, or summing out. So for P of T-- I can take P of T. I can derive it from P of T comma S by summing out all values of S for the given value of T
I care about. So if I want probability of T equals hot, I add up probability of hot sun and hot rain. That is this equation. So connect to this equation with that idea that you've already done intuitively. It's summing out the dimension S, which here is the variable W. Of course, there's also another marginal of this table. The strength distribution also has a marginal probability over W, which gives the probability of sun and rain with the temperature marginalized out.
OK. So from the joint distribution, you can derive the marginals. You think it works the other way? It will be a puzzle for next time. It's certainly the case that if I give you the thing on the left, you can derive the thing on the right. But it's actually tricking you to go the other direction. There's a problem with that. We'll talk about that next lecture. OK. All right. Let's do a quiz on this marginal distributions. Here is a marginal distribution over X and Y, which both take on the plus and minus value. That's their joint distribution. So for their joint values, we have the probabilities. I'm going to compute a marginal analysis. So let's compute the part marginal over P of X. Well, it's got entries for every value of X, but ignoring the distinction in Y. So for P of plus X, I look at the consistent rows in the joint distribution, which here the top two. I add them together. This is called summing out for that reason. And what do I get?
I get the 0.5. That was this row and this row are consistent with plus X. I add them together. I get plus 5. Now, I could do minus X. I could do it the same way algorithmically. I could take all of the rows in the joint-- which are consistent, meaning matching-- plus X. That's the bottom two. And I could add them together. And what would I get? 0.5. Or I could do it the sneaky way, and I could just take 1 minus what I've already gotten, because I know they had 1.
All right. With P of Y? Stare at it for a second. Think about it in your head. What's P of Y? 0.6. And P of minus Y? 0.4. OK great. That is creating a marginal distribution from a joint distribution. Now, in this case, the joint distribution had two variables with a two-dimensional object. And I created one-dimensional objects. The joint distribution might have 100 variables, and I create a marginal distribution over just 1 of them. I have do a whole lot of summing things. Or I could create a marginal distribution over 99 of those 100 things.
And the table is still big, but less big. So any subtable, whether it's the smallest, or nearly the entire thing, or even, technically, the whole thing, can be called a marginal distribution. OK. Questions on that? Now, we have the core concept in probabilistic reasoning, which is the computation of conditional probabilities. In and of themselves, conditional probabilities are pretty simple to state. The conditional probability of some event A given some other event B. So, in general, you've got some universe of outcomes. You've got the region here-- you can see on this Venn diagram. What do we know? We know that B has happened. That means we are in this circle here. And what we'd like to know is, how likely is it that A also happens given that B happened? So, graphically, that's how likely is it that we're in this purple part in the middle given that we are in the red. OK. Mathematically, how do we compute that the definition of a conditional probability
is the ratio of the joint probability? A and B divided by the probability of B. And you can think of this as, what proportion of the B outcomes are also A outcomes? OK. That's the definition of conditional probability. So that's one of the rules we're going to have when we start having to compute things is this definition that we can compute-- conditional probabilities, A given B, from joint and marginal probabilities. A comma B, And just B. OK. Let's do some. So here is T and W again.
We can compute things like, what is the probability of sunny given that is cold. Well, we remember the definition first. We can do this the long way first. So first, it will be the probability of sunny and cold divided by the total probability of the conditioning event, which is C, which is cold. And the numerator, P of S comma C is sitting in this table, probability of cold and sun. So that's 0.2. And the denominator is not sitting in this table. But I can derive it.
What's the total probability of cold here? It's 0.5. But notice it's also 0.2 plus 0.3. OK, what does that mean? Notice the numerator is part of the denominator. The denominator consists of cold and sun but also cold and rain. And this is going to be something that's important for some of the algorithms that come up. I'll show you more examples of it as we go. OK. So there is the competition there. OK. Quick quiz on conditional probabilities. Let's do probability of A plus X given plus Y. And for this one, the first thing we'll do is remember the definition. That's the probability of A plus X and plus Y divided by the total probability of A plus Y. So what's the numerator? Plus X and plus Y? It's 0.2. Plus X-- total probability of plus Y is 0.6. And that's going to be 1/3. All right. I'll let you do the next one yourselves. Probability of minus X given plus Y?
All right. Who's got an answer in their head? OK. I'm going to do it. I'm going to do the whole thing. This is probability of minus X and plus Y divided by the total probability of plus Y. Minus X plus Y is this row here. So that's 0.4. The total probability of A plus Y is that row along with that row. Those are the two rows which are consistent with plus Y. And so together, they're 0.6. That means 2/3. And you could have also gotten that sneakily by noticing that this is everything other than the 1/3 we just computed. All right. I'll let you guys do the last one yourselves. OK. So this is the point where you start getting like, yes, I understood all the pieces. But, actually, I'm having to access them all in all kinds of combinations really fast. It is really good to practice this stuff, because it does have to get mechanical. All right. In addition to conditional probabilities, which
so far have been numbers, there are conditional distributions. Like any other distribution, they are a vector of numbers that describe a probability of various outcomes that sum to 1. Except these outcomes are conditioned on an event. OK. So here's a joint distribution. This is that same distribution over the hot and cold variable T and the sun and rain variable W. And we can compute various things. For example, we can compute the probability distribution over W given the evidence T equals hot.
Where did we get this? Well, first of all, what does this mean? Because there's a capital letter here, this will be a distribution over W. And you see a capital letter, you think, at a data structure level, this thing is an array in that dimension. So when I see P of capital W, this is an array over all of the values W can take. So it's going to be an entry for sun and an entry for rain. Each one of them is going to be P of sun given hot and P of rain given hot. OK. Let's compute one of them. Let's compute P of sun given hot. That's equal to P of sun and hot divided by the total probability of hot. And that is P of sun and hot is 0.4. Total probability of hot, 0.5. And you can see that 8 is sitting there in that slot. You can compute the other one as 0.2. But there are other conditional distributions. There's also a distribution over P of W given T equals cold. And there's at least one other thing you could talk about here, which is
the marginal probability of P of W. So let's compute that. P of W, this is a distribution. It has a value. Remember it's a vector for W. It has a value for sun and has a value for rain. And what's the total probability of sun here? 0.6. Total probability of rain, 0.4. And so I can look at this and I can say, all right, before I had any evidence-- if you had said, hey, what's the probability of sun today? I would have said 0.6. But if you tell me it's hot, that belief
that posterior probability condition on the evidence goes up to 0.8. That sort of makes intuitive sense. So maybe this joint model isn't totally crazy. But if I tell you it's cold now, the probability of sun drops from 0.6 to 0.4. So what I'm starting to get is I'm starting to get qualitative changes in variables of interest. Like, hey, what's the weather? That change as a function of the evidence I get. And where that changing probability is a function of the joint model, which specifies sort of everything and the evidence I get. And this is a lot of what we do with probabilistic models, is we build a giant model. And then we ask various questions. How does this evidence and this evidence tell me about this? I've got more evidence. How should my beliefs change? And that updating of beliefs in a well-founded way is a big part of what we're doing here. Any questions about conditional distributions? A conditional distribution is a distribution.
So as a data structure, it looks like P of W. But semantically, it is conditioned on evidence. So it's not the same as the marginal. Let me stop and ask questions before you discover the normalization trick, which will serve you well. OK. So one thing you do a lot in probabilistic reasoning is you compute conditional probabilities. And in particular, you usually want the whole distribution. Like you don't really care how likely is the ghost to be right here. Oh 0.004. I don't know what to do with that. But if you give me the whole distribution, I could do something like take the maximum and bust there. Or I could do a calculation, a utility calculation. Usually you want a conditional distribution
over your query variable but given the specific settings of the evidence that you have. So a lot of your queries look like this. You have some joint distribution that has the variables you care about, and also the other variables, including your evidence. And then you want something like-- I want to know the probability of the various weather outcomes given that I've observed that the temperature is cold. All right. Well, how do we compute that? Well, OK, so we could just-- we could actually compute it. So, first of all, what's the thing going to look like? The thing's going to look like-- it's a distribution over W. So there's going to be sun and then some number, and then rain and then some number. So as a data structure, it's going to be a distribution over W. How am I going to get each entry? Well, we did it before. You kind of compute-- you use the definition of conditional probability. And you say, all right, well, first I
have to compute the top one, probability of sun given cold. What's that? I go back to my definition. Oh, that's the probability of sun and cold in proportion to the total probability of cold. And you say, well, the numerator was easy. It's sitting in the table. And for the denominator, I went and I added some things up. OK. So where is this on the table, sun and cold? It's right there. OK. So what's that total probability of cold? OK. Don't go into simple shock here. Look at what these entries actually are. This is sun and cold in the numerator. And the denominator is that and the other thing-- rain and cold. So then I go to the other entry in the table and I say-- and there the numbers-- I go to the entry on the other end of the table and say, OK, what's the probability entry for rain given cold? Well, I pull up my definition of conditional probability, and I say that's the probability of rain and cold in proportion to the total probability of cold.

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