 This is a video about probability density functions for continuous random variables. First of all, what's a continuous random variable? Well, whenever you have a random process, the outcome of which is a measure of distance, or of time, then that would be a continuous random variable. For example, suppose I choose a pencil at random and measure how long it is, or I choose a random competitor in the London Marathon and I look at her finishing time. Then those will be continuous random variables, because measures of distance and of time are continuous. Continuous random variables can be contrasted with discrete random variables, like those which had the binomial distribution and the Poisson distribution. These represented the number of successes in a sequence of trials, or the number of events in an interval of time or space. And these are the number of times that something happened. They have to be whole numbers. Continuous random variables, on the other hand, can be any number at all. Now this video is mainly about probability density functions, and the next thing I want to do is to give you a sense of what these are. I'd like you to suppose that we're on an alien planet, and just like here, the aliens have all different heights. Let's suppose that x is the random variable, which is equal to the height in centimetres of a randomly chosen alien. The probability density function for x gives us a sense of the different possible heights of the aliens and the relative likelihood of the heights. So you can see from this graph that there are two clusters of heights. Many of the aliens have a height close to 200 centimetres, whereas another group of aliens have a height close to 100 centimetres. You can also see that the aliens whose height is close to 200 centimetres all have roughly the same height. There isn't much variance in the heights of the aliens which are close to 200 centimetres. On the other hand, the aliens whose heights are close to 100 centimetres have heights which are more spread out. There's more variation in the heights of the shorter aliens. Now, how does a probability density function work? Well, it's quite similar to a histogram. And here's a histogram of the same population of aliens telling you about their heights. The only difference really is that the histogram gives us only a very crude picture of the distribution of heights. There's only a small number of intervals and the picture looks quite blocky. We can draw a better histogram by increasing the number of intervals and if we do that the graph becomes more and more accurate. At this stage there are so many bars that you can't really see them but what you can see clearly is the overall shape of the histogram and you'll notice that the overall shape is exactly the same as the probability density function. So a probability density function is very similar to a histogram in that it shows you the shape of the distribution of heights. It tells you all the different possible heights for the aliens and the relative likelihood of each height. Now the most important thing about a histogram is that you can see what the relative frequencies are by looking at area. And in the same way you can find a probability from a probability density function by looking at the area under the curve. For example if we wanted to know the probability of getting one of the tall aliens then we would want to know this area. And similarly if we wanted to know the probability of getting one of the shorter aliens then we would want to know this area. Now if we look at these two areas together you can see that although the one on the right is taller it's also narrower. In fact it's twice as tall and it has half the width. So these two areas are about the same and that means that the probability of getting a tall alien is about the same as the probability of getting one of the shorter aliens. Now what are the key points that you need to know about probability density functions? Well the most important one is that the probability that the random variable x is between A and B is the area under the curve under the probability density function between A and B. Now you must be aware that the way to find areas under curves is to do some integration. So it won't surprise you to hear that the probability that x is between A and B can be calculated by evaluating the integral of the probability density function with limits A and B. For example if we wanted to know the probability of getting an alien whose height is between 90 centimetres and 190 centimetres we'd have to find this area and we do that by integrating the probability density function with limits 90 and 190. There are a couple of more points that you need to know. The first is that the probability density can't be negative because otherwise we'd end up with some negative probabilities which doesn't make sense. So that means that the output of the probability density function must be greater than or equal to zero for any possible input. The final thing is that the total area under the curve must be one because the total probability must be one. And so the integral of the probability density function over all possible values must equal one. This area here must equal one. Now what sort of questions can you be asked about probability density functions? Well unfortunately real world probability density functions can be extremely complicated. For example the probability density function that I've sketched here has this definition and this would be very hard for you to do any calculations with. For example it would be impossible for you to integrate this. So that means that in this topic on continuous random variables and probability density functions you're not going to be looking at real world examples. Instead it's all going to be quite theoretical. Now the first type of question that you'll be expected to answer is about recognising when a function could be a probability density function. So I'm about to show you some graphs and I want you to think about whether they could be probability density functions. So what about this? Could this be the graph of a probability density function? Well the answer is no it couldn't because there's a part of the graph which dips below the x-axis. And what this means is that the probability that x is between 3 and 4 would be negative. So the fact that this function is less than 0 when x is between 3 and 4 means that this can't be a probability density function. What about this graph? Could this be the graph of a probability density function? Well this time we need to look at this area and find out if it's equal to 1 because remember the total area under the graph of a probability density function must be 1. Well this is just a triangle so we can find the total area by doing a half base times height which in this case is a half times 4 times 0.3 which is only 0.6. So therefore this can't be a probability density function. What about this function? Could this be a probability density function? Well again we need to find this area and check whether or not it's equal to 1. Well this time we've got a trapezium and so the way to find its area is to do the average of the parallel sides multiplied by the perpendicular distance between them. So we need to find the average of 0.1 and 0.4 and multiply that by 4. That does give us the answer of 1 and so this could be a probability density function. Let's look at another example to do with recognising probability density functions. A variation is to give you a partially defined function and to ask you to complete the definition. In this case the function is partially defined because it includes the letter k which we don't know the value of and the task is to find the value of k. By the way this function is a good example of the type of function you're going to see a lot of in this context. It's called a piecewise defined function because it's defined in two pieces. The definition tells us that when x is between 1 and 4 f of x is equal to k times the square of x plus 1. And otherwise when x isn't between 1 and 4 f of x is equal to 0. It may be helpful to visualise the graph of this function. You can see here that between the values of 1 and 4 f of x obeys one rule whereas for all other values of x f of x is equal to 0. Now we know that the total area under this graph must be 1 and that's how we're going to find out what k is. We need to work out the total area and then see what value of k is needed to make it equal to 1. So we need to use integration to find the total area under the curve. And since the only area is between 1 and 4 we can integrate the function with limits 1 and 4. So we need to find the integral of k times the square of x plus 1 with limits 1 and 4. Now the integral of x squared is a third of x cubed and the integral of 1 is x. So the integral we're looking for is k times a third of x cubed plus x with limits 1 and 4. That's equal to k times a third of 4 cubed plus 4 take away k times a third of 1 cubed plus 1. And if you work that out that's k times 64 over 3 plus 4 minus k times 1 over 3 plus 1. We can simplify this in various ways but one way is to see that 64 thirds minus 1 third is 63 thirds and 4 take away 1 is 3. So we've got k times 63 thirds plus 3 and that's equal to 24k. Now the whole point here is that this area, this integral must turn out to be 1. So what we can say now is that 24k is equal to 1 and therefore that k is equal to 1 over 24 which is the answer to this question. Okay, the second type of thing that you can be asked to do with probability density functions is to calculate probabilities and so let's look at an example of that. Here's the probability density function that we were just looking at this time with k replaced by 1 over 24 since that's what k was. The question is to find the probability that x is exactly equal to 3. Now let's think about that. If x is exactly equal to 3 it's not equal to 2.9 or 3.1 or 2.99 or 3.01 so that means that we're trying to find the area of a line. Now how thick is this line? And the answer is that it doesn't have any thickness. It doesn't stretch from 2.99 to 3.01 even in which case it would have thickness 0.02. The thickness is actually 0. I mean I know that in the picture it does have a tiny thickness but that's only because I wanted you to be able to see it. In principle it doesn't have any thickness at all and that means that no matter how tall it is the area of the line must be 0 and therefore the probability that x is exactly equal to 3 is 0. This is kind of a trick question. Let's look instead at the probability that x is greater than 2 and less than or equal to 3. Well here's the area where x is greater than 2 and less than or equal to 3. So we need to find out this area. We'll do that by integration. We need to integrate 1 over 24 times the square of x plus 1 with limits 2 and 3. That integrates the same way as before so we need to find out the value of 1 over 24 times a third of x cubed plus x with limits 2 and 3. And that's 1 over 24 times a third of 3 cubed plus 3 minus 1 over 24 times a third of 2 cubed plus 2. That comes to 1 over 24 times 9 plus 3 minus 1 over 24 times 8 thirds plus 2. And if you work it out that's equal to 11 over 36. So that's the answer. That's the probability that x is greater than 2 and less than or equal to 3. Before we move on I want you to notice something really important here. If x had been a discrete random variable taking only whole numbers then these two probabilities would have been the same. The event that x is equal to 3 and the event that x is greater than 2 and less than or equal to 3 are the same if x has to be a whole number. But in this case x is a continuous random variable and so these probabilities have turned out to be completely different. One other question to do with this probability density function what's the probability that x is greater than or equal to 2 and less than or equal to 3? Well this is another trick question. The answer is the same as before because the probability that x is exactly equal to 2 would be 0. And so there's no difference between the chance that x is greater than 2 and less than or equal to 3 and the chance that x is greater than or equal to 2 and less than or equal to 3. Okay, here's another example to do with calculating probabilities. This time here's the graph of a probability density function and I'd like us to find the probability that x is greater than or equal to 2 and less than or equal to 4. That's this area. Now this time we don't need to use integration in order to find the area. We can just use some simple geometry. And one way of doing it would be to split the area up into a trapezium and a triangle and to find the area of these two shapes. But actually there's a slightly easier way. The entire area under the graph must be 1 so what we can do is to find the area of the yellow triangle and subtract this from 1. Now finding the area of a triangle is generally quite easy but this time we need to start out by working out the height of the triangle. We need to find the value of the probability density function when x is 2. Well the answer is that it will be 2 thirds times 0.5 because the graph rises from 0 to 0.5 from when x is 0 to when x is 3. And so 2 thirds of the way along it must have risen to 2 thirds of 0.5 which is 1 third. Okay so now we know the height of the triangle it's easy to find the area. The area must be a half times 2 times a third which is a third. It follows from this that the red area the area that we're looking for is 1 minus a third which is 2 thirds and so that must be the probability that x is greater than or equal to 2 and less than or equal to 4. The third type of thing that you need to be able to do with the probability density function is to define it. You see you might be given the graph and asked to work out from the graph an algebraic definition of the probability density function. So what we need to do here is to work out the equation of each part of the graph and we'll start out by looking at the line on the left. We'll need to know it's gradient which here is 0.5 divided by 3 because it rises 0.5 between when x is 0 and when x is 3 and that's equal to a sixth. Now if we use y equals mx plus c we can see that y must be a sixth of x because obviously the y-intercept c is 0. For the line on the right hand side the gradient is minus 0.5 divided by 1 because it falls 0.5 between when x is 3 and when x is 4. So the gradient is minus 0.5. Now if we use y minus y0 is m times x minus x0 we can see that y minus 0 must be equal to minus 0.5 times x minus 4 because the line goes through the point where y is 0 and x is 4. Simplifying that we get y equals minus 0.5 of x plus 2 or more neatly y equals 2 minus 0.5 of x. So these are the equations for the lines that make up this graph. The one on the left is y equals a sixth of x and the one on the right is y equals 2 minus 0.5 of x. And this enables us to define the probability density function. We can say that f of x is equal to a sixth of x when x is between 0 and 3 that it's equal to 2 minus 0.5 of x when x is between 3 and 4 and everywhere else it's equal to 0. You'll notice that this is another piecewise defined function. Okay, one last example and this is to do with calculating probabilities again. This time I want to use integration to calculate the probability that x is greater than or equal to 2 and less than or equal to 4 for this probability density function that we've just defined. This is the same area that we already worked out and obviously it was quite easy to work it out by looking at the area of some simple geometric shapes. But unfortunately this time I want to do it by using integration. Now we could use a similar trick to before and use integration to find the yellow area and then subtract the answer from 1. But actually I want to use integration to find the red area directly because I'm trying to illustrate an important point. Because we have a piecewise defined function integrating the function isn't straightforward. What we've got to do is to split it into parts and integrate a sixth of x for the left-hand side and integrate 2 minus a half of x for the right-hand side. We have to do one integral with limits 2 and 3 and another integral with limits 3 and 4 and this is because the definition of the function changes when x is equal to 3. So first of all we need to integrate a sixth of x with limits 2 and 3 and that's going to be a twelfth of x squared evaluated with limits 2 and 3. That's 9 twelfths, take away 4 twelfths, which is 5 twelfths. Secondly we need to integrate 2 minus a half of x with limits 3 and 4 and that's 2x minus quarter of x squared with limits 3 and 4 which is 8 minus 4, take away 6 minus 2 and a quarter. That's 4 minus 3 and 3 quarters, which is a quarter. So now we can say that the total probability, the probability that x is greater than or equal to 2 and less than or equal to 4 is 5 twelfths plus a quarter, which is 2 thirds. Phew, we got the same answer as before. Before we move on I just want to emphasize the point of this example. If you're using integration to find the area under a piecewise defined function you sometimes have to integrate it in parts. You've got to integrate one expression with one set of limits and another expression when a different set of limits. So do be on the lookout for this. Okay, so this has been a video about probability density functions and these are the things that you need to remember. First of all and most importantly the probability that a random variable is between a and b is the area under the probability density function between a and b. In other words, the probability that x is greater than or equal to a and less than or equal to b is the integral of the probability density function with limits a and b. Secondly, probability density can't be negative. So the output of the probability density function must be greater than or equal to 0 for all possible values of x. And finally the total area under the curve the total area under the probability density function must be 1. The integral of f of x overall possible values must equal 1. Okay, thank you very much for watching. I hope that you found this helpful.