Quartile Calculator
Split a data set into quarters. Four methods, side by side, with the halves shown.
What a quartile is
Quartiles are the three values that cut sorted data into four groups of equal size. A quarter of the values fall below Q1, half fall below Q2 — which is just the median under another name — and three quarters fall below Q3.
They are percentiles at fixed positions: Q1 is the 25th percentile, Q2 the 50th, Q3 the 75th. Anything the percentile calculator can do at an arbitrary percentage, the quartiles do at those three.
Why methods differ, and which one you want
Every method agrees on the median. They disagree about what to do with the halves on either side of it, and the disagreement is real enough to change your answer.
Exclusive — the textbook rule
Split at the median. If the count is odd, the median belongs to neither half. Q1 is the median of the lower half, Q3 the median of the upper half. This is what a TI-83 or TI-84 reports under 1-Var Stats, and what most introductory courses teach.
Inclusive — Tukey's hinges
Same split, except that with an odd count the median is counted in both halves. The two quartiles move inward compared with the exclusive rule, so the IQR comes out smaller. R's fivenum() produces these.
Interpolation at rank p(n+1)
Rather than splitting into halves, treat the quartile as a position. Compute the rank p(n+1) — for Q1 that is 0.25(n+1) — and if it lands between two values, interpolate linearly between them. This is the rule in the NIST handbook, and the one Excel's QUARTILE.EXC implements.
Interpolation at rank (n−1)p+1
Same idea, different rank formula. This one always lands inside the data, so it never needs clamping at small n. It is the most widely deployed convention in practice, because it is what Excel's QUARTILE.INC, Google Sheets, NumPy and pandas all use by default.
The words "exclusive" and "inclusive" are used inconsistently across the web. Some tools use them for the halves rules above; others use them for Excel's .EXC and .INC functions, which are the two interpolation rules and are unrelated to whether the median joins a half. This site uses those two words only for the halves rules, and names the interpolation methods by their rank formula.
Which method does your software use?
| Software | Function | Method here |
|---|---|---|
| TI-83 / TI-84 | 1-Var Stats | Exclusive |
| R | fivenum() | Inclusive |
| R | quantile(type = 6) | Interpolation p(n+1) |
| R | quantile() default, type 7 | Interpolation (n−1)p+1 |
| Excel | QUARTILE.EXC, PERCENTILE.EXC | Interpolation p(n+1) |
| Excel | QUARTILE.INC, PERCENTILE.INC, QUARTILE | Interpolation (n−1)p+1 |
| Google Sheets | QUARTILE | Interpolation (n−1)p+1 |
| NumPy / pandas | quantile(), describe() | Interpolation (n−1)p+1 |
Pick the matching row in the panel above and this calculator will reproduce that software's answer exactly.
Quartile deviation and the semi-interquartile range
Also called the semi-interquartile range. It answers "how far, typically, is a quartile from the median?" rather than "how far apart are the quartiles?" — the same information, halved. It appears in older textbooks more often than in modern practice.
Worked examples
An even count: every method agrees
Six values. The median is (15 + 16) ÷ 2 = 15.5, and the halves are 4, 8, 15 and 16, 23, 42 regardless of which halves rule you apply — there is no middle value to argue over.
Q1 = 8, Q3 = 23, IQR = 15. The exclusive and inclusive methods are identical here. The two interpolation methods still differ, because they position the quartile by rank rather than by splitting: p(n+1) gives Q1 = 7 and (n−1)p+1 gives Q1 = 9.75.
An odd count where all four separate
Eleven values, median 40.
- Exclusive: Q1 = 15, Q3 = 43
- Inclusive: Q1 = 25.5, Q3 = 42.5
- p(n+1): rank 3 and rank 9 land exactly on values → Q1 = 15, Q3 = 43
- (n−1)p+1: rank 3.5 and 8.5 interpolate → Q1 = 25.5, Q3 = 42.5
The IQR is either 28 or 17 depending on which convention you follow — a difference of 65%. This is the data set to paste in if you want to see the point.
Questions
Is Q2 the same as the median?
Yes, always, under every method. Q2 and the median are two names for the value with half the data below it.
Can Q1 equal Q3?
Yes, when at least half the values are identical. The IQR is then 0, and a box plot drawn from the data collapses to a line.
Which method should I report?
Whichever your audience expects, stated explicitly. In coursework, match the method you were taught. In a paper or report, name the software and function you used — "quartiles computed with R quantile type 7" removes all ambiguity.
Method & sources
- The p(N+1) rank rule with linear interpolation — NIST/SEMATECH e-Handbook of Statistical Methods
- Method survey and worked comparisons — Wikipedia: Quartile