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.

Calculation parameters
Was this calculator useful?

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. 1.5·IQR rule is arbitrary: for very skewed data may flag too many points or none.
  2. Works well for approximately symmetric distributions; for extreme skew use adjusted rule (Hubert-Vandervieren 2008).
  3. For small samples (n<10) quartiles very unstable.
  4. Detected outliers ≠ measurement errors: can be true extreme values (top performer, rare events).
  5. For heavy-tailed distributions (Cauchy, low-df t), many "outliers" are normal.
  6. Different percentile definitions exist (Hyndman-Fan 1996 lists 9 methods).
  7. Box plot doesn't reveal bimodality or fine shape: complement with histogram.
  8. For discrete data with many ties, quartiles can be identical.

Common errors

  1. Computing quartiles with different method than reference (Excel QUARTILE.EXC vs INC).
  2. Confusing mild outliers (1.5·IQR) with extreme (3·IQR).
  3. Automatically removing outliers without investigating cause.
  4. Ignoring asymmetric bias (1.5·IQR rule symmetric around Q2).
  5. Applying 1.5·IQR rule to clearly non-normal distributions.
  6. Confusing range (max-min) with IQR (Q3-Q1).
  7. Not reporting both median and mean to highlight asymmetry.
  8. Always treating outliers as errors (incorrect statistical practice).

Practical applications

  1. Quality control: SPC control charts, lot acceptance (ISO 8258, ANSI/ASQ Z1).
  2. Exploratory data analysis (EDA): first phase of any statistical analysis.
  3. Finance: identifying anomalous price movements, trade surveillance.
  4. Healthcare: out-of-range lab values (CDC, NHS, FDA).
  5. Clinical research: outlier handling per ICH E9.
  6. Education: grade distributions, performance bands.
  7. HR: outlier compensation analysis.
  8. Sports analytics: performance outliers vs peer.
  9. Climatology: extreme event identification (NOAA, NWS).
  10. 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

Frequently Asked Questions

What are quartiles?

They are the three values that divide an ordered dataset into four equal parts. The first quartile Q1 leaves 25% of the data below it, the second Q2 is the median (50%), the third Q3 the 75%. Together with the minimum and maximum they form the five-number summary used in box plots.

What is the IQR?

It is the interquartile range, the difference IQR = Q3 - Q1, which measures the spread of the central 50% of the data. It is a robust measure: unlike the full range, it is not affected by extreme values. The larger the IQR, the more the central data are spread around the median.

How are outliers identified?

With Tukey's fences based on the IQR. Values beyond Q1 - 1.5 IQR or Q3 + 1.5 IQR are mild outliers; those beyond Q1 - 3 IQR or Q3 + 3 IQR are extreme. It is the standard method proposed by John Tukey in 1977, robust because it uses the quartiles rather than the mean.

How are quartiles computed?

You sort the data, then for percentile p compute the index idx = (p/100)(n-1) and interpolate linearly between the two closest values: arr[lo](1-frac) + arr[hi]frac. It is the linear interpolation method adopted by NumPy and Excel. Q1, Q2 and Q3 correspond to percentiles 25, 50 and 75.

What is a box plot?

It is the diagram invented by Tukey that displays the five-number summary: a box from the first to the third quartile with the median, whiskers extending to the data within the fences, and individual points for outliers. It allows comparing several distributions at a glance without tables.

Why is the IQR more robust than the standard deviation?

Because it is based on the central positions of the sorted data and not on the magnitude of individual values. A single extreme value can severely distort the mean and standard deviation, but leaves the median and IQR almost unchanged. This is why they are preferable with skewed or potentially contaminated data.

Should an outlier always be removed?

No. An outlier can be a measurement error to correct, but also a genuine and important data point, such as a fraud, a failure or a rare event. It should always be investigated before deciding: removing it automatically risks hiding precisely the most significant information in the dataset.

Where are quartiles and outliers used?

In statistical quality control, in exploratory data analysis, in financial surveillance of suspicious transactions, in clinical research, in sports analysis, in climatology and in cybersecurity to detect anomalies. They are fundamental tools wherever robust measures of the distribution are needed.

Formula

IQR = Q_3 - Q_1, \quad \text{outliers}: x < Q_1 - 1.5 \cdot IQR \text{ or } x > Q_3 + 1.5 \cdot IQR

Comments (0)

No comments yet. Be the first!