Hi. My name is Brian Caffo. I'm in the department of Biostatistics of the Johns Hopkins Bloomberg School of Public Health. And this is Mathematical Biostatistics Boot Camp Lecture Three on Expectations. Expected values are ways of summarizing probability distribution in the same way, in the last lecture, we talked about quantiles to summarize probability distributions. So, we will talk about the rules that expected values have to follow, we will talk about the basic mechanics of how you calculate expected values for discrete random variables and continuous random variables. We will talk about important subclasses of expected values. The mean, variances, and we'll talk about how to interpret variances because they're a little bit trickier with Chebyshev's inequality. The expected value or mean of a random variable is the center of it's distribution. It's in essence a particular definition of the middle of a distribution. There's more than one definition of the middle of a distribution. For example, the median would constitute a different definition of the middle of a distribution. But the mean is a particular one. And we'll talk about the intuition behind it in a minute. And consider how you would calculate the mean for example, a discreet random vaiable. We denote the mean with this capital E here which stands for expected value, and then usually, for whatever the reason, we tend to use square brackets for expected values rather than parentheses. And so, we might write expected value of X. Here again, we're using a capital X because we're talking about a conceptual value of the random variable. This, in the case of a discrete random variable is the sum over all possible values that X can take of x p(x). Now, note here. If we didn't have this x out in front of the p(x), this would just sum to one because the PMF sums to one by the definition of, of a PMF. So, this x out in front is what turns it into an expected value. Here, we were just talking about the expected value of x. But if we wanted the expected value of x squared it would be the sum over x and we would have a little square in front of the x right here that we're summing over. So, sum over x^ two times p(x). E(X), one way to think about expected value of X is that it represents the center of mass. If the Xs are locations, and the p of xs are weights, and I have kind of a schematic here on the next slide that's shows an example. So, imagine if on the horizontal lines here, let's suppose the left most line is at the point zero, and it's just a, a real line extending in the positive direction and each location of, of a line here is the value that x would take. So, in this case, X takes four possible values. Two low values and two high values. And the height of the bars is p(x). So, in this case, p(x) is equal for each of the four bars. So, because p(x) is a probability mass function, each of these four bars would have to take value one quarter. So, the expected value then would be the center of this distribution, the point at which you would balance this out if this was, say, for example, four little bars and you wanted put your finger on the horizontal bars, so that it would balance out. And here, of course, because the bars of the same height, you know, of two on the left side and two on the right side, placed in the same configuration, the geometric center of mass would be right in the middle. Well, what would happen consider the one next to the right, what would happen if you had three all squashed up on the right-hand side and one really far on the left hand side? Well, the one really far on the left-hand side would pull the mean away from the center of the three just to a little bit outside of it. And then, I go through two other cases over here where I vary the heights of the bars and their configuration. In each of these cases, the fulcrum point at the bottom is exactly where you'd have to put it to balance out the bars. And that's where the expectation gets its definition from. It actually draws exactly from the Physics' definition of center of mass. And, and in this case, it's exactly just another property of a probability mass function in order to characterize it. Let's talk about how you calculate the expected value for a coin flip. So, in a coin flip, our sample space is heads or tails. And we'll define our random variable as being zero for tails and one for heads. Let's calculate the expected value for the probability mass function from a fair coin. That is, it's a 50 percent chance of tails and 50 percent chance of heads. So, let's plug directly into the formula. The expected value of the coin flip x is 50%, 0.5 probability of a tail times the value we've assigned for a tail, zero plus 0.5 times the value we've assigned for a head, one. Add those up and you get 0.5. So, the expected value of a coin flip is 0.5. This exactly makes sense if you think back to our previous page. If you had a bar at zero and a bar at one, and they were both equal height, you would put your right at the 0.5 to balance out that bar. So, it, it maps intuition. Also note the expected value does not have to be a value that the random variable can take. In this case, the random variable can only take value 0,1. But the expected value is point 0.5 which is between the two. Okay, let's go through the same exercise but, now instead of a coin, let's talk about a die. Here, the possible values that the die can take are one, two, three, four, five, and six. We're going to assume that the die is fair so all of the numbers have probability one-sixth of occurring. What's the expected value of that die roll? So, we denote the expected value again by E[X]. Here we have one times the probability of getting a one one-sixth plus two times the probability of getting a two one-sixth, and so on. And if you add them all up, you get 3.5. Again, this makes perfect sense. You have six bars of equal height. One at position one, one at position two, one at position three, one at position four, one at position five, and one at position six. And, of course, if you were to balance that out with your finger, you'd pit it right in the middle of those numbers as 3.5. That covers discreet random variables, at least two examples of discreet random variables. Let's talk about how you do continuous random variables. Well, again, the definition follows exactly from the physical definition of center of mass and in this case, the expected value of a random variable x is the integral from minus infinity to positive infinity of t f(t) dt. And here t, is just the dummy variable of integration. Pretty much the same formula. Here, if you omit this value t right here, then the integral just works out to be just one again because f is a probability density function. So, it's putting the t there that turns it into expected value. If you wanted the expected value of x^2, then it would be integral minus infinity to plus infinity t^2 f(t) dt. And this just borrows from the definition of center of mass for continuous bodies rather than the center of mass of a group of discreet bodies exactly from physics. And again, it's just a description or it's a useful summary of the density function f which is a complicated functional construct. It reduces it down to one number, which is a property, which is what we kind of think as some, at least one of the definitions of the center of the density f. Let's go through an example of calculating the expected value of a particular kind of random variable, one that we have not encountered before. So, let's think of a very simple density. The density is such that it's zero below zero, constant at the value of one between zero and one, and it's zero above the value one. So, let's mentally just real quick verify that this is in fact a valid density. Well, this density is exactly a brick. Starting at zero, ending at one, with height one. You don't even need Calculus to verify that this integrates to one, because it's just a square. Its area is the, the length of base, which is one, times the length of the height which is one. One times one is one. So, it's a proper density. It's also positive everywhere because it's zero below zero, zero above one, and the value one between zero and one. So, it's positive everywhere. So, it's a valid density. This is in fact, actually, an extremely important density. It's pretty simple one, but it's an extremely important density, and it's called the standard uniform density. It sort of represents the idea that any value between zero and one, is equally likely. It's, so imagine if you were to, to drop a pencil on a line between zero and one. And you were dropping that pencil in such a way that it was equally probable to land anywhere between zero and one, this density would represent that process. Well, let's go ahead and calculate its expected value. Now again, we already know what the answer is from the geometric argument. It's a brick that starts at zero and ends at one. The answer has to be 0.5 because if you wanted to balance that brick out, you would have to put your finger right in the middle. So, let's just verify that calculation. Here, our expected value of our uniform random variable X is the integral from zero to one. And again we have X, right, in the previous slide I had t, but let's just use x in this slide times the density, which in this case, is just the constant one, so I just didn't write it down, then dx, the variable of integration. And so that integral is x^2 / two, evaluated the bound zero to one, which works out to be one half, exactly what we would have thought. Incidentally, I just want to remind everyone of this notation. The capital X in the expected value represents a conceptual value of the random variable. Whereas, the little x, in this equation, represents the dummy variable of integration. A value that's actually getting numbers plugged into it. So, it wouldn't have mattered for this little x if we had used x, or t, or z, or w, or whatever. However, it's important that we kept it at capital X. That's what we've assigned this random variable, the value capital X. So, it's small point but keep that in mind. So, I wanted to talk about something that always comes up in my in-person classes when I talk about this. So, here we calculate the expected value of x. And I, told you that expected value of x squared, well, you would just calculate integral from zero to one, x^2 dx. And a question that always comes up in class is, well, wait a minute. I could calculate expected value of x squared that way or I could figure out what the distribution of the square of a uniform actually is, right? A uniform random variable is a random variable representing some process. So, the square of that has to be a random variable and it, itself must have a density. So, I should be able to calculate the expected value from that density and it should be the expected value of y, let's say if y is x^2, do I get a different answer if I figure out what the density associated with the square of a uniform random variable is? Do I get a different answer if I calculate the expected value that way? Or if I calculate the expected value this way, by just putting a square into the expected value calculation from the original uniform density? At any rate, you'll be happy to know that you get exactly the same answer. And in fact, I would also add that it's a lot easier to just put the square in this integral equation because we automatically know, off the top of our head, what the density of a uniform random variable is. We may or may not know what the square of a uniform random variable is. So, this should give you some basic examples of calculating discrete and continuous expected values. In the problems, you'll have both harder and easier examples to work out, and in the assessment we'll have harder ones. In the next section, we'll talk about rules that expected values have to take.