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.

30 minFoundation8 graded exercisesFree

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 pp-th percentile is a value with (about) p%p\% 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:

  • Q1Q_1, the first quartile = 25th percentile;
  • Q2Q_2 = the median = 50th percentile;
  • Q3Q_3, the third quartile = 75th percentile.

The interquartile range IQR=Q3−Q1\text{IQR} = Q_3 - Q_1 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.

h=(n−1) p+1,Q(p)=x(⌊h⌋)+(h−⌊h⌋)(x(⌊h⌋+1)−x(⌊h⌋))h = (n - 1)\,p + 1, \qquad Q(p) = x_{(\lfloor h \rfloor)} + \big(h - \lfloor h \rfloor\big)\big(x_{(\lfloor h \rfloor + 1)} - x_{(\lfloor h \rfloor)}\big)
Percentile by the type 7 method (linear interpolation between order statistics)
x(k)x_{(k)}
the kk-th smallest value (the kk-th order statistic): sort the data first
pp
the proportion, e.g. p=0.25p = 0.25 for Q1Q_1, p=0.9p = 0.9 for the 90th percentile
hh
the position in the sorted list; it runs from 1 (the minimum, p=0p = 0) to nn (the maximum, p=1p = 1)
⌊h⌋\lfloor h \rfloor
hh rounded down; the fractional part h−⌊h⌋h - \lfloor h \rfloor 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 Q1Q_1, Q3Q_3 and the IQR.

  1. Q1Q_1: h=9×0.25+1=3.25h = 9 \times 0.25 + 1 = 3.25. Start at the 3rd value (17) and go a quarter of the way to the 4th (20): 17+0.25×3=17.7517 + 0.25 \times 3 = 17.75 km.

  2. Q3Q_3: h=9×0.75+1=7.75h = 9 \times 0.75 + 1 = 7.75. Start at the 7th value (28) and go three quarters of the way to the 8th (31): 28+0.75×3=30.2528 + 0.75 \times 3 = 30.25 km.

  3. IQR =30.25−17.75=12.5= 30.25 - 17.75 = 12.5 km. The middle half of the deliveries span 12.5 km. The median (h=5.5h = 5.5) is (22+25)/2=23.5(22 + 25)/2 = 23.5 km.

Q1 = 17.75 km, Q3 = 30.25 km, IQR = 12.5 km (type 7).

Step curve rising steeply between about 8 000 and 20 000 SAR and then slowly up to 63 600 SAR, showing a long right tail.Monthly base salary (SAR)Cumulative proportion
Empirical cumulative distribution of 600 monthly base salaries (salaries dataset). Read across from 0.25, 0.5 and 0.75 on the vertical axis to find Q1, the median and Q3.
Show the data as a table
Monthly base salary (SAR)Monthly base salary
66300.00166667
70900.00333333
71100.005
71300.00666667
72700.00833333
72800.0116667
73000.0133333
73800.0166667
74000.0183333
74200.02
74500.0216667
75100.0233333
75300.0266667
75400.0283333
75500.03
75900.0333333
76400.035
77200.0383333
77400.0433333
77800.0483333
77900.0516667
78100.0533333
78200.055
78500.0583333
78600.06
79100.0616667
79500.065
79800.07
80300.0716667
80400.0733333
80600.0783333
80900.08
81000.0816667
81100.085
81300.0883333
81400.09
81500.0916667
81800.0933333
82000.095
82100.0966667
82600.0983333
82700.1
82900.103333
83000.108333
83200.11
83300.113333
83400.115
83500.116667
83600.118333
83800.12
83900.121667
84000.123333
84100.125
84300.126667
84500.128333
84600.133333
84700.135
84900.136667
85000.138333
85100.14
85400.141667
85500.143333
85600.145
85700.146667
85800.148333
85900.15
86800.151667
86900.153333
87200.156667
87300.158333
87400.161667
88500.163333
88800.165
88900.166667
89000.168333
89300.17
89500.173333
89800.176667
90000.18
90100.181667
90500.183333
90600.185
90800.186667
90900.188333
91500.19
91800.191667
91900.193333
92200.198333
92400.201667
92700.203333
92800.205
93400.206667
93500.208333
93700.21
94000.211667
94400.213333
94600.215
94900.218333
95300.22
95400.221667
95500.225
95600.226667
95700.228333
96000.231667
96300.233333
96800.235
97100.236667
97300.238333
97400.24
97800.241667
98000.245
98100.246667
98300.248333
98500.25
98600.251667
98900.253333
99000.255
99100.256667
99300.261667
100800.263333
101200.268333
101400.27
101800.273333
103000.275
103400.278333
103600.28
103700.281667
104000.283333
104100.285
104600.286667
104800.288333
105500.29
105900.291667
106200.293333
106300.295
107400.296667
107700.298333
108000.3
108500.301667
108600.306667
108800.308333
109000.31
109100.311667
109200.313333
109600.316667
109800.318333
109900.32
110600.321667
110800.323333
111000.325
111300.326667
111500.328333
111700.331667
112100.333333
112300.338333
112700.34
112900.341667
113000.343333
113300.345
113500.346667
113800.351667
113900.353333
114100.355
114300.356667
114500.358333
114900.361667
115100.363333
115500.365
115600.368333
115700.37
116100.371667
116300.373333
116600.375
117000.376667
117100.378333
117200.38
117700.381667
117900.386667
118300.39
118600.391667
119000.395
119100.396667
119300.398333
119500.401667
119600.405
119800.41
119900.411667
120000.413333
120200.415
120700.416667
121200.42
121700.421667
121900.423333
122000.425
122100.426667
123000.428333
123100.431667
123200.433333
123700.435
123800.436667
124500.438333
124600.44
124900.441667
125400.443333
125500.445
125900.446667
126100.451667
126300.453333
126400.455
126800.456667
126900.461667
127400.463333
127700.465
127900.466667
128000.47
128200.471667
128300.476667
128400.478333
128700.48
129000.481667
129300.485
129700.486667
129800.488333
130000.49
130100.491667
130800.493333
130900.496667
131400.5
131500.501667
131600.503333
132400.505
132500.51
132600.511667
132800.513333
132900.516667
133100.518333
133400.521667
133500.523333
134200.525
134300.526667
134400.528333
134500.53
134600.531667
134800.533333
134900.535
135000.536667
135100.538333
135400.541667
135900.543333
136200.545
136600.546667
136900.548333
137600.551667
137800.553333
138000.555
138400.556667
138500.558333
139000.56
139500.561667
139600.563333
140200.565
140400.566667
141500.57
141600.571667
141800.573333
142200.575
142400.576667
143100.578333
143200.58
143500.581667
143600.583333
143700.585
144000.586667
144100.588333
144400.59
144700.593333
145200.595
145400.596667
147600.598333
147900.6
148200.601667
149500.603333
149800.605
151000.608333
151100.61
151300.611667
151600.613333
152500.615
152600.616667
153500.618333
153700.62
153800.623333
153900.625
154000.626667
154200.628333
154500.63
154600.631667
154900.633333
155000.635
155200.636667
156000.638333
156500.64
157200.641667
157400.643333
157900.645
158300.646667
158400.648333
158600.65
162000.651667
162500.653333
164100.655
165400.656667
165600.658333
166100.66
167400.661667
167700.663333
167900.665
168500.666667
168600.668333
168800.671667
168900.673333
169000.675
169200.676667
169300.678333
169400.68
169500.681667
169600.685
170000.688333
170400.69
171400.691667
171700.693333
172300.695
172600.696667
173600.698333
174300.7
174600.701667
176300.703333
177500.705
177900.706667
178200.708333
179100.71
179400.711667
179700.713333
180300.715
180400.716667
180900.718333
181700.72
181800.721667
183200.723333
184300.725
184900.726667
185500.728333
185800.73
186800.731667
187300.733333
188100.735
188200.736667
189300.738333
189700.741667
189800.743333
190300.745
191000.746667
191500.748333
192800.751667
193000.753333
193700.755
194000.756667
194700.758333
195500.76
195900.761667
196100.765
196300.766667
197200.768333
197300.771667
198100.773333
198500.775
199300.776667
199700.778333
201100.78
201200.781667
201600.783333
202600.785
203600.786667
203900.788333
204800.79
204900.791667
205400.793333
205600.795
206900.796667
208400.798333
208800.8
209300.801667
209400.803333
210000.805
211200.806667
212800.808333
214800.81
215100.811667
215700.813333
216100.815
217600.816667
217800.818333
218600.82
220400.821667
220500.823333
221100.825
221300.826667
221600.828333
221700.83
223700.831667
225400.833333
226100.835
227800.836667
233100.838333
235300.84
236200.841667
237100.843333
238000.845
241600.846667
243600.848333
250600.85
253300.851667
254100.853333
254400.855
255900.856667
256000.858333
256700.86
258200.863333
258600.865
266100.866667
269200.868333
271200.87
271800.871667
272600.873333
275600.875
277200.878333
277300.88
277500.881667
277900.883333
278400.885
279100.886667
280300.888333
282900.89
283700.891667
284000.893333
284300.895
284600.896667
285900.898333
288800.9
289600.901667
289800.903333
290200.905
291700.906667
292800.908333
293500.91
294400.911667
294500.913333
295500.915
296800.916667
300900.918333
301200.921667
303300.923333
303700.925
304700.926667
307400.928333
307800.93
309600.931667
312700.933333
316900.935
323500.936667
323900.938333
328400.94
331700.941667
337400.943333
343700.945
352300.946667
352400.948333
377500.95
387100.951667
394600.953333
405500.955
423200.956667
423900.958333
440500.96
441600.961667
447000.963333
447400.966667
448700.968333
454600.97
458200.971667
460200.973333
465900.975
468600.976667
468700.978333
470700.98
473100.981667
483100.983333
485200.985
491100.986667
500900.988333

First 500 of 507 rows.

P10Q1 (P25)Median (P50)Q3 (P75)P90IQR
8 2889 857.513 14519 28028 8889 422.5
Percentiles of monthly base salary (SAR) in the synthetic salaries dataset, type 7

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

Not started

Twelve trainees' assessment scores are:

46, 79, 83, 53, 29, 38, 37, 34, 86, 32, 63, 69

Find the first quartile Q1Q_1 using the type 7 method (position h=(n−1)p+1h = (n - 1)p + 1). Give your answer to 2 decimal places.

Exercise 2 · Practice, difficulty 2 of 3

Quartiles and IQR

Not started

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 Q1Q_1, Q3Q_3 and the interquartile range. Give each to 2 decimal places.

Exercise 3 · Practice, difficulty 2 of 3

The 90th percentile

Not started

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

Not started

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 P90/P10P_{90}/P_{10} — 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

Not started

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

Not started

An analyst computes Q1Q_1 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?

Choose one

Exercise 7 · Practice, difficulty 1 of 3

Percentile vocabulary

Not started

Match each term to its meaning.

Q1Q_1
Median
Q3Q_3
IQR
Percentile rank of a value

Exercise 8 · Interpretation, difficulty 2 of 3

Explaining a pay percentile

Not started

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.

0 words

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