Motion Planning Optimization
Transcript
- CS 287, Fall, 2019. Sorry to miss you last week. You covered, on Tuesday, contacting variant optimization with Igor, and on Thursday, I believe you covered motion planing with one of the T.A.s, Harry. There was a couple of slides that weren't covered at the end of last lecture. I'm gonna let you study those on your own. Essentially, there's the topic of LQR trees. It's not gonna come in the homework, but it's quite interesting, it's a way to combine motion planning with LQR to have a more efficient motion planner, effectively. Because, motion planning tends to be very local in its sampling base, LQR is not that local, it has a base of attraction. And so, combining both of those into LQR tress is pretty interesting. And then, the other thing he didn't cover was shortcutting. Typically, when you use a sampling-based motion planner,
you will, at the end of a path that's very jagged, shortcutting is the idea that you just check if any of the steps along the way, you can just skip because it's just a little bit of a detour and you can use a straight line instead. Of course, depends on the dynamics of your system. If your system has peculiar dymanics, you cannot just do straight lines, but if your system is able to follow any path, except when there are obstacles, then you can do straight lines, if there's no obstacle. So, that's shortcutting. There's a little more detail on the slides. And, often actually, also run, normally your opposition for control actually at the end to smooth out your path and get a locally optimal path.
So, those are the highlights of what you didn't cover, but we're gonna, not cover in more detail, but the slides have the detail. So, then we'll switch to... Sometimes the second part of the course. First part of the course was all about finding optimal actions. How do we, given a dynamical system, some environment, really, find a sequence of actions or a policy that optimizes expected reward? Now, we're gonna look at the complementary part, which is trying to make sense of our sensory readings, such that we even know what the state of the environment might be and then act against that. And, we'll need a lot more probability here, so we'll start with a bit of probability review. Then, we'll look at base filters, which are gonna be the core of what we'll be doing, and we'll look at base filters today, in the simplest setting, which is just discreet state, discreet observation. And then, we'll look at Gaussians, which will allow us, next lecture, to do it in continuous state's basis,
in many ways similar to how LQR give us local solutions, similarly with Gaussians, even for non-linear systems, we'll be able to find local approximations to the probability distributions. All right, any questions? All right, then let's get started. So, why might we care about probability in robotics?
Well, often the state of the robot and the state of its environment are unknown and only noisy sensors are available. So, we don't have a sensor that just says, "Here is a state," instead you measure something else. Probability provides a framework to fuse that sensory information into a reasonable estimate of what the state might be. And so, the result of what we would compute would be a distribution over possible states that the environment and robot could be in. There's another reason we care about probability, which is something we've already covered a little bit, which is that the dynamics is often stochastic. So, we can't optimize for a particular outcome,
but the only optimize to obtain a good distribution over outcomes. And again, probability provides us a framework to deal with that, we've done that in simple settings so far, but we'll expand that later. And, we'll actually bring both of those together in a future lecture, where we'll look at the notion that the actions you take could be taken to reduce uncertainty about the world. So, actively go seek out sensory information that could help you understand better what the state of the world is, and then collect more reward. Formally, those are called palmny piece, partial-observable, market decision probabilities, and that'll be somewhat the combinations bring together, what we're covering in the next few lectures, and what we're covering in everything so far.
Let's look at an example, a helicopter. What would be the state? Position of the helicopter, orientation, velocity, angular rate? What would be the sensors you have? You don't have direct access to position, orientation, velocity, angular rate, you have access to some of those in a noisy way, and then others you don't have access at all. So, GPS gives you a noisy estimate of position, sometimes also velocity. Typically, only up to a couple meters accuracy. So, not super precise, but it's a noisy estimate of position. Typically, you put the inertial sensing on your robot, so for helicopter, maybe you have a three-axis gyro. So, a gyro is an angular rate sensor, so it gives you three numbers at any given time, measuring the angular velocity around the three main axes of the helicopter,
if you mount it axis-aligned. Then, three-axis accelerometer. Accelerometers measure acceleration, but not exact acceleration. It's a little trickier than that, and it actually measures all zeros in free fall. So, if you're free-falling, an accelerometer measures all zeros, and anything that you do that's not free-falling, for example if you're standing on the ground, your accelerometer will measure 9.81 meters per second squared, opposite to, essentially, gravity, 'cause you're resisting gravity, and that's what it's measuring at that time. So, in some sense, accelerometer is not just... And in fact, much more accelerometer is about measuring orientation, very often, than it is about measuring your actual acceleration. Because, any resistance to gravity, you'll be able to measure, and from that can, in some sense, especially if you're on the ground, understand where gravity's pointing, which gives you a lot of information about your orientation.
Then, three-axis magnetometer, which... Well, what is a magnetometer? It measures the earth magnetic field, so earth magnetic field, you might think of it as North, but it's actually, if you measure it in 3D, it's not really North, it's roughly North, but it actually also points into earth. But, it's known, which direction it points, and so you are measuring in the frame of your sensor, where is the magnetic field pointing, and that gives you information about the orientation of the system that you have. Some tricky things that, of course, if you have something that generates its own magnetic field, like maybe have some magnets on your system, or you have some high currents that induce magnetic fields, then it might perturb those measurements and not really get the earth magnetic field, but something else. Or, you're flying near a power line or something, it might perturb the measurements you're getting.
Dynamics, there is noise from the wind. There's unmodeled dynamics in the engine, in the servo motors, and in the blades of the helicopter. So overall, we don't really have access to a state directly but we have things that relate pretty closely to state, and we should be able to distill from that a likely estimate of the state. Or, a distribution around some mode, maybe, of what the state might be. How about a mobile robot inside a building. The state could be position and heading, if it's, let's say, a slow robot, if it's just slowly moving, you don't care about velocity, just the position and the direction it's facing. Then, sensors, odometry, which is sensing motion of the actuators. For example, wheel encoders. So, on your wheels, you might measure how much your wheel has turned.
If you didn't know, the diameter of your wheel, you know how much you have moved. Well, that's approximately true, 'cause the wheel might have slipped. There might have been bumps in the road where if it's not flat you don't move as far forward as you thought you would have, 'cause you really have been going down and back up. But, it gives you some kind of measurement of how much you've moved. Then, often people with a laser range finder on a mobile robot. Why is that? It sends out a laser beam, and then it measures how long it takes for that beam to come back, and that gives you a measurement of twice the distance to the obstacle in that direction. And so, it's a nice way to directly measure 3D. It's a little bit problematic at times, 'cause sometimes you have mirrors, and then a thing doesn't come back, it reflects off in another way, or you might have glass that acts much like a mirror and same thing will happen, you don't get the measurements back.
But, if you have nice mapped surfaces, it's a really nice way to measure how far away things are. Dynamics is noisy because of wheel slippage. You might say, "My wheel turned this much," well, what if it slipped and you don't know what your next state is going to be if you don't know how much it slipped? And, there could be unmodeled variations in the floor that affect, essentially, where you end up. All right, so those are two examples, just to motivate why we might wanna deal with probability distributions in that... Yeah, if this is what we're faced with, or the helicopter's what we're faced with, we're not gonna have a deterministic notion of this is the state, we're just gonna have a bunch of sensory information, and the result, at best, will be a distribution over possible states.
Okay, so today what we're gonna do, we're gonna do probability review. Hopefully that's review. If what we do in the probability review section is not review, you should go study to make sure that it feels like review as soon as possible. Then, we'll do Bayes Filters, where we will look at the foundation of a lot of what we'll cover in the discrete setting. And then we'll start looking at Gaussians, which will form the foundation for what we'll do next lecture, to do it in continuous space. All right, so, probability theory. As a lot of math, it starts with some actions and then everything falls from that. So, probability theory, actions here is that you have some outcome, A, and there could be many possible outcomes.
An outcome A, the probability of the outcome is assigned a number between zero and one. Maybe, I don't know, the probability of being in the correct room for lecture has some probability assigned to it. Then, the probability of the union of all possible outcomes. Omega is essentially everything that could possibly happen, the probability of everything that could possibly happen, something in that set to have happened should be one, otherwise that's not the proper omega that captures everything. And, that also means nothing can have a number assigned higher than one, probabilities don't go above one. And then, probability the empty set. Well, the empty set is never containing the outcome that happened. Whatever happened is something, it's not in the empty set. And so, the probability of that is zero. And then, the main thing here is essentially how you keep track of probability. The probability of the union of two possible outcomes, A and B, is the probability of A,
plus the probability of B, but it's possible that A and B happened at the same time, and then you're double counting that, and so you subtract back out the probability that A and B happen at the same time, which is A intersection B, and that gives you the probability of the union. Pictorially, looks like this. You have your omega space which has all possible events in it. Then, there is outcomes that make A true. There is outcomes that make B true. And then, there's outcomes that make A and B true, the intersection. And then, the probability of A, union B, is the probability of A plus the probability of B, minus the probability of the intersection. One abstract, abstract or concrete, depending on your mindset, way to think of it is that everything that can possibly happen is a point in this rectangle, pictorially.
That's every possible state the world could be in is a point in that rectangle. I mean, we might never know the exact details of it, but every possible state is a point in that rectangle. And then, A is a property of the state of the world that holds true for all the ones that line that blue circle. But is a property of the state that holds true for all the states of the world in the yellow circle. And then, A intersection B is a property of the world that holds true for all the points that are in the intersection.
And so, you can think of A and B just as properties, or descriptions of abstractions of the world of the state for us. Individual points in that rectangle are in some sense the full state of the world, which are probably never observable, never really talk about because we don't care about all the details. We'll talk about A and B, but in terms of how it's all set up, that's an easy way to think of it. Then, when you use these axioms, you can come to new conclusions. That's kind of how math works, you posit some actions and then you do some derivations and you have a new thing that's useful to use. So for example, probability of A union, omega, minus A. Well, on the left, we just look at what's in the parentheses is well, A union with omega minus A, that's omega. So, the probably of omega is one. That's what we derived up to here. On the right-hand side, we used that thing that said probability of union is probability of each individual
event minus probability of the intersection, that's this. We work that out. Then, we know that this probability is zero, and now we have the probability of A plus probability of the complement of A, has to be equal to one. And so, that's the kind of properties you would derive. All right. So, there are discrete random variables and continuous random variables. So, here we have omega, again the rectangle, and again, think of every point in the rectangle as representing one possible state of the entire world. And then, X is our random variable we work with. X can take on four values, in the case the world is in a state that's in that left-most rectangle, we say X equals X1. If it's in that triangle above, it's X equals X2, and so forth. And so, there's only four values X can take on.
The probability associated with X equal to X1, we could think of essentially the mass associated with that region in the rectangle, and we call P a probability mass function. A simpler example than the abstract rectangle there would be a coin flip, heads and tails. Probability half for each. That's another example of a distribution. Again, you can think of it as, in the context of that rectangle, though, you can say, "I have a rectangle, I split it in half, "there is heads and tails, "in half the states of the entire world, "my coin came out in heads, "half the states of the entire world, "my coin came out tails." We're ignoring everything else about the world, we're just looking at heads versus tails, and not the details of everything else in the world.
Continuous random variables, X takes on a value in the continuum, you cannot now associate a probability with X taking on a specific value, because if it's infinitely many things, it's a continuum. If you want to assign a finite probability to things, it'll sum up to something higher than one, which we can't have, it needs to be something to one. So, we can't sum anymore, we have to integrate now, so what we'll do is we'll say, probability density function is defined as saying that if you look at mass under the curve,
so the probability of what X, being the interval A to B, is the integral from A to B of P of X, dx. For example, if we think from zero here, maybe, till this point, we could take the probability mass and that's then the area under the curve would be denoting how much probability we associated with X landing in that interval. So again, we can't really talk about X taking on a specific value here, the best we can do is say, probability of X lying in an interval. You could say probability of X taking on a specific value, let's say it's zero, but then to have something meaningful, you take intervals and assign probabilities to the intervals.
Any questions so far? All right, then, the most important thing, and what we'll be working on is to look at distributions that involve multiple variables. So, why is that? Well, the reason is that, as already talked about, we'll have things like real state that we care about and sensory measurements. So, we wanna somehow talk about the joint distribution between the two, such that if we measure one of them we can say something about the other one. Or, it will do with dynamics of the world, and so we wanna relate the distribution now with the distribution at the next time. And so, both of these involve joint distributions over two random variables, rather than just looking at a single variable.
All right, so, the joint distribution over X and Y is denoted this way. Then, in simple scenarios... Simple scenarios, X and Y might be independent, meaning that the probability of X and Y taking on specific values, small x, small y, is the probability of X taking on value x and Y taking on value y.
That's the case, actually, knowing X does not tell you anything about Y or the other way around. So, it's actually a not so interesting case, mathematically it simplifies things, but if you had a sensor where your sensor is independent of the state of your system, the sensor cannot inform you about the system. Sometimes the property that holds true, though, and then it's good to know and good to take advantage of mathematically, but you don't wanna build your systems that way, necessarily. Then, X, given Y, is the probability of
X taking on value of small x, given Y has value of small y. So, what we have here is that, as a definition we write it as, X given Y is the probability of X and Y divided by the probability of Y. So, think again about that rectangle, there's a region where Y takes on the value of small y, and that has a certain surface, and that's P(y), and we look at the region where X takes on value of small x, within that region, that's P(x,y) and then the fraction of the surface it takes up, that's the conditional.
We can also re-write this as the probability of X comma Y is the probability of Y times the probability of X, given Y. This'll become very useful in many situations, because let's say we know the distribution for Y, and wanna know something about X, which might be the distribution at the next time slice, and if we know something about X, given Y, that is, maybe the dynamics of the system to go from Y to next time X, then this equation will tell us something about the joint, and hence tell us something about X.
Then, if X and Y are independent, then the conditional of X given Y is the same as the marginal for X. So, P of X, we'll call the marginal for X, and so that means that sometimes in our math, we'll be able to simplify things. If you're an assumption, X independent of Y, and we see X given Y appear, we can just get rid of the Y and simplify it to just PX. All of this is also true for probability densities. It's just, in densities often it's a small p, but other than that, you can write the exact same math, and now it'll say something about the densities instead of the actual probability mass.
Now, let's work through the equations we'll be using the most. All right. So, there are essentially two equations we'll be using a lot, and so let's explicitly step through them and see what they are. (projector screen humming) One is called law of total probability.
(marker scratching) What's it say? It says that, and we'll write it for the discrete case, the probability distribution for X is equal to, so probability X equals X, is sum over all values Y can take on, of P(x,y).
So, the reason that'll be so important is 'cause often we'll wanna get rid of some variables and move to another variable, and the way we're gonna be doing that is by constructing a joint distribution over those two variables somehow, and then summing out the one we don't want anymore. More specifically, the way this'll typically be used is here we'll say, P(X) is equal to sum over Y, and imagine we already had access to the distribution for Y, and we need to construct a joint, 'cause you wanna bring in X, now you might have a model for how X is related to Y, so you'll have P(X), given Y, and so this equation here is one that we'll find ourselves using a lot. One of the two equations we'll be using over and over. Same thing can, of course, be done for densities. In densities, the summation will become a intregal, 'cause you have to integrate overall continuous variables, values the variable can take on,
rather than discrete variables, you just sum. Otherwise, same thing, though. In general, whenever there's a summation, you can but a intetral, same math will go through. So, that's one of the things we'll use a lot. The other thing we'll use a lot is Bayes Rule. Bayes Rule hopefully sounds familiar. How do you derive it? We actually derive it from looking at the expression for the joint, the X,Y is P(X) given Y times P(Y), which is also, 'cause the roles of X and Y are arbitrary, it doesn't matter which one comes first or second in this equation here, we can swap the roles, and we have P(y) given x, times P(x).
From that, using just this part over here, we can write, P(x) given y as P(y) given x, times P(x) over P(y). Let's interpret this equation for a moment. So, what are we doing here? We're interested in finding the distribution over x, given y. So, if we can associate a story with this, imagine x is the state of the system, and y is a sensor reading we might obtain. And so, we wanna know, what's the distribution over possible states of the system given we have a sensory reading, y.
Well, it's not easy to come up with a table for that. It's not easy to just say, "Oh, you know what? "I'm just gonna build a table for P, X given Y." Because, it's actually not really how nature works. The way nature works is that, if there is a state, that state causes the readings. So, this model here is really the causal model that we have available. Given a state, it will cause a distribution over readings. When you build a sensor and you try to sell it to people, this is your sensor model that you would provide. It's a vista distribution over outcomes given this situation, this situation of outcomes given this other situation, and so forth. For example, for a laser range fighter, you might say, "Well, if there's a mapped surface at a certain distance, "the reading you'll get back is within maybe two centimeters
like maybe with standard deviation two centimeters around the proper distance reading, something like that. So, that thing is your calibrated sensor and that you can get a distribution for but what actually I believe will be distribution over state given that reading will depend on the prior X, what you thought ahead of time might be likely states of your system and so they combined together and then of course is a normalization to make sure things sum to one that's old is this and often will write this as just one over Z times P Y given x times px or it turns out in a probabilistic robotics book notation they love to use it I so often write as a dot x py given x times px.
So we don't have too much worry about the thing at the bottom, that's just a normalization. We just wanna understand the thing at the top which brings together the thing for which we are able to build a model which is the relationship from X to Y and how we can then use it. Assuming we have a prior over X, use it to get the distribution we really want which is distribution over state.
Any questions about this. These two equations are essentially the ones we'll just use everywhere and what we'll do today, next lecture, lecture after that. If you fully understand those you should be in really good shape. Now we can have a new version of this. So law of total probability again but with conditioning.
What does that mean? For both of these, imagine for the first one here, imagine we had already something to conditioned on, maybe there was a measurement in the past that was already there, like we really interested in not going just from Y to X but there's some Z that's already present somewhere. So, what can we do? Well we can say okay P X given Z is equal to, we write the same equation, sum over Y P Y times P X
given Y, but since we conditioned on Z, we need to ever wear condition on Z and if you already, I mean, notation wise condition on Y and Z is just Y comma Z you don't need to draw another bar. And so what we see happen is that the exact same equation can be written with just additional conditioning on Z or any number of variables as long as you consistently put them everywhere. So you can always add more conditioning. And so often that's the version we'll be using 'cause we'll have many things we've already observed in the past will wanna condition on and then we'll wanna apply the equation the left law of total probability and we'll just carry along everything so do our math as if it doesn't exist, we just need to consistently carry it along very straightforward. Gotta be careful, you can't drop it anywhere. Same thing is true with Bayes rule, what if you have multiple things you are conditioning on, you already condition of something else, no problem.
Bayes rule with conditioning and the reason this shouldn't really be a surprise is you go back to the original picture of probability right then we have this rectangle and the rectangle is really the foundation of everything with a point in the rectangle corresponding to the full world state and then regions correspond to values the random variable takes on. If you condition on something essentially we're just redefining the rectangle as being only, let's say this part, that's our new rectangle and that's the only part of the world we're working with possible States you can take on and once we've done that, we put all probability on this thing, we kind of renormalize it, everything's there. That's our new rectangle and the maths not gonna change
'cause we're just looking at this sub part of the whole rectangle. But of course you need to do it consistently, every step along the way. We need to consistently look at that sub part where we are having Z, this would be Z equals Z. We need to keep it consistently to that part, we can sometimes have it sometimes, not when we do this. But then same thing with Bayes rule, yeah. Initially it was for the full rectangle, now we restricted attention to some sub region. No problem, we just condition everywhere. P X given Y comma Z is equal to, well what do we have?
We had Y given X but of course also Z because Z needs to be in the back everywhere now, then P X but we need to carry along the Z and then normalize by Y again given Z. But again the bottom here doesn't really matter much in Bayes rule, we usually know that we just need to compute the top part for every possible value of x and once we computed the top part for every value of x, we can see what it sums to and whatever it sums to is what goes in the bottom, right. And so applying Bayes rule is about doing this for all X and then summing to know what the bottom is.
And so here we see that we can incorporate new evidence, we already had evidence we had already had X given Z, we had a past observation, distribution over x given that observation, then a new thing came in for Y. And we have a model of how Y acts given X and Z and practice often the Z will disappear here because Y will only depend on X not on Z but in general, Y could depend on X and Z. And then we can combine that together to know what now new distribution is over state X.
Then another concept that will be very important is conditional independence. So conditional independence is a lot like independence but a little less strict. Independence is a property that and sometimes it's nice 'cause it simplifies the math whenever you run into it but if your variables are all independent then you can't really infer anything from one variable about the other variable and so ultimately you get no interesting results out. You need the variables to interact to get something interesting out. Now it could be that they interact but in limited ways and that's what conditional independence tries to capture.
So conditional dependence, we have X conditionally independent of Y given Z if and only if we have P X comma Y given Z equals P X given Z times P Y given Z. So it's like independence, the joint being x and y is the product of marginal for X marginal for y except that it's only true when you condition on Z. Once you know Z, x and y are independent but as long as you don't know Z, they might have a relationship. For example Z might be something I don't know, like Z could be the weather and X might be is somebody carrying an umbrella and Y might be is the pavement wet
or something. Once you know it's raining, you already know that the rain will cause x and y independently. It's not related directly whether pavement is wet and somebody cares umbrella, it's through the fact that it rains which is the common cause for both of them. And said I will make x and y independent given z. Another example and the one that will see most often in this class is, if you know the state of the world then every sensor you're reading my independent very often 'cause if your sensor just acts on the real state of the world, then the reading that happens first, very happens next will be unrelated and we'll be able to simplify things.
Okay, so this is kind of really everything we need so we just need three things. We need law of total probability, the regular version and the conditioned version, we need Bayes rule, the regular version the conditioned version and we need a notion of conditional independence, which will allow us to simplify equations. This is also equivalent to writing, and often we'll see it that way, equivalent to P X given Z and y but once you know Z, X is independent of Y being equal to px given Z and it's also equivalent to P y given Z comma X being equal to Y given Z, 'cause once you know Z, X does not tell you anything about Y.
Now to be fair this condition the dependence assumptions that we'll be making some times in the real world might not exactly be true ever but they'll often be reasonable approximations and we might be willing to make them because they drastically simplify the math and the competition we need to do to then run the algorithm in practice. So often these things are assumptions we make to approximate things that are almost independent in the real world.
Questions so far? Yes. (Student asking a question at the back) So typically the way you would do this is, typically what you'd be given is from a previous calculation maybe or just given would be this thing here, which is the prior over X or prior over X given Z, you'd be given a model of how X and Z in this case are just X in that case cos Y, that's your sensor calibration model, for example, and that together allows you to compute this product for every possible value of X, because we're conditioning on Z, a favorite possible value of X, yeah.
We compute this for every possible value of X cause Y will be measured in this scenario, Z will be measured so y and z will be numbers available to us, X will not be known, can take on many values. And so we'll compute this for every value of X. Now after we've computed this for every value of X, we'll have a table of all these four values of X and those entries if we ignore the bottom will not sum to one, but we know it's supposed to be a distribution over x given y and z. So then, I also know we ignored the thing at the bottom, that does not depend on X that's key here, there's no X in here. So what we're computing is a table with entries that depend on X, every X will have its own entry and we know all of them are missing the same rescaling, which we've ignored but we can find the rescaling by remembering that actually every old entries in the table have to sum to one and so summing all the entries in that table will actually compute this thing over here,
mathematically we know that's a way to compute this and practice we don't often pay attention to what it really means we, just say hey, we want this, we know this thing here does not depend on X, so we can ignore it as long as at the end we do a rescaling of all entries with the same scaling. You cannot rescale one entry for x one by the other one, You need a fixed rescaling across all entries that you computed.
So the things written on the board we also have on the slides where often we have a pairing between the discrete version where there's a summation and continuous version where you just replaced out some sign with a little squiggly thing and then you put a D something is over the variable instead of putting it under, so essentially just always a place sum over the variable with this thing here and then a dy and then you got the same thing Just for continuous space. Bayes rule, the terms we didn't name them but essentially often the X, the P of X is called the prior because we have it ahead of time, Y given X is the likelihood of a measurement Y given the state is X is often what it ends up being solvent called likelihood and evidence is, yeah, that's just Y is what you measure to is a probability of getting that evidence.
Therefore we just talked about when you do these calculations often you effectively algorithmically you compute it for all X's, you compute that top part in the fraction and after you've done that, you know it has to be rescale and you just compute the rescaling and multiply with that. In the paralytic robotics book notation it's a little bit funny that sometimes they use the ADA as the thing, you multiply with sometimes I think you divide by, just gotta I guess be okay with that, it has different meanings in different contexts, but Ella is just a rescaling and some people like to divide by their risk and some people like to multiply with one over that thing all the same.
Law of total probability with integrals, we saw that, Bayes rule with conditioning we saw that, we saw a conditional independence, what it means. Again it's an assumption we often make that will hopefully be approximately true or maybe even fully true, so we can use it to simplify our math. Here's a simple example, so we have a robot trying to see the doors open or not. Okay what's the probability of doors open given some measurement of the sensor of the robot?
It is to illustrate that kind of reasoning behind why we often use Bayes rule. Probability of being open given some measurement is a diagnostic distribution, it's kinda we're trying to diagnose what's the state given a measurement. But those distributions often we cannot build, we cannot deliver sensor without distribution because, I mean you can't do that, imagine you deliver the sensor to somebody and they lock the door and nobody has the key anymore then your sensor can't know that 'cause you didn't know that ahead of time. What you really can build is the opposite distribution, the causal one, given a situation, what am I going to measure? And so that's what's be available to us and that's what we have to use but it's not what we want. The reason about the world so we'll use Bayes rule to get what we want which is the opposite thing going from
the distribution that we know how to model, which is the measurement given the state to the distribution, we want to take action which is one know whether the door is open or not or at least a distribution over that. For the causal one, it's really just a matter of counting frequencies. You might have a physical model that makes it easy but often you just kind of just do a bunch of measurement so you see how often does a sensor read this or that as a function of whether the door is open or not and now I have my model.
Let's do a concrete example, we need to put some numbers into it, probability of a measurement Z given the doors open is 0.6, Z again when the door is not open is 0.3. So we see that when the door is open, we are more likely to measure Z as the outcome than when the door is not open. So if we measure Z, which should increase our probability that the door is open. And our prior is 50%, well we can apply Bayes rule, we measured Z, we can look at Bayes rule, fill this in, do the math which is described and find D that now after measuring Z which favors the door being open, we have more specifically 0.67 probability that the door is open.
Now you could have another measurement, imagine have another sensor, wait where does it go, yeah. Well imagine we have another sensor Z two, how can we integrate that? Well we can again apply Bayes rule, we already know that we can apply Bayes rule again even with conditioning in the back, we already conditioned on one measurement just in a condition on the next measurement. We actually do this as many times as we want. So the condition on many measurements, we can do it one at a time and build it up.
So here we have the, often a assumption is applied to simplify the math is that the sensor measurements are all independent given the state of the world 'cause the state of the world is causing what you measure and so if the state of the world is a known entity, then each outcome is independent given that state. That will simplify the math 'cause then when we look at Zn the Nth sensory measurement given the state of the world X and all the other sensory measurements, we don't need to build a model for Z and given X and the other measurements we just need to build a model for Z and given X, the state of the world which is exactly the kind of sensory model that we like to build. So we get a simplification happening over here we have Zn
conditioned on everything that's the standard base rule with conditioning but then we made an assumption, there's not generality but we made an assumption that Zn is independent of the other Z's if we already know the state X and then this here has simplified. Then again the bottom we don't worry about there's no X in it, we can compute the top part for every value of x once we're done we sum it all together to know what the bottom is that will normalize it. We can apply this repeatedly the idea we just saw that this becomes Zn given X, px given all the previous ones, there's nothing specific about Zn and we'll see that we get a product over all Z is given x times prior over X. And so now all we need is that sensor model for each sensor given X, we multiply probabilities together and we get our posterior distribution.
Okay, for the door example we had in this case a new sensor Z2 and when we see Z2, it actually is more likely to be seen when the door is not open and we observe Z2, so what do you expect to happen mathematically, we had a 2/3 probability of the door being open ahead of time after sensor measuring 1 we observe Z2, that probability should drop, but let's check, we can do the math, we just apply Bayes rule fill in the numbers and indeed the probability drops as we expected.
All right, now there is one thing I wanna point out here is that a typical pitfall is that real-world sensors are not always super independent. So you might have a sensor and you might say, okay maybe I have a little laser rangefinder and it reads a reading, but then maybe send out two beams next to each other but those two beings might encounter the same kind of noise or the same kind of interference in their paths. and so those two measurements might not be independent and the assumption we just went through where there's all simplifies just becomes a product of things is violated.
Even though often the math will want this and practice, be careful, you need to think carefully are these sensory readings really independent? Or imagine the laser rangefinders reading something at time T and you run it again at time T plus one but nothing has changed in the world then are those really independent readings? Not totally necessarily 'cause you're measuring the exact same configuration with the exact same sensor, so maybe it's not completely independent, so be careful. What can the effect be? Imagine you think they're independent, these readings and they're not, what do you think will happen?

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