measure of statistical dispersion
statistics - Calculating interquartile range - Mathematics Stack Exchange
Interquartile range
Help interpreting an interquartile range (IQR)
[University statistics] What is the interquartile range of this data set?
What are the two main methods for calculating interquartile range?
How do you find the interquartile range?
When should I use the interquartile range?
Videos
Let's not confuse you with so much theories. Just calculate according to these steps:
- find the position of the Q1 and Q3
Q1 = (n+1)/4
Q3 = 3(n+1)/4
according to your question:
Q1 = (18+1)/4 = 4.75
Q3 = 3(18+1)/4 = 14.25
- Now what you get from above is just the position
{0, 1, 2, 5, 8, 8, 9, 10, 12, 14, 18, 20, 21, 23, 25, 27, 34, 43}
4.75 falls between 5 and 8
14.25 falls between and 23 and 25
- Now you interpolate using this formula
Q1 = 5 + 3/4(8-5) = 7.25 explanation: - 5 is the lower part taken from 5 and 8 (where the 4.75 falls within) - 3/4 is the 4.75 (convert from 0.75) - 8-5 is the 5 and 8 you got from previous step
Q3 = 23 + 1/4(25-23) = 23.5
As the varied answers indicate, extracting quantiles is something of an inexact science when you have few enough samples that the rounding between two neighbor samples matters.
A bit abstractly expressed, you have tabulated values for $f(1)$, $f(2)$, ... $f(18)$, but getting from there to actual quartiles requires at least two semi-arbitrary choices:
How do we define values of $f$ for non-integral arguments when "a quarter way through the sample set" happens not to hit one particular sample exactly? Linear interpolation between neighbor samples is a popular choice, but it seems that Wolfram Alpha instead extends $f$ to a step function. Even step functions can be done in different ways: round up? round down? round to nearest? In the latter case, what about the point exactly halfway between samples?
What is actually the interval that we want to find quarter-way points in? One natural choice is $[1,18]$, which makes the zeroth and fourth quartile exactly the minimum and maximum. But a different natural choice is $[0.5, 18.5]$ such that each sample counts for the same amount of x-axis. In the latter case there is a risk that one will have to find $f(x)$ for $x<1$ or $x>18$, where a linear interpolation does not make sense. More decisions to make then.
It looks like your book is using yet a third interval, namely $[0, 19]$! Then, by linear interpolation, we get $$Q1 = f(4.75) = 5+0.75\times(8-5) = 7.25$$ $$Q3 = f(14.25) = 23+0.25\times(25-23) = 23.5$$
I'm not sure how you get your own suggestions for quartiles. Since you divide 18 by 4, I assume you use an interval of length 18, but if you're using linear interpolation, you compute Q1 as $f(4.5)$ and Q2 as $f(9.5)$, with a distance of only 4 rather than 4.5. Or are you completing $f$ such that every non-integral $x$ maps to the midpoint between neighbor samples?