How to compute quartiles, IQR and outliers (box plot)
Compute quartiles Q1, Q2 (median), Q3, IQR and outliers (Tukey 1.5·IQR rule) of a dataset. Box plot, inner/outer fences, asymmetry, dispersion. Tukey 1977 EDA.
Report a calculation error
Help us improve. Describe what is wrong with the calculation.
Result
| Voce | Valore |
|---|
Show full details
Share result
Disclaimer: this calculation is for informational purposes only. For important decisions, consult a qualified professional.
How to calculate quartiles, IQR, and outliers: quartiles divide ordered data into four equal parts. Q1 (25th percentile) leaves 25% of data to the left; Q2 (50th percentile, median) 50%; Q3 (75th percentile) 75%. IQR = Q3 − Q1 is a robust dispersion measure. Mild outliers lie beyond Q1 − 1.5·IQR or Q3 + 1.5·IQR (Tukey 1977 rule); extreme beyond 3·IQR.
Formula and principles
Quartiles are specific percentiles: Q1 = 25th, Q2 = 50th (median), Q3 = 75th. Calculation has multiple conventions (R offers 9 methods). Most common: sort data, compute index idx = (p/100)·(n-1) for percentile p, linearly interpolate between arr[floor(idx)] and arr[ceil(idx)]. The IQR (Interquartile Range) = Q3 − Q1 is a dispersion measure robust to outliers (unlike standard deviation). Tukey's "fences" define outliers: inner fence Q1±1.5·IQR for mild outliers, outer fence Q1±3·IQR for extreme.
History and statistical context
John Wilder Tukey introduced the box plot in his book Exploratory Data Analysis (1977), along with the 1.5·IQR rule for outliers. Tukey is considered the father of EDA (Exploratory Data Analysis). "Stem-and-leaf plot" and "five-number summary" (min, Q1, median, Q3, max) are his contributions. The 1.5·IQR rule is based on the normal distribution: for N(0,1) IQR ≈ 1.349·σ, so 1.5·IQR ≈ 2.024·σ; fences correspond to ±2.7σ from median, containing 99.3% of normal data (0.7% false positive rate accepted). ASA, ICH E9, FDA Guidance, ISO 16269-4 codify exploratory analysis.
Interpretation table
- Range = max − min: total dispersion, outlier-sensitive
- IQR = Q3 − Q1: middle 50% dispersion, outlier-robust
- Inner fence: Q1 − 1.5·IQR (lower), Q3 + 1.5·IQR (upper)
- Outer fence: Q1 − 3·IQR, Q3 + 3·IQR
- Mild outliers: between inner and outer fences
- Extreme outliers: beyond outer fence
- Quartile Coefficient of Dispersion: QCD = (Q3 − Q1)/(Q3 + Q1), compares dispersions
- Five-number summary: min, Q1, median, Q3, max
Worked numerical examples
Example 1 — symmetric dataset. Data 1-10. n=10. Median Q2 = 5.5. Q1 = 3.25, Q3 = 7.75. IQR = 4.5. Inner fences: -3.5 and 14.5. Outer: -10.25 and 21.25. No outliers. Range = 9, mean = 5.5, SD ≈ 3.03. QCD = 0.41.
Example 2 — dataset with outlier. Data: 10, 12, 14, 15, 16, 17, 18, 19, 20, 100. Q1 ≈ 14.25, Q2 ≈ 16.5, Q3 ≈ 18.75. IQR = 4.5. Inner fences: 7.5 and 25.5. Value 100 > 32.25 → extreme outlier. Median 16.5 vs mean 24.1: median more representative, immune to 100.
Example 3 — positive skewed distribution. Salaries ($k): 25, 28, 30, 32, 33, 35, 38, 42, 45, 60, 80, 150. Q1 = 30.5, Q2 = 36.5, Q3 = 51.25. IQR = 20.75. Upper inner fence: 82.4. Value 150 > 82.4 → mild outlier. Positive skew confirmed: Q2−Q1 = 6 < Q3−Q2 = 14.75.
Example 4 — SPC quality control. Diameter measurements (mm): 9.98, 10.01, 10.02, 10.00, 9.99, 10.03, 9.97, 10.04, 9.96, 10.05, 11.50 (instrument error). IQR = 0.04. Inner fences: 9.94 and 10.07. 11.50 way beyond, extreme outlier. Trigger inspection. ISO 8258 SPC control charts.
Example 5 — exam scores. 50 students scores out of 100. Five-number summary: 35, 60, 70, 80, 95. IQR = 20. Lower inner fence: 30. Student with 35 NOT an outlier. Box plot shows median 70 (passing grade), middle 50% spread between 60-80, full range 35-95.
Model limitations
- 1.5·IQR rule is arbitrary: for very skewed data may flag too many points or none.
- Works well for approximately symmetric distributions; for extreme skew use adjusted rule (Hubert-Vandervieren 2008).
- For small samples (n<10) quartiles very unstable.
- Detected outliers ≠ measurement errors: can be true extreme values (top performer, rare events).
- For heavy-tailed distributions (Cauchy, low-df t), many "outliers" are normal.
- Different percentile definitions exist (Hyndman-Fan 1996 lists 9 methods).
- Box plot doesn't reveal bimodality or fine shape: complement with histogram.
- For discrete data with many ties, quartiles can be identical.
Common errors
- Computing quartiles with different method than reference (Excel QUARTILE.EXC vs INC).
- Confusing mild outliers (1.5·IQR) with extreme (3·IQR).
- Automatically removing outliers without investigating cause.
- Ignoring asymmetric bias (1.5·IQR rule symmetric around Q2).
- Applying 1.5·IQR rule to clearly non-normal distributions.
- Confusing range (max-min) with IQR (Q3-Q1).
- Not reporting both median and mean to highlight asymmetry.
- Always treating outliers as errors (incorrect statistical practice).
Practical applications
- Quality control: SPC control charts, lot acceptance (ISO 8258, ANSI/ASQ Z1).
- Exploratory data analysis (EDA): first phase of any statistical analysis.
- Finance: identifying anomalous price movements, trade surveillance.
- Healthcare: out-of-range lab values (CDC, NHS, FDA).
- Clinical research: outlier handling per ICH E9.
- Education: grade distributions, performance bands.
- HR: outlier compensation analysis.
- Sports analytics: performance outliers vs peer.
- Climatology: extreme event identification (NOAA, NWS).
- Cybersecurity: anomaly detection in logs and network traffic.
Support
Questions: info@calcoi.com. Educational tool for quartile and outlier analysis. For professional statistical analysis consult biostatistician per ASA, ICH E9.
Updated July 2026
Comments (0)
Login to leave a comment.
No comments yet. Be the first!