 This is a video about finding the median of a continuously distributed random variable. Suppose we're looking at the graph of a probability density function. The median is a place where the probability of getting less than the median is a half, and the probability of getting more than the median is a half. In other words, it's the place where the cumulative probability is a half. And so the output from the cumulative distribution function is a half. And this is the key formula that we need to remember. The median is the solution if the equation f of m is equal to a half. Okay, let's look at some examples. You might be given the probability density function for a continuous random variable and asked to find the median from that. But in order to find the median, we need to solve an equation involving the cumulative distribution function, not the probability density function. So the first thing to do is to convert the probability density function into a cumulative distribution function. There are various ways of doing this, and you might like to have a go before continuing with the video. Okay, one way to convert a probability density function into a cumulative distribution function is to use indefinite integration. And we can say that when x is between 1 and 3, f of x is the integral of a sixth of x plus 1. That's the same as the integral of a sixth of x plus a sixth, which is one-twelfth of x squared plus a sixth of x plus c. Okay, but now we need to find out what the plus c is, and we can do that by looking at f of 1. We know that f of 1 must be 0, because the probability of getting up to and including 1 is nothing. And so if we substitute 1 into the above formula, we know we should get the answer 0. In other words, we know that a twelfth times 1 squared plus a sixth times 1 plus c should be 0. If you solve that, it means that a quarter plus c is 0, and therefore that c is minus a quarter. Okay, so now we can say what the cumulative distribution function is in this case. f of x is 0 when x is less than 1, a twelfth of x squared plus a sixth of x minus a quarter when x is between 1 and 3, and 1 when x is greater than 3. Now we know the cumulative distribution function. We can find the median by solving the equation f of m is equal to a half. Putting m into the function gives us a twelfth of m squared plus a sixth of m minus a quarter equals a half. Or in other words, a twelfth of m squared plus a sixth of m minus three quarters equals 0. This is a quadratic equation, and one way to make it easier to solve is to multiply everything by 12, which gives us m squared plus 2m minus 9 equals 0. And then we can use the formula, which says that m is minus 2 plus or minus the square root of 2 squared minus 4 times 1 times minus 9 all over 2. And that gives us the answer 2.16 or minus 4.16 to three significant figures. And obviously the only correct answer here is 2.16, because that's the only answer that's between 1 and 3. So 2.16 is the median. Let's look at another example. This time suppose that we're given the cumulative distribution function, and we're asked to show that the median is 2.46, correct to two decimal places. Well this time we could try and solve the equation f of m is equal to a half, but you can see it would be an extremely complicated equation, because it would involve cubes of m and even the fourth power of m. And actually there's a much simpler method. We can show that the median is 2.46 correct to two decimal places by showing that it's between 2.455 and 2.465. And we can do that by showing that the cumulative probability at 2.455 is less than a half and the cumulative probability at 2.465 is greater than a half. And we can work out these cumulative probabilities simply by substituting the numbers into the cumulative distribution function. So first of all let's work out f of 2.455. It turns out to be 0.499 0876 990 and so on. And secondly let's work out f of 2.465. It turns out to be 0.503 456 1846 and so on. And that's all we need to do really. We just need to point out that because the cumulative probability at 2.455 is less than a half and the cumulative probability at 2.465 is more than a half the median is definitely somewhere between 2.455 and 2.465 and therefore whatever it is it rounds to 2.46 to two decimal places. Let's look at a third example. This time suppose that the cumulative distribution function is defined in four pieces and we have to find the median. So suppose that f of x is 0 when x is less than 0 and it's 1 when x is greater than 4. Then there are two definitions for between 0 and 4. Between 0 and 2 it's a 12th of x squared and between 2 and 4 it's a third of x minus 1. Let's see how we would find a median in this case. Well we're supposed to be solving the equation f of m is equal to a half. So we could begin by assuming that m was between 0 and 2 in which case we'd get the equation a 12th of m squared is equal to a half. And when we solve that we get m squared equals 6 which means that m is 2.45 to three significant figures. But it's important to realise that this can't be the right answer and perhaps you can see why not. We assumed that m was between 0 and 2 and now we've got an answer which isn't between 0 and 2. So in fact our assumption must have been wrong and actually m must be between 2 and 4. So in that case we need to solve a third of m minus 1 is equal to a half or in other words m minus 1 is equal to one and a half which means that m is 2 and a half. And this time you can see that we're all right. We assumed that m was between 2 and 4 and we've got an answer that's between 2 and 4. So m is equal to 2 and a half. The median is equal to 2 and a half. Okay now it's important to understand what just happened here. To begin with we were trying to find an answer which was between 0 and 2. We assumed that the median was between 0 and 2 and that's like trying to find a triangle like this whose area is equal to a half. But it turns out that you can't do that because even if you take the whole triangle up to where x is equal to 2 the area is still less than a half. You'd actually need to look at an even bigger triangle like this to get an area that's equal to a half. But obviously at x is equal to 2 the definition of the cumulative distribution function changes and so we can't have a triangle like this giving us a probability of a half. Instead we get a cumulative probability of a half by going into the region between x is equal to 2 and x is equal to 4. So we need to be careful here and be on the lookout for phantom answers that aren't really correct. A better way of tackling this question is actually to test at the very beginning whether the answer is between 0 and 2 and between 2 and 4. And the way to do this is to find the cumulative probability at 2. If we calculate f of 2 you'll see that it's a 12 times 2 squared which is a third and that's less than a half. So that means that when x is 2 we haven't got a large enough cumulative probability yet to reach the median. The median must be more than 2. And as soon as we know that the median is more than 2 we know we should be dealing with the case where x is between 2 and 4. And we can solve the equation exactly as we did before. Okay, so that's three examples of looking at finding the median of a continuously distributed random variable. I just want to end by talking about quartiles and quantiles more generally. So the median is the solution of f of m is equal to a half. And you can find the lower quartile in a very similar way. You just have to find the solution of f of q1 is equal to a quarter. You can find the upper quartile by solving f of q3 is equal to three quarters. And for example, you could find the third decile by solving f of d3 is equal to three tenths. Okay, that's the end of my video about finding the median of a continuously distributed random variable. The most important thing that you need to remember is that the median is the solution of f of m is equal to a half. Thank you very much for watching.