# Getting the upper and lower quartiles in data with an even number of observations, or where the quartile lands on a decimal number

I want to draw a box plot, which requires that I know the median, the lower and upper quartiles, and the minimum and maximum values of my data.

I understand that the quartiles are simply the value on certainly "percentile" of the cumulative frequency of the data.

So lower quartile = the value of the observation on the 25th percentile of the data. Now my question (for AQA GCSE prep) is - what if taking 25% of my data ends up in a decimal number, let's say, $3.5$. And my data consists of classes in a grouped frequency table. And two of my classes are:

$class 1$ || $2 <= h < 3.5$

$class 2$ || $3.5 <= h < 5$

So when I take 25% of 3.5 falls in between two classes. Which value should I choose as the lower quartile? Should it be $class 1$, or $class 2$? Should my rounding of 3.5 be the same as regular rounding is done, i.e. just rounding up to 4 (hence selecting $class 2$)? Or should I round choose $class 1$ for some reason?

If taking the $25$th percentile of the data gives you the value $3.5$, then the value of the first quartile is $3.5$. We would usually expect that the number of observations in each of your frequency classes is a whole number, but there is nothing wrong with having a quartile or median value that is not a whole number, so further rounding is neither needed nor desired.

If your data consist of the frequency of observations within each class, then the best that you can day is say that the quartile is somewhere within the class. To find out which class the quartile belongs to, you need to first figure out the index of the quartile. For example, if you have 100 observations in your dataset, then the median would be the average of the 50th and the 51st observations of your dataset. You would then need to find which class contains both the 50th and 51st observations by examining the cumulative frequencies. Perhaps the cumulative frequency for class 2 is 45 and the cumulative frequency for class 3 is 55. Then you would know that the 50th and 51st observations were in class 3, so the median would be in class 3.

Intro textbooks tend to use one of two different methods for boxplot/five number summary construction, in my experience.

The first method is to apply your percentile to the total number of observations; for example, the first quartile of 14 data points ordered least to greatest is the data value located in position $14*(0.25)= 3.5;$ that is, your fourth quartile is the value in the "3.5th place."

Well, there's no such thing as the "three point fifth place," so the first method has you round up to the nearest larger integer; this means you round this "place value calculation" up when you have a nonzero decimal in your computation (even if normal rounding rules would have you round down). In this case, 3.5 rounds up to 4, so the first quartile is whatever data value is in 4th place in the list of 14 data values ordered least to greatest. This method, if defined this way in your text, is good to use for finding any percentile: for instance, the 80th percentile is $(.8)(14) = 11.2,$ or the 12th place, and the median or 50th percentile is $(.5)(14) = 7,$ which lacks a nonzero fractional part, indicating that the median is to be taken as the average of the 7th place and its "next door neighbor," the data value in 8th place.

The second method is slightly different; after finding median, you find the first quartile by taking the median of the values to the left of your median placement in your ordered list and you find the third quartile by taking the median of the data place values beyond the place value of your median. In this case, the boxplot for your 14-point data set would not change, but if it had, say, 13 elements instead, the median would be in place value $(0.5)(13) = 6.5$ or the 7th place, the first quartile is the median, then, of the first six values in the ordered list, meaning it is the average of the 3rd and 4th values in the ordered list (in the previous paragraph, the quartile would have been the value in place number $13*.25 = 3.25 \to 4$th place).

Double-check your text to see which applies to you, but it is likely one of these two ways unless I am expressing something in error above.