Category: Statistics Level: 301
IQR = Q3 - Q1; outlier if beyond Q3 + 1.5 IQR or Q1 - 1.5 IQR
Sort the data, split it at the median, and split each half again to get the quartiles. The box spans the middle half, whiskers reach the furthest ordinary values, and anything past 1.5 IQR from the box is flagged.
Write the 15 values from smallest to largest. Number the positions so the middle is easy to find.
n = 15
Position 8 sits in the middle, with 7 values on each side. Its value is the median, Q2.
Q2 = 11
Take the median of each half, leaving Q2 out. These are Q1 and Q3: a quarter of the data sits below Q1 and a quarter above Q3.
Q1 = 8, Q3 = 15
On a number line, draw a box from Q1 to Q3 with a line at the median. The box holds the middle half of the data; its width is the IQR.
IQR = 15 - 8 = 7
Step 1.5 IQR out from each end of the box. Values past these fences count as outliers.
8 - 1.5 × 7 = −2.5; 15 + 1.5 × 7 = 25.5
Whiskers run to the smallest and largest values inside the fences, 3 and 18. The 31 sits past the fence, so it gets its own dot. Somebody either aced it or typed it wrong.
whiskers 3 to 18; outlier 31
cd svg-generator python3 -m svgmath render box-plot --out /tmp/box-plot
Source: svgmath/diagrams/statistics.py