Track 2 · Describing Data · Lesson 5 of 11
Quartiles and percentiles
Calculate percentiles, quartiles and the interquartile range with the type 7 method, find a percentile rank, and explain why different software can report slightly different quartiles.
A pay review asks: what salary separates the lowest-paid 10% of staff from the rest, and what does the middle half of employees earn? Percentiles answer exactly that kind of question, and — unlike the mean — they are not dragged around by a handful of very high salaries.
The -th percentile is a value with (about) of the data at or below it and the rest above it. The median is the 50th percentile. The quartiles split the sorted data into four parts:
- , the first quartile = 25th percentile;
- = the median = 50th percentile;
- , the third quartile = 75th percentile.
The interquartile range is the width of the middle half of the data: a measure of spread that, like the median, ignores the extremes.
With a finite sample, a percentile usually falls between two observations, and there are several reasonable rules for where exactly. This course uses the most common one, Hyndman–Fan type 7 — the default in R, NumPy, and Excel's PERCENTILE.INC / QUARTILE.INC. All graded answers use it unless a question says otherwise.
- the -th smallest value (the -th order statistic): sort the data first
- the proportion, e.g. for , for the 90th percentile
- the position in the sorted list; it runs from 1 (the minimum, ) to (the maximum, )
- rounded down; the fractional part says how far to move towards the next value
Worked example
Quartiles of ten delivery distances
Ten delivery distances (km), already sorted: 12, 15, 17, 20, 22, 25, 28, 31, 40, 55. Find , and the IQR.
: . Start at the 3rd value (17) and go a quarter of the way to the 4th (20): km.
: . Start at the 7th value (28) and go three quarters of the way to the 8th (31): km.
IQR km. The middle half of the deliveries span 12.5 km. The median () is km.
Q1 = 17.75 km, Q3 = 30.25 km, IQR = 12.5 km (type 7).
Show the data as a table
| Monthly base salary (SAR) | Monthly base salary |
|---|---|
| 6630 | 0.00166667 |
| 7090 | 0.00333333 |
| 7110 | 0.005 |
| 7130 | 0.00666667 |
| 7270 | 0.00833333 |
| 7280 | 0.0116667 |
| 7300 | 0.0133333 |
| 7380 | 0.0166667 |
| 7400 | 0.0183333 |
| 7420 | 0.02 |
| 7450 | 0.0216667 |
| 7510 | 0.0233333 |
| 7530 | 0.0266667 |
| 7540 | 0.0283333 |
| 7550 | 0.03 |
| 7590 | 0.0333333 |
| 7640 | 0.035 |
| 7720 | 0.0383333 |
| 7740 | 0.0433333 |
| 7780 | 0.0483333 |
| 7790 | 0.0516667 |
| 7810 | 0.0533333 |
| 7820 | 0.055 |
| 7850 | 0.0583333 |
| 7860 | 0.06 |
| 7910 | 0.0616667 |
| 7950 | 0.065 |
| 7980 | 0.07 |
| 8030 | 0.0716667 |
| 8040 | 0.0733333 |
| 8060 | 0.0783333 |
| 8090 | 0.08 |
| 8100 | 0.0816667 |
| 8110 | 0.085 |
| 8130 | 0.0883333 |
| 8140 | 0.09 |
| 8150 | 0.0916667 |
| 8180 | 0.0933333 |
| 8200 | 0.095 |
| 8210 | 0.0966667 |
| 8260 | 0.0983333 |
| 8270 | 0.1 |
| 8290 | 0.103333 |
| 8300 | 0.108333 |
| 8320 | 0.11 |
| 8330 | 0.113333 |
| 8340 | 0.115 |
| 8350 | 0.116667 |
| 8360 | 0.118333 |
| 8380 | 0.12 |
| 8390 | 0.121667 |
| 8400 | 0.123333 |
| 8410 | 0.125 |
| 8430 | 0.126667 |
| 8450 | 0.128333 |
| 8460 | 0.133333 |
| 8470 | 0.135 |
| 8490 | 0.136667 |
| 8500 | 0.138333 |
| 8510 | 0.14 |
| 8540 | 0.141667 |
| 8550 | 0.143333 |
| 8560 | 0.145 |
| 8570 | 0.146667 |
| 8580 | 0.148333 |
| 8590 | 0.15 |
| 8680 | 0.151667 |
| 8690 | 0.153333 |
| 8720 | 0.156667 |
| 8730 | 0.158333 |
| 8740 | 0.161667 |
| 8850 | 0.163333 |
| 8880 | 0.165 |
| 8890 | 0.166667 |
| 8900 | 0.168333 |
| 8930 | 0.17 |
| 8950 | 0.173333 |
| 8980 | 0.176667 |
| 9000 | 0.18 |
| 9010 | 0.181667 |
| 9050 | 0.183333 |
| 9060 | 0.185 |
| 9080 | 0.186667 |
| 9090 | 0.188333 |
| 9150 | 0.19 |
| 9180 | 0.191667 |
| 9190 | 0.193333 |
| 9220 | 0.198333 |
| 9240 | 0.201667 |
| 9270 | 0.203333 |
| 9280 | 0.205 |
| 9340 | 0.206667 |
| 9350 | 0.208333 |
| 9370 | 0.21 |
| 9400 | 0.211667 |
| 9440 | 0.213333 |
| 9460 | 0.215 |
| 9490 | 0.218333 |
| 9530 | 0.22 |
| 9540 | 0.221667 |
| 9550 | 0.225 |
| 9560 | 0.226667 |
| 9570 | 0.228333 |
| 9600 | 0.231667 |
| 9630 | 0.233333 |
| 9680 | 0.235 |
| 9710 | 0.236667 |
| 9730 | 0.238333 |
| 9740 | 0.24 |
| 9780 | 0.241667 |
| 9800 | 0.245 |
| 9810 | 0.246667 |
| 9830 | 0.248333 |
| 9850 | 0.25 |
| 9860 | 0.251667 |
| 9890 | 0.253333 |
| 9900 | 0.255 |
| 9910 | 0.256667 |
| 9930 | 0.261667 |
| 10080 | 0.263333 |
| 10120 | 0.268333 |
| 10140 | 0.27 |
| 10180 | 0.273333 |
| 10300 | 0.275 |
| 10340 | 0.278333 |
| 10360 | 0.28 |
| 10370 | 0.281667 |
| 10400 | 0.283333 |
| 10410 | 0.285 |
| 10460 | 0.286667 |
| 10480 | 0.288333 |
| 10550 | 0.29 |
| 10590 | 0.291667 |
| 10620 | 0.293333 |
| 10630 | 0.295 |
| 10740 | 0.296667 |
| 10770 | 0.298333 |
| 10800 | 0.3 |
| 10850 | 0.301667 |
| 10860 | 0.306667 |
| 10880 | 0.308333 |
| 10900 | 0.31 |
| 10910 | 0.311667 |
| 10920 | 0.313333 |
| 10960 | 0.316667 |
| 10980 | 0.318333 |
| 10990 | 0.32 |
| 11060 | 0.321667 |
| 11080 | 0.323333 |
| 11100 | 0.325 |
| 11130 | 0.326667 |
| 11150 | 0.328333 |
| 11170 | 0.331667 |
| 11210 | 0.333333 |
| 11230 | 0.338333 |
| 11270 | 0.34 |
| 11290 | 0.341667 |
| 11300 | 0.343333 |
| 11330 | 0.345 |
| 11350 | 0.346667 |
| 11380 | 0.351667 |
| 11390 | 0.353333 |
| 11410 | 0.355 |
| 11430 | 0.356667 |
| 11450 | 0.358333 |
| 11490 | 0.361667 |
| 11510 | 0.363333 |
| 11550 | 0.365 |
| 11560 | 0.368333 |
| 11570 | 0.37 |
| 11610 | 0.371667 |
| 11630 | 0.373333 |
| 11660 | 0.375 |
| 11700 | 0.376667 |
| 11710 | 0.378333 |
| 11720 | 0.38 |
| 11770 | 0.381667 |
| 11790 | 0.386667 |
| 11830 | 0.39 |
| 11860 | 0.391667 |
| 11900 | 0.395 |
| 11910 | 0.396667 |
| 11930 | 0.398333 |
| 11950 | 0.401667 |
| 11960 | 0.405 |
| 11980 | 0.41 |
| 11990 | 0.411667 |
| 12000 | 0.413333 |
| 12020 | 0.415 |
| 12070 | 0.416667 |
| 12120 | 0.42 |
| 12170 | 0.421667 |
| 12190 | 0.423333 |
| 12200 | 0.425 |
| 12210 | 0.426667 |
| 12300 | 0.428333 |
| 12310 | 0.431667 |
| 12320 | 0.433333 |
| 12370 | 0.435 |
| 12380 | 0.436667 |
| 12450 | 0.438333 |
| 12460 | 0.44 |
| 12490 | 0.441667 |
| 12540 | 0.443333 |
| 12550 | 0.445 |
| 12590 | 0.446667 |
| 12610 | 0.451667 |
| 12630 | 0.453333 |
| 12640 | 0.455 |
| 12680 | 0.456667 |
| 12690 | 0.461667 |
| 12740 | 0.463333 |
| 12770 | 0.465 |
| 12790 | 0.466667 |
| 12800 | 0.47 |
| 12820 | 0.471667 |
| 12830 | 0.476667 |
| 12840 | 0.478333 |
| 12870 | 0.48 |
| 12900 | 0.481667 |
| 12930 | 0.485 |
| 12970 | 0.486667 |
| 12980 | 0.488333 |
| 13000 | 0.49 |
| 13010 | 0.491667 |
| 13080 | 0.493333 |
| 13090 | 0.496667 |
| 13140 | 0.5 |
| 13150 | 0.501667 |
| 13160 | 0.503333 |
| 13240 | 0.505 |
| 13250 | 0.51 |
| 13260 | 0.511667 |
| 13280 | 0.513333 |
| 13290 | 0.516667 |
| 13310 | 0.518333 |
| 13340 | 0.521667 |
| 13350 | 0.523333 |
| 13420 | 0.525 |
| 13430 | 0.526667 |
| 13440 | 0.528333 |
| 13450 | 0.53 |
| 13460 | 0.531667 |
| 13480 | 0.533333 |
| 13490 | 0.535 |
| 13500 | 0.536667 |
| 13510 | 0.538333 |
| 13540 | 0.541667 |
| 13590 | 0.543333 |
| 13620 | 0.545 |
| 13660 | 0.546667 |
| 13690 | 0.548333 |
| 13760 | 0.551667 |
| 13780 | 0.553333 |
| 13800 | 0.555 |
| 13840 | 0.556667 |
| 13850 | 0.558333 |
| 13900 | 0.56 |
| 13950 | 0.561667 |
| 13960 | 0.563333 |
| 14020 | 0.565 |
| 14040 | 0.566667 |
| 14150 | 0.57 |
| 14160 | 0.571667 |
| 14180 | 0.573333 |
| 14220 | 0.575 |
| 14240 | 0.576667 |
| 14310 | 0.578333 |
| 14320 | 0.58 |
| 14350 | 0.581667 |
| 14360 | 0.583333 |
| 14370 | 0.585 |
| 14400 | 0.586667 |
| 14410 | 0.588333 |
| 14440 | 0.59 |
| 14470 | 0.593333 |
| 14520 | 0.595 |
| 14540 | 0.596667 |
| 14760 | 0.598333 |
| 14790 | 0.6 |
| 14820 | 0.601667 |
| 14950 | 0.603333 |
| 14980 | 0.605 |
| 15100 | 0.608333 |
| 15110 | 0.61 |
| 15130 | 0.611667 |
| 15160 | 0.613333 |
| 15250 | 0.615 |
| 15260 | 0.616667 |
| 15350 | 0.618333 |
| 15370 | 0.62 |
| 15380 | 0.623333 |
| 15390 | 0.625 |
| 15400 | 0.626667 |
| 15420 | 0.628333 |
| 15450 | 0.63 |
| 15460 | 0.631667 |
| 15490 | 0.633333 |
| 15500 | 0.635 |
| 15520 | 0.636667 |
| 15600 | 0.638333 |
| 15650 | 0.64 |
| 15720 | 0.641667 |
| 15740 | 0.643333 |
| 15790 | 0.645 |
| 15830 | 0.646667 |
| 15840 | 0.648333 |
| 15860 | 0.65 |
| 16200 | 0.651667 |
| 16250 | 0.653333 |
| 16410 | 0.655 |
| 16540 | 0.656667 |
| 16560 | 0.658333 |
| 16610 | 0.66 |
| 16740 | 0.661667 |
| 16770 | 0.663333 |
| 16790 | 0.665 |
| 16850 | 0.666667 |
| 16860 | 0.668333 |
| 16880 | 0.671667 |
| 16890 | 0.673333 |
| 16900 | 0.675 |
| 16920 | 0.676667 |
| 16930 | 0.678333 |
| 16940 | 0.68 |
| 16950 | 0.681667 |
| 16960 | 0.685 |
| 17000 | 0.688333 |
| 17040 | 0.69 |
| 17140 | 0.691667 |
| 17170 | 0.693333 |
| 17230 | 0.695 |
| 17260 | 0.696667 |
| 17360 | 0.698333 |
| 17430 | 0.7 |
| 17460 | 0.701667 |
| 17630 | 0.703333 |
| 17750 | 0.705 |
| 17790 | 0.706667 |
| 17820 | 0.708333 |
| 17910 | 0.71 |
| 17940 | 0.711667 |
| 17970 | 0.713333 |
| 18030 | 0.715 |
| 18040 | 0.716667 |
| 18090 | 0.718333 |
| 18170 | 0.72 |
| 18180 | 0.721667 |
| 18320 | 0.723333 |
| 18430 | 0.725 |
| 18490 | 0.726667 |
| 18550 | 0.728333 |
| 18580 | 0.73 |
| 18680 | 0.731667 |
| 18730 | 0.733333 |
| 18810 | 0.735 |
| 18820 | 0.736667 |
| 18930 | 0.738333 |
| 18970 | 0.741667 |
| 18980 | 0.743333 |
| 19030 | 0.745 |
| 19100 | 0.746667 |
| 19150 | 0.748333 |
| 19280 | 0.751667 |
| 19300 | 0.753333 |
| 19370 | 0.755 |
| 19400 | 0.756667 |
| 19470 | 0.758333 |
| 19550 | 0.76 |
| 19590 | 0.761667 |
| 19610 | 0.765 |
| 19630 | 0.766667 |
| 19720 | 0.768333 |
| 19730 | 0.771667 |
| 19810 | 0.773333 |
| 19850 | 0.775 |
| 19930 | 0.776667 |
| 19970 | 0.778333 |
| 20110 | 0.78 |
| 20120 | 0.781667 |
| 20160 | 0.783333 |
| 20260 | 0.785 |
| 20360 | 0.786667 |
| 20390 | 0.788333 |
| 20480 | 0.79 |
| 20490 | 0.791667 |
| 20540 | 0.793333 |
| 20560 | 0.795 |
| 20690 | 0.796667 |
| 20840 | 0.798333 |
| 20880 | 0.8 |
| 20930 | 0.801667 |
| 20940 | 0.803333 |
| 21000 | 0.805 |
| 21120 | 0.806667 |
| 21280 | 0.808333 |
| 21480 | 0.81 |
| 21510 | 0.811667 |
| 21570 | 0.813333 |
| 21610 | 0.815 |
| 21760 | 0.816667 |
| 21780 | 0.818333 |
| 21860 | 0.82 |
| 22040 | 0.821667 |
| 22050 | 0.823333 |
| 22110 | 0.825 |
| 22130 | 0.826667 |
| 22160 | 0.828333 |
| 22170 | 0.83 |
| 22370 | 0.831667 |
| 22540 | 0.833333 |
| 22610 | 0.835 |
| 22780 | 0.836667 |
| 23310 | 0.838333 |
| 23530 | 0.84 |
| 23620 | 0.841667 |
| 23710 | 0.843333 |
| 23800 | 0.845 |
| 24160 | 0.846667 |
| 24360 | 0.848333 |
| 25060 | 0.85 |
| 25330 | 0.851667 |
| 25410 | 0.853333 |
| 25440 | 0.855 |
| 25590 | 0.856667 |
| 25600 | 0.858333 |
| 25670 | 0.86 |
| 25820 | 0.863333 |
| 25860 | 0.865 |
| 26610 | 0.866667 |
| 26920 | 0.868333 |
| 27120 | 0.87 |
| 27180 | 0.871667 |
| 27260 | 0.873333 |
| 27560 | 0.875 |
| 27720 | 0.878333 |
| 27730 | 0.88 |
| 27750 | 0.881667 |
| 27790 | 0.883333 |
| 27840 | 0.885 |
| 27910 | 0.886667 |
| 28030 | 0.888333 |
| 28290 | 0.89 |
| 28370 | 0.891667 |
| 28400 | 0.893333 |
| 28430 | 0.895 |
| 28460 | 0.896667 |
| 28590 | 0.898333 |
| 28880 | 0.9 |
| 28960 | 0.901667 |
| 28980 | 0.903333 |
| 29020 | 0.905 |
| 29170 | 0.906667 |
| 29280 | 0.908333 |
| 29350 | 0.91 |
| 29440 | 0.911667 |
| 29450 | 0.913333 |
| 29550 | 0.915 |
| 29680 | 0.916667 |
| 30090 | 0.918333 |
| 30120 | 0.921667 |
| 30330 | 0.923333 |
| 30370 | 0.925 |
| 30470 | 0.926667 |
| 30740 | 0.928333 |
| 30780 | 0.93 |
| 30960 | 0.931667 |
| 31270 | 0.933333 |
| 31690 | 0.935 |
| 32350 | 0.936667 |
| 32390 | 0.938333 |
| 32840 | 0.94 |
| 33170 | 0.941667 |
| 33740 | 0.943333 |
| 34370 | 0.945 |
| 35230 | 0.946667 |
| 35240 | 0.948333 |
| 37750 | 0.95 |
| 38710 | 0.951667 |
| 39460 | 0.953333 |
| 40550 | 0.955 |
| 42320 | 0.956667 |
| 42390 | 0.958333 |
| 44050 | 0.96 |
| 44160 | 0.961667 |
| 44700 | 0.963333 |
| 44740 | 0.966667 |
| 44870 | 0.968333 |
| 45460 | 0.97 |
| 45820 | 0.971667 |
| 46020 | 0.973333 |
| 46590 | 0.975 |
| 46860 | 0.976667 |
| 46870 | 0.978333 |
| 47070 | 0.98 |
| 47310 | 0.981667 |
| 48310 | 0.983333 |
| 48520 | 0.985 |
| 49110 | 0.986667 |
| 50090 | 0.988333 |
First 500 of 507 rows.
| P10 | Q1 (P25) | Median (P50) | Q3 (P75) | P90 | IQR |
|---|---|---|---|---|---|
| 8 288 | 9 857.5 | 13 145 | 19 280 | 28 888 | 9 422.5 |
Read it like this: 10% of employees earn 8 288 SAR or less a month, and 10% earn 28 888 SAR or more; the middle half earn between 9 857.5 and 19 280 SAR. The gap from the median up to Q3 (6 135 SAR) is much larger than from Q1 to the median (3 287.5 SAR) — the percentiles reveal the right skew directly.
A percentile rank runs the other way: given a value, what percentage of the data lies below it? About 78% of these employees earn less than 20 000 SAR, so 20 000 SAR has a percentile rank of about 78. (Definitions differ slightly when the value itself occurs in the data — some count values at or below, some count half of the ties; with no ties, they agree.)
Quick check
For 600 salaries, Q1 = 9 857.5 SAR and Q3 = 19 280 SAR. Roughly how many employees earn between them?
Exercises
The lesson is complete when every exercise is answered correctly. Hints are free; viewing a worked solution before solving means the exercise won't count towards mastery.
0 of 8 exercises correct (not saved — sign in to keep your progress)
Exercise 1 · Guided, difficulty 1 of 3
First quartile by interpolation
Twelve trainees' assessment scores are:
46, 79, 83, 53, 29, 38, 37, 34, 86, 32, 63, 69
Find the first quartile using the type 7 method (position ). Give your answer to 2 decimal places.
Exercise 2 · Practice, difficulty 2 of 3
Quartiles and IQR
A pharmacy logged the time (minutes) to fill ten prescriptions:
68, 18, 98, 81, 41, 47, 42, 88, 34, 64
Using the type 7 method, find , and the interquartile range. Give each to 2 decimal places.
Exercise 3 · Practice, difficulty 2 of 3
The 90th percentile
A help desk measured the resolution time (minutes) of 15 tickets:
395, 137, 173, 409, 121, 145, 376, 436, 205, 258, 420, 303, 371, 457, 282
The service target is set at the 90th percentile. Find it with the type 7 method, to 1 decimal place.
Exercise 4 · Application, difficulty 2 of 3
The salary distribution in percentiles
Using base_salary_sar in the salaries dataset (600 employees), calculate the 10th percentile, the median and the 90th percentile (type 7), and the ratio — a common measure of pay dispersion. Give the percentiles in SAR to the nearest whole riyal and the ratio to 2 decimal places.
Data: salaries · Open in the lab to explore and calculate.
Exercise 5 · Practice, difficulty 2 of 3
Percentile rank
Twenty applicants took an aptitude test. Their scores were:
75, 92, 81, 97, 74, 96, 45, 68, 65, 78, 41, 70, 69, 44, 43, 82, 87, 86, 42, 83
A new applicant scores 72.5. Compared with these twenty, what is the percentile rank of that score — the percentage of the twenty scores that are below it?
Exercise 6 · Interpretation, difficulty 2 of 3
Two answers for the same quartile
An analyst computes of eleven invoice amounts in R and gets 412.5 SAR. A colleague uses Excel's QUARTILE.EXC on the same data and gets 395 SAR. What is the best explanation?
Exercise 7 · Practice, difficulty 1 of 3
Percentile vocabulary
Match each term to its meaning.
Exercise 8 · Interpretation, difficulty 2 of 3
Explaining a pay percentile
An HR letter tells an employee: “Your base salary is at the 75th percentile for your job level.” The employee asks whether this means they earn 75% of the top salary. In two or three sentences, explain what the statement does and does not mean.
What you can now do
- Calculate any percentile, the quartiles and the IQR with the type 7 method
- Find the percentile rank of a value
- Explain why R, Excel .INC/.EXC and other tools may report different quartiles
- Describe a skewed distribution with percentiles in plain language