With the mean and the standard deviation you can already describe the center and the width of your data. But Marta rarely asks about "the data in general"; she asks about specific cases: "Is an order that took 36 hours normal, or is it an incident?", "Is this member among our biggest spenders?", "Is that €3,240 receipt real, or did someone mistype?". To answer, you need to know where a value falls within the data set: that is what the measures of position do (quartiles, deciles, percentiles and z-scores) and, with them, the rules for detecting outliers. In this lesson you will learn how to compute them, how to read a box plot and, above all, how to decide what to do when a suspicious data point shows up — a decision that connects directly with the data quality issues you saw in Types of Data.
Contents
- The idea of relative position
- Quartiles
- Deciles and percentiles
- The interquartile range (IQR)
- The box plot
- Outlier detection: the 1.5×IQR rule
- Z-scores: position in units of standard deviation
- What do I do with an outlier?
The idea of relative position
An isolated data point says almost nothing: is a 36-hour delivery a lot? It depends on how the other deliveries are distributed. The measures of position answer by sorting the data from smallest to largest and locating cut-points that split the set into parts holding the same number of observations:
| Measure | Splits the data into… | Cut-points |
|---|---|---|
| Median | 2 halves | 1 (the 50% mark) |
| Quartiles | 4 quarters | 3 (Q1, Q2, Q3) |
| Deciles | 10 tenths | 9 (D1 … D9) |
| Percentiles | 100 hundredths | 99 (P1 … P99) |
They are all the same idea at different resolutions: the median is Q2, which is D5, which is P50. Because they rely on the order of the data and not on the values of the extremes, they are robust measures, just like the median.
Our working material: 12 e-commerce deliveries
Logistics sends you the delivery times (in hours, from order to the customer's door) of 12 orders from last week, already sorted:
\[ 18 \quad 20 \quad 21 \quad 22 \quad 24 \quad 25 \quad 26 \quad 28 \quad 30 \quad 33 \quad 36 \quad 72 \]
The 72-hour order catches the eye immediately (a customer spent three days waiting). We will work with this sample throughout the lesson.
Quartiles
The quartiles divide the sorted data into four equal parts:
- Q1 (first quartile): leaves 25% of the data below it.
- Q2 (second quartile): the median; leaves 50% below.
- Q3 (third quartile): leaves 75% below.
We will use the interpolated position method: quartile \( k \) sits at position
\[ \text{position of } Q_k = \frac{k , (n+1)}{4} \]
and if the position is not a whole number, you interpolate between the two neighboring values. (An honest warning: several calculation conventions exist and spreadsheets may give slightly different results from one another; with large samples the differences are irrelevant.)
Step-by-step calculation with the 12 deliveries (( n = 12 ))
Q1: position \( \frac{1 \times 13}{4} = 3.25 \) → it lies 25% of the way between the 3rd value (21) and the 4th (22):
\[ Q_1 = 21 + 0.25 \times (22 - 21) = 21.25 \text{ hours} \]
Q2 (median): position \( \frac{2 \times 13}{4} = 6.5 \) → halfway between the 6th value (25) and the 7th (26):
\[ Q_2 = \frac{25 + 26}{2} = 25.5 \text{ hours} \]
Q3: position \( \frac{3 \times 13}{4} = 9.75 \) → 75% of the way between the 9th value (30) and the 10th (33):
\[ Q_3 = 30 + 0.75 \times (33 - 30) = 32.25 \text{ hours} \]
Business reading: 25% of orders arrive in under ~21 h; half in under 25.5 h; 75% in under ~32 h. You can already answer Marta: a 36-hour order sits above Q3 — among the slowest 25% — but within what happens every week. The 72-hour one is another story, as we shall see.
Deciles and percentiles
Deciles and percentiles refine the same idea. Percentile \( P_k \) is the value that leaves \( k,% \) of the data below it; its interpolated position is \( \frac{k,(n+1)}{100} \). For instance, with the deliveries, \( P_{10} \): position \( 0.10 \times 13 = 1.3 \) → \( 18 + 0.3 \times (20-18) = 18.6 \) hours: only 10% of orders arrive before ~18.6 h.
Percentiles are everywhere in management:
- Service-level agreements (SLAs): NovaMarket's logistics team does not promise "an average delivery of 26 h" but rather "90% of orders in under 48 h" — that is, a commitment on the P90. The mean does not protect the customer who lands in the slow tail; the percentile does.
- Customer segmentation: the loyalty team classifies the ≈380,000 Club Nova members by annual spend using deciles:
| Decile | Annual spend (upper limit) | Reading |
|---|---|---|
| D1 | €120 | The lowest-spending 10% stay under €120/year |
| D2 | €210 | |
| D3 | €310 | |
| D4 | €430 | |
| D5 | €580 | Median spend: half of the members spend less than €580 |
| D6 | €760 | |
| D7 | €990 | |
| D8 | €1,320 | |
| D9 | €1,980 | The top 10% spend more than €1,980/year |
Notice the skewness: from D1 to D2 there is a €90 gap, but from D8 to D9 there is €660. The deciles sketch the shape of the distribution without any chart: a long tail towards high spending, as befits monetary amounts.
- Individual position: telling a member (or an account manager) "this customer is at the 92nd percentile of spend" is more informative than "they spend €2,300".
The interquartile range (IQR)
The interquartile range is the width of the "central 50%" of the data:
\[ IQR = Q_3 - Q_1 \]
With the deliveries: \( IQR = 32.25 - 21.25 = 11 \) hours. The central half of the orders fits inside an 11-hour window.
The IQR is the robust alternative to the standard deviation, just as the median is to the mean: since it ignores the bottom 25% and the top 25%, extreme values cannot alter it. Check it yourself: if the 72-hour order had taken 172 hours, the sample's standard deviation would explode, but Q1, Q3 and the IQR would not move a tenth. That is why the IQR is the basis of the standard outlier-detection rule we will see next.
Summary of center–dispersion pairings:
| Approach | Center | Dispersion | When it suits |
|---|---|---|---|
| Classical | Mean \( \bar{x} \) | Standard deviation \( s \) | Data without troublesome extremes; downstream calculations |
| Robust | Median | IQR | Skewed data or data with outliers; honest description |
The box plot
The box plot is the graphical representation of everything above in a single drawing. It is built like this:
- A box running from Q1 to Q3 (its length is the IQR).
- A line inside the box at the median.
- Whiskers: lines extending from the box to the most extreme data point that is not an outlier (according to the 1.5×IQR rule of the next section).
- Individual points beyond the whiskers: the outliers, drawn one by one.
For our deliveries, the summary the box plot represents is:
| Element | Value |
|---|---|
| Minimum (non-outlier) | 18 h |
| Q1 (start of the box) | 21.25 h |
| Median (central line) | 25.5 h |
| Q3 (end of the box) | 32.25 h |
| Largest non-outlier (end of the whisker) | 36 h |
| Outliers (isolated points) | 72 h |
How to read it:
- Position of the box → where the central 50% lives.
- Length of the box → dispersion (IQR).
- Off-center median inside the box and unequal whiskers → skewness. In our deliveries, the upper whisker and upper data points stretch out far more than the lower ones: right skew (a tail of slow orders).
- Isolated points → candidates to investigate.
Its great virtue is comparison: lining up one box plot per store (or per month, or per logistics operator) lets you compare centers, dispersions and outliers of many groups at a glance. We will exploit that in the next lesson, Graphical Representation of Data.
Outlier detection: the 1.5×IQR rule
An outlier is an observation abnormally far from the rest. "Abnormally" needs an operational definition, and the most widespread convention (proposed by John Tukey, the inventor of the box plot) uses the IQR. Two fences are computed:
\[ \text{Lower fence} = Q_1 - 1.5 \times IQR \qquad \qquad \text{Upper fence} = Q_3 + 1.5 \times IQR \]
Every data point outside the fences is flagged as an outlier.
Applying it to the 12 deliveries
\[ 1.5 \times IQR = 1.5 \times 11 = 16.5 \] \[ \text{Lower fence} = 21.25 - 16.5 = 4.75 \text{ h} \qquad \text{Upper fence} = 32.25 + 16.5 = 48.75 \text{ h} \]
No order comes in under 4.75 h (the minimum is 18), but 72 h > 48.75 h: the 72-hour order is a formal outlier, not just an impression. The box plot's whiskers reach 18 and 36 (the most extreme data points inside the fences), and the 72 is drawn as an isolated point.
Notice the effect on the classical summaries: the mean of the 12 deliveries is \( 355/12 \approx 29.6 \) h, but without the outlier it drops to \( 283/11 \approx 25.7 \) h, much closer to the median (25.5 h). A single order was shifting the mean by almost 4 hours.
Two important nuances:
- The rule is a detector of candidates, not a judge: it flags data "to investigate", not data "to delete".
- In naturally skewed distributions (amounts, times) it is normal for a few legitimate outliers to appear on the long side; with large samples, a handful of points beyond the fences is no cause for alarm.
Z-scores: position in units of standard deviation
The measures above locate a data point by its rank. The z-score (or standardized value) locates it by its distance from the mean, measured in standard deviations:
\[ z = \frac{x - \bar{x}}{s} \]
- \( z = 0 \): the data point coincides with the mean.
- \( z = +1 \): it is one standard deviation above the mean.
- \( z = -2 \): two standard deviations below.
Its great strength is that it removes the units: it lets you compare relative positions across variables on completely different scales.
Example: which was more exceptional?
Two things happen on the same day: a customer pays a €95 receipt, and the Madrid-Chamberí store takes in €60,000. Which of the two events is more extraordinary in its own context? With NovaMarket's benchmark figures:
| Event | Value \( x \) | Mean \( \bar{x} \) | Std. dev. \( s \) | Z-score |
|---|---|---|---|---|
| €95 receipt | 95 | €32.40 | €21.50 | \( z = \frac{95 - 32.40}{21.50} \approx +2.91 \) |
| €60,000 day | 60,000 | €43,983 | €6,200 | \( z = \frac{60{,}000 - 43{,}983}{6{,}200} \approx +2.58 \) |
Although €60,000 "sounds" far bigger than €95, the receipt is more exceptional within its own world: it sits almost 3 standard deviations above its mean, versus 2.6 for the sales day. Z-scores work as a common currency of "rareness".
An example with a negative sign: a member rates their satisfaction with a 5. With a mean of 8.1 and a standard deviation of 1.6: \( z = (5 - 8.1)/1.6 \approx -1.94 \). They sit almost two deviations below the average member: a clearly unhappy customer whom customer service should perhaps call.
As a guiding criterion, values with \( |z| > 3 \) are usually treated as outlier candidates too. For now use it only as a rule of relative position: what proportion of the data you can expect beyond each value of z depends on the shape of the distribution, and you will be able to pin it down once you study the Normal Distribution. Bear in mind, too, that \( \bar{x} \) and \( s \) are not robust: in small samples with extremes, the IQR rule is more reliable than the z rule.
What do I do with an outlier?
Detecting the outlier is the easy part; deciding what to do with it is where the quality of your analysis is at stake. The professional protocol has three steps:
1. Investigate the origin. Go back to the source (the receipt system, the order record, the questionnaire) and ask: is it a recording error or a real value?
| Diagnosis | NovaMarket example | Action |
|---|---|---|
| Recording error | A €3,240.00 receipt that turns out to be a €32.40 one with the decimal point mistyped; a delivery whose order date is later than its delivery date | Correct it if you know the true value; otherwise, treat it as missing. Always document it |
| Real value but outside the population of interest | The bar's €289 receipt: it is real, but if your analysis is about households, that wholesale customer does not belong to the defined population | Exclude it from the analysis, declaring it: you are redefining the scope, not "cleaning" |
| Real and relevant value | The 72 h order: there was a breakdown on that delivery route | Keep it. It is extremely valuable information: real outliers are often the finding itself (fraud, breakdowns, exceptional customers) |
2. Analyze with and without it when in doubt. If the business conclusion changes depending on whether you include the outlier, your result is fragile and you must say so. If it does not change, all the better: report it with the data point included.
3. Document the decision. In the report (and in the data dictionary you set up in Types of Data): what you detected, what you decided and why. Never delete data silently: an analysis where outliers vanish without explanation is neither reproducible nor honest.
The golden rule: an outlier gets investigated; it gets corrected only if it is a proven error, and excluded only if it does not belong to the population you are studying.
Common Mistakes and Tips
- Forgetting to sort the data before looking for quartiles or percentiles. It is the number-one slip; every measure of position presupposes sorted data.
- Panicking because the spreadsheet gives a different quartile. Several legitimate interpolation conventions exist; document which one you use and do not mix methods when comparing.
- Confusing the percentile with the value. "Being at the P90 of spend" does not mean spending €90, nor spending 90% more: it means spending more than 90% of the members.
- Deleting outliers automatically (or, conversely, never looking at the extremes). Both destroy information: the 1.5×IQR rule flags candidates to investigate, not a deletion list.
- Using z-scores on heavily skewed data or small samples as the only criterion: the mean and standard deviation are contaminated precisely by the values you are trying to judge. Prefer the IQR in those cases.
- Tip: get into the habit of requesting (or building) the five-number summary — minimum, Q1, median, Q3, maximum — for every new variable that lands on your desk. Five figures that tell the full shape of the distribution.
Exercises
Exercise 3.1: quartiles, IQR and fences
Eleven receipt amounts from the Barcelona-Gràcia store, already sorted (in euros): 9.80 — 14.20 — 19.60 — 22.10 — 25.40 — 28.90 — 33.50 — 38.70 — 44.20 — 51.80 — 120.00.
- Compute Q1, Q2 and Q3 using the position method \( k(n+1)/4 \).
- Compute the IQR and the fences of the 1.5×IQR rule. Are there any outliers?
- Describe what the box plot would look like (ends of the box, median, whiskers, isolated points).
Exercise 3.2: comparing with z-scores
On one particular day, the Cuenca store takes in €39,500 and Sevilla-Nervión takes in €52,000. Using the chain's mean (€43,983) and standard deviation (€6,200) for daily sales:
- Compute each store's z-score for that day.
- Interpret the signs and magnitudes. Is either day "exceptional" under the guiding criterion \( |z| > 3 \)?
Exercise 3.3: deciding what to do
In the satisfaction survey file you find three cases: (a) a member with a recorded age of 141 years; (b) a member with an annual spend of €9,400 who, upon checking, turns out to be the owner of a restaurant that does its purchasing at NovaMarket; (c) a satisfaction score of 0 from a customer who wrote a furious comment about a lost delivery. Your analysis aims to describe the satisfaction of Club Nova's household members. What would you do with each case?
Solutions
Exercise 3.1:
- \( n = 11 \), so \( n+1 = 12 \) and the positions are whole numbers: Q1 at position 3 → €19.60; Q2 at position 6 → €28.90; Q3 at position 9 → €44.20.
- \( IQR = 44.20 - 19.60 = \text{€}24.60 \). \( 1.5 \times IQR = 36.90 \). Fences: \( 19.60 - 36.90 = -\text{€}17.30 \) and \( 44.20 + 36.90 = \text{€}81.10 \). The €120.00 receipt is an outlier (it exceeds the upper fence); there are no lower outliers (a negative fence is normal and simply unreachable with monetary amounts). Common mistake: using the actual maximum and minimum as whiskers even when there are outliers.
- A box from 19.60 to 44.20 with the median at 28.90 (off-center towards the bottom: right skew); lower whisker down to 9.80 (the minimum, inside the fences) and upper whisker up to 51.80 (the largest data point ≤ 81.10); one isolated point at 120.00.
Exercise 3.2:
- Cuenca: \( z = (39{,}500 - 43{,}983)/6{,}200 \approx -0.72 \). Sevilla-Nervión: \( z = (52{,}000 - 43{,}983)/6{,}200 \approx +1.29 \).
- Cuenca is somewhat below the chain's mean (less than one standard deviation: a quiet but ordinary day); Sevilla, clearly above but nowhere near unusual. Neither exceeds \( |z| > 3 \): there is nothing exceptional to investigate. Common mistake: comparing the euros directly (52,000 versus 39,500) without standardizing; also beware of using the chain's mean when what you want is to compare each store against its own history — that would be a different question (and different \( \bar{x} \) and \( s \)).
Exercise 3.3:
(a) An obvious recording error (nobody is 141 years old): try to recover the real value (a 41, perhaps?); if that is not possible, mark it as missing. Document it. (b) A real value but outside the defined population (households): exclude it from the analysis, declaring it in the report; that is not "cleaning", it is scope definition. (c) A real and relevant value: keep it; that 0 with its comment is probably the most actionable data point in the whole survey for logistics. Common mistake: treating all three cases the same way (deleting them "for being odd"); every outlier demands its own diagnosis.
Conclusion
You now command the full descriptive toolbox: to the mean and standard deviation you have added quartiles, deciles and percentiles to locate any data point by its rank, the IQR as a robust dispersion measure, the box plot as a visual five-number summary, the 1.5×IQR rule for flagging outlier candidates, z-scores for comparing rareness across different scales and, most importantly, a protocol for deciding — by investigating, not deleting — what to do with each anomalous data point.
So far all these summaries have been numeric. But when Marta walks into the executive committee she will not project tables of quartiles: she will project charts, and whether the room understands — or misreads — the data will hinge on those charts being well chosen and well built. Choosing the right chart for each type of variable, reading the shape of a distribution and dodging misleading charts is the subject of the next lesson: Graphical Representation of Data.
Statistics Course
Module 1: Introduction to Statistics
Module 2: Describing Data
- Measures of Central Tendency
- Measures of Dispersion
- Measures of Position and Outliers
- Graphical Representation of Data
Module 3: Probability
Module 4: Probability Distributions
- The Binomial Distribution
- The Normal Distribution
- Other Important Distributions
- The Central Limit Theorem
Module 5: Statistical Inference
Module 6: Data Analysis
- Correlation Analysis
- Regression Analysis
- Analysis of Variance (ANOVA)
- Categorical Data Analysis: Chi-Square
