So we've talked about different ways to measure the center of a data set and the spread of that data
set.
Now we want to talk about the quartiles and I.Q. R or interquartile range of a data set so that we can
understand what they can tell us about our data.
So the easiest way to explain quartiles and IQ is to look at a data set.
Let's say that we have this data set here.
There are 18 values in this set, ranging from 66 to 75.
And we're going to say that this data represents the golf score of 18 golfers.
So maybe the golf course is a par 72 course.
The best golfer shot a 66 and the worst golfer shot a 75.
So we have 18 golfers.
This is our data set.
And the first thing we want to say is that this idea of a quartile is related to what we already know
about the median of the data set.
So if you remember when we talked about median, we talked about it as the center of the set.
When we ordered the set from smallest to largest and found the center value.
So let's start there.
Let's think about the median.
If we look at this data set, there are 18 values in the set, as we said.
And so we have here the lower nine values and the upper nine values.
Therefore, we know that the median is found by taking the mean of these two center values here.
So if we take the mean of these two values, we would add 69 and 69 and then divide by two.
And of course, the result there will be 69.
So the median here of this data set is 69.
Now, when we talk about the quartiles of a data set, we usually talk about the first, second and
third quartiles.
And in general, just at a broad level, you want to think about the first quartile as the median of
this lower half of the data.
You want to think about the third quartile as the median of the upper half of the data.
And you want to think about the second quartile as being equal to the median.
So we can refer to the first quartile sometimes as Q one, sometimes we'll refer to it as the first
quartile or the lower quartile.
So we'll call it the first quartile or we'll call it the lower quartile.
We can also think about it as the.
25th percentile of the data.
On the other hand, the third quartile will often call it Q three or the third quartile.
So instead of the first, we'll call it the third or we'll call it the upper quartile and we can think
about it also as the 75th percentile of the data.
And then the median here we call that the second quartile or Q two.
So Q Two or the second quartile instead of the lower or the upper quartile, we would say that this
is the median because the second quartile is equal to the median.
And we would also refer to this as the 50th percentile because in the same way that the median divides,
the lower half of the data from the upper half of the data, meaning that 50% of the data points will
fall below the median and 50% of the data points will fall above the median.
And therefore it's the 50th percentile.
In that same way, 25% of the data points will fall below the first quartile, whereas 75% of the data
points will fall below the third quartile or below the upper quartile.
So the upper quartile divides the lower 75% of the data points from the upper 25% of the data points.
The first quartile divides the lower 25% of the data points from the upper 75% of the data points.
So these are our three quartiles.
And one of the reason that these values are interesting to us is because they lead us to what we call
a five number summary.
And the five number summary gives us a really good picture of the center and the spread of the data
set at the same time.
So in the past we looked at the center of the data set as mean median or mode, and then we looked separately
at the spread of the data set as the variance or standard deviation.
But the five number summary kind of gives us a picture of both the center and the spread at the same
time.
So that five number summary is always going to include the same five values.
It will include the minimum and maximum values from the data set.
So the lowest value and the largest value.
In the case of this data set, of course, that's 66 for the minimum value here and 75 for the maximum
value.
It will include the median, which of course we're already familiar with.
And for this data set, we already calculated that that median was 69 and then it'll include the first
and third quartile or the lower quartile and the upper quartile and without even calculating the lower
and upper quartiles for this particular data set, you can already start to get a sense that this five
number summary gives us a pretty good picture of the center and spread of the data set, because not
only do we have the median as the center and we get the full range from the minimum to the maximum value,
let's go ahead and say while we're at it, that we define the range of a data set as being equal to
the maximum value minus the minimum value.
So in this case, the range of the data set is 75.
-66 or in our case, a range of nine.
So we get the minimum, the maximum, the total range.
We can see the center as the median.
And these Q one and Q three values.
Give us a picture of the middle 50% of the data set because we know everything below.
Q One below the first quartile is the first 25% of the values in the set, and we know everything above.
Q Three is the last 25% or the greatest 25% of the values in the set, but everything between Q one
and Q three between the first and third quartiles represents that middle 50% of the data set of the
values in the data set.
And so those two values taken together.
Q one and Q three.
Give us a little bit of a picture of how tightly clustered the data is around the median.
If the difference between Q one and Q three is fairly small, then we know that most of the data is
tightly clustered around the median.
But if the difference between Q one and Q three is large, then we know that the data is more spread
out.
So this five number summary given by these quartiles here is just another way to get a sense of what
our data set is doing now while we're here.
Let's go ahead and talk about how to calculate these quartile values.
We already know how to calculate the second quartile because it's equal to the median and we know how
to find the median.
But how do we find.
Q one and Q three.
Well, the answer to that is a little nuanced, because technically there are different ways of calculating
the first and the third quartile, and they're not always going to give exactly the same answer.
There's no universally agreed upon method for finding the exact value of Q one and Q three.
Just know that any accepted method we use is still going to give us a good approximation of what Q one
and Q three actually are one of the methods you can use for calculating these two quartiles?
And maybe the most straightforward one is to start by considering whether the original data set has
an even or an odd number of data points.
So in this case, this data set has 18 data points.
So we have a data set with an even number of data points.
If there are an even number of data points in the original set, then of course we already know, as
we saw here, that the median is going to be found by taking the mean of these two numbers in the center,
because with an even number of data points, the data is going to split into two halves perfectly.
In this case, we have nine values in the lower half and nine values in the upper set.
So of course, the median is going to be found by taking the mean of these two middle numbers.
And then in order to find the first and third quartile, we can just look at each half of the data set
and find the median of the lower and upper halves.
So if we just look at the lower half here, starting with this lowest value, 66 and going up to this
69 value right here, there are nine values.
Now in this lower half, we can consider the median of these nine values.
Well, of course, if we have nine values and we're looking for the median, we know we're going to
have four values on the low side of this half for values on the high side of this half.
And then the median is this fifth value in the center right here, 68.
And then we would consider the same thing with the upper half.
The upper half contains nine data points ranging from this 69 value right here up to 75.
So if we ignore the first four data points, 69, 69, 70 and 70, and we ignore the last four data
points, 71, 72, 73 and 75, the median of this upper half is this value here, 71 and we can fill
in our five number summary and say 68 and 71.
Now once we have Q one and Q three, going back to what we said earlier about the five number summary,
the difference between the first and third quartiles gives us a picture of how spread out the data is
around the median, because what this five number summary tells us is that 50% of all of the values
in the data set fall between 68 and 71 around a median of 69.
That gives us a sense of how tightly clustered the data is around the median.
And that value is important.
That's the interquartile range that we mentioned at the beginning.
The IQR of a data set is equal to the difference between the third quartile and the first quartile.
So in our case, 71 for the third quartile -68 for the first quartile or three.
So the interquartile range of the IQR of this.
Particular data set is three.
It's Q three minus.
Q one the difference between the first and the third quartiles.
So that's what our five number summary looks like.
That's how we calculate.
Q one, Q three and the median, when we have an odd number of data points in our set.
But what about if we have an even number of data points in the set?
So this is the same data set except for the fact that we have removed one value of 68 from the set.
So now we have 17 golf scores instead of 18 golf scores.
We have an odd number of values in the data set and one common method for computing the first and the
third quartiles, when we have an odd number of data points, is to again first find the median.
So if we look at the lower and upper halves of the data because we have 17 values here in the set,
we've underlined the first eight and the last eight, leaving us with just this center value here of
69 as the median and one method for computing.
Q one and Q three when we have an odd number of data points, is just to exclude this median value when
we calculate Q one and Q three.
So excluding the median, we just look at this lower half of the data, these eight values here, and
we find the median of these eight values.
So looking at the median here, we have four values 66, 67, 67, 68, and then four values 68 through
69 here.
So the median should fall right here.
And we know, of course, that that means that we are taking the mean of these two values here.
And so the mean of these two is 68, and the first quartile will be 68 to find Q three, the upper quartile,
we consider just these eight values.
We know that the median should fall between the lower four values and the upper four values.
So right here and therefore we know that that means that we are taking the mean of these two values
and we get an upper quartile of 71.
So in this case, removing that value of 68 didn't change the value of the median or Q one or Q three.
All three values stayed the same.
But of course that won't always be the case.
So these methods that we showed here to calculate Q one and Q three when we had an even number of data
points, are an odd number of data points.
You can always use these methods.
They'll work, but other methods sometimes have us include this median value here when we calculate
Q one and Q three instead of excluding it as we did with our method.
Sometimes the method for an even number of data points up here, we'll have us calculate this median
and then include this median as if we had an extra value of 69 right here and then go ahead and find
the lower and upper quartile.
So there are slight differences, but as you can imagine, they're always going to produce fairly similar
results.
So the most important thing here is just understanding what the first and third quartiles are, how
they fit into this idea of a five number summary to give us an idea of the center and spread of the
data set and at least one method for calculating the three quartiles.
And of course we calculated these quartile values by hand, but we can also use computers to help us
find these values, especially as the data set gets larger.
For instance, you can use the quartile function in Excel to calculate any of the five values in the
five number summary The quartile function will just ask you for your array, which will be the range
of cells where you have your data set in the spreadsheet and then for the quartile that you want the
function to return.
And so you would enter the array and then either the number zero, if you want the minimum value, the
number one, if you want the first quartile or the numbers two, three or four, if you want the median
third quartile or maximum value of that array of that data set.
So instead of trying to do this by hand, if we had inputted this entire data set into Excel, we could
have used the quartile function, highlighted this data set, and then input the number one into the
function for Excel to return to us.
The first quartile 68 of this data set.
So the last thing we want to say is that it's very common for us to use this concept of quartiles to
identify outliers in the data set.
We talked a little bit about outliers before when we talked about measuring the center of a data set,
but determining which values in the set technically qualify as outliers can be more of an art than a
science.
But one method that people use is to.
Boy, these quartiles to give sort of benchmarks for outliers in the data set.
And so sometimes we will say that any value in the set that is lower than the first quartile -1.5 times
the IQ r of the data set will be an outlier in the data or similarly, any value that is larger than
the third quartile plus 1.5 times the IQ r that will consider any value larger than this value to be
an outlier on the upper end of the data.
So you can imagine with this data set right here, we said that the first quartile was equal to 68,
so let's say 68 and then we'll say -1.5 times the IQ r, which we calculated to be three.
So we have 68 -4.5, which gives us a value of 63.5.
And so by this method, if we choose to use this method for determining outliers, we would say that
any value less than 63.5 would be considered an outlier of this data set.
So if we have 66, 67, 67 all the way to 75, if this is our data set, anything less than 63 and a
half, we would consider an outlier.
And similarly on the high end, if we take Q three, which we know is 71 for this set, so 71 plus 1.5
times an IQ R of three is 71 plus 4.5 or 75.5.
So any value greater than 75.5 we could consider to be an outlier for this data set.
Again, this isn't some objective, universally accepted standard for outliers.
It's just one way that we could maybe set some parameters to start getting an idea for what would we
even consider an outlier on the low end or an outlier on the high end?
For a data set like this one, it sort of gives us some boundaries, Some gates around the data set,
a sense of which values are unusually low or unusually high given the rest of the data that we have.
So again, a lot that we can do with this concept of quartiles and interquartile range, but all of
this information is really just more context around the center and the spread of a data set.