# Do you include the median in calculating the upper and lower quartiles?

My statistics teacher failed me on a quiz because I did not include the median in calculating upper and lower quartiles. Here is the data set:

23, 32, 33, 47, 40, 43, 44, 47, 52

Median: 40 Q1: 32.5 Q3: 45.5

She claims you include the 40 in both quartiles.

• Did you intend to say $23, 32, 33, 37, 40, 43, 44, 47, 52$? Sep 6, 2020 at 23:50
• There are several different ways of stating quartiles and quantiles. Your $32.5$ and $45.5$ correspond to method 1 in the first link and R-6 in the second. Your teacher's presumably $33$ and $44$ correspond to method 2 in the first link and R-1, R-2 and R-7 in the second. It is difficult to say one is correct and the other wrong, but your teacher may know what is expected in any future test or exam, and so you might be wise to follow your teacher Sep 7, 2020 at 0:02
• A multitude of rules for sample quantiles exist (and quantile-like quantities, such as fourths/hinges). For your performance on a quiz or test, what we might use matters less than what rule your class has established. Sep 7, 2020 at 0:06
• rdocumentation.org/packages/stats/versions/3.6.2/topics/… The R documentation describes nine different ways to calculate quantiles (percentiles, more or less). If you have a convention in your class, stick with it.
– Dave
Sep 7, 2020 at 0:17
• Other way round, negative marks to the teacher if they did not explain that there are several different methods which usually give similar but not necessarily identical answers. This point arises often even at the most elementary or introductory level and students (and professionals too) are quite likely to be puzzled, e.g. if they are expected to use software X but fall back on software Y as more accessible or familiar, and get different results. (And nobody even mentioned what happens when you have weights too...) Sep 7, 2020 at 9:06

Comment: Following @Dave's Comment, here are some of the different outputs for the quantiles in R. I was motivated to list them because it seems none of them match the values you give for the quartiles. It is not possible to divide nine observations into four 'quarters', so conventions need to be established how to get sensible quartiles. Each of the 'types' in R exists because there are people who think each one is 'best' for certain purposes.

Fortunately, quantiles are usually used in applications with much larger sample sizes, so that the minor differences in the definitions of quantiles do not often result in important differences in reported values.

While you are in your current statistics course, you should certainly follow the advice of @Henry and @Glen_b: Figure out your instructor's method and use it. After you get out of school, you can decide which 'type' of quantile is your favorite.

x = c(23, 32, 33, 47, 40, 43, 44, 47, 52)
sort(x)
[1] 23 32 33 40 43 44 47 47 52

quantile(x, type=1)
0%  25%  50%  75% 100%
23   33   43   47   52
quantile(x, type=2)
0%  25%  50%  75% 100%
23   33   43   47   52
quantile(x, type=3)
0%  25%  50%  75% 100%
23   32   40   47   52
quantile(x, type=4)
0%   25%   50%   75%  100%
23.00 32.25 41.50 46.25 52.00
quantile(x, type=5)
0%   25%   50%   75%  100%
23.00 32.75 43.00 47.00 52.00
quantile(x, type=6)
0%  25%  50%  75% 100%
23.0 32.5 43.0 47.0 52.0
quantile(x)  # 'type 7 is the default in R
0%  25%  50%  75% 100%
23   33   43   47   52
quantile(x, type=8)
0%      25%      50%      75%     100%
23.00000 32.66667 43.00000 47.00000 52.00000
quantile(x, type=9)
0%     25%     50%     75%    100%
23.0000 32.6875 43.0000 47.0000 52.0000