Statistics & Probability Percentiles, Z-Scores & Distribution Shape Tukey's hinges and the 1.5 x IQR outlier rule (Exploratory Data Analysis, 1977)

Quartile and Interquartile Range Calculator

This calculator returns the first quartile, the median, the third quartile and the interquartile range of your data, then applies Tukey's 1.5 x IQR rule to flag outliers. It also gives you the full five-number summary - minimum, Q1, median, Q3, maximum - which is everything you need to draw a box plot by hand. Because textbooks and spreadsheets disagree about how to split the data at the median, you can choose between the three quartile conventions in common use.

Calculator

This calculator runs in your browser. Enable JavaScript for live results — the inputs, formula and worked example below remain fully readable without it.

Inputs this calculator takes, with typical values
InputWhat to enterExample
Data valuesSeparate numbers with commas, spaces or line breaks. The calculator sorts them for you.7, 15, 36, 39, 40, 41
Quartile methodMatch this to whatever your course or software uses; the three conventions can give different quartiles on the same data.Tukey's hinges - exclude the median when n is odd
Outlier fence multiplierTukey's rule uses 1.5 for outliers and 3.0 for far-out points; leave it at 1.5 unless you have a reason.1.5

It returns

  • Interquartile range (Q3 - Q1) — The width of the middle half of the data.
  • First quartile Q1
  • Median (Q2)
  • Third quartile Q3
  • Lower fence
  • Upper fence
  • Values outside the fences
  • Count n

The formula

IQR=Q3Q1
fence=Q1kIQR,Q3+kIQR

In plain text: IQR = Q3 - Q1; lower fence = Q1 - 1.5 x IQR; upper fence = Q3 + 1.5 x IQR

  • Q1First quartile: the value below which a quarter of the data lie (same as the data)
  • Q3Third quartile: the value below which three quarters of the data lie (same as the data)
  • IQRInterquartile range, the width of the middle 50% of the data (same as the data)

The 1.5 multiplier is Tukey's convention from Exploratory Data Analysis (1977). It is a rule of thumb chosen so that, on normally distributed data, only about 0.7% of observations are flagged.

Updated Category Percentiles, Z-Scores & Distribution Shape Verified against published test cases Reading time 10 min

What the interquartile range measures

The interquartile range is the width of the middle half of your data. Sort the observations, find the value a quarter of the way up (Q1) and the value three quarters of the way up (Q3), and subtract. Half of every data set lies between those two numbers, by construction.

That construction gives the IQR a property the standard deviation does not have: it is resistant. Move the largest observation from 41 to 41,000 and Q1, Q3 and the IQR do not change at all, because the quartiles depend only on where an observation sits in the order, not on how far away it is. The standard deviation, which squares distances, would change enormously. That is why the IQR is the spread measure that belongs with a median, and why box plots are built from quartiles rather than from means.

The IQR is also the engine of the most widely used outlier rule in statistics. John Tukey proposed marking any point more than 1.5 interquartile ranges beyond the nearer quartile, and that convention is now baked into the whiskers of almost every box plot you will see. The multiplier is a judgement call, not a derivation: it is calibrated so that on normally distributed data roughly 0.7% of observations get flagged.

Three conventions for the quartiles, and why they disagree

The median is unambiguous. The quartiles are not, and the disagreement is entirely about what to do with the median when the count is odd.

Tukey's hinges. Split the sorted data at the median. When n is odd, leave the median out of both halves. Q1 is the median of the lower half, Q3 the median of the upper half. For 1 to 9, the halves are 1,2,3,4 and 6,7,8,9, giving Q1 = 2.5 and Q3 = 7.5.

Moore and McCabe. Same procedure, except that when n is odd the median belongs to both halves. For 1 to 9 the halves are 1,2,3,4,5 and 5,6,7,8,9, giving Q1 = 3 and Q3 = 7. This is the convention in many introductory textbooks and in the TI graphing calculators.

Linear interpolation. Forget halves and treat the quartile as a percentile. The value at proportion p sits at position 1 + (n - 1)p in the sorted list, and if that position falls between two observations you interpolate. For 1 to 9, Q1 sits at position 1 + 8 x 0.25 = 3, which is the third value, 3. This is Excel's QUARTILE.INC, R's default type 7 and NumPy's default.

All three are defensible and all three are in daily use, which is why this calculator asks. On the same nine integers they give IQRs of 5, 4 and 4. Neither answer is wrong; they are answers to slightly different questions, and the only real error is comparing a quartile computed one way with a quartile computed another. The percentile calculator exposes the same choice for arbitrary percentiles.

Once you have Q1 and Q3, the rest is mechanical. IQR = Q3 - Q1. The lower fence is Q1 minus 1.5 IQR, the upper fence is Q3 plus 1.5 IQR, and anything beyond either is flagged.

Worked example: six values, by hand

Take 7, 15, 36, 39, 40, 41. They are already sorted, and n = 6 is even, so all three conventions treat the halves identically here.

  1. Find the median. With six values, average the 3rd and 4th: (36 + 39) / 2 = 37.5.
  2. Split at the median. Lower half: 7, 15, 36. Upper half: 39, 40, 41.
  3. Q1 is the median of the lower half. Three values, so take the middle one: Q1 = 15.
  4. Q3 is the median of the upper half. Again the middle of three: Q3 = 40.
  5. Subtract. IQR = 40 - 15 = 25.
  6. Build the fences. 1.5 x 25 = 37.5. Lower fence = 15 - 37.5 = -22.5. Upper fence = 40 + 37.5 = 77.5.
  7. Check the data against them. Every value lies between -22.5 and 77.5, so nothing is flagged.

The five-number summary is 7, 15, 37.5, 40, 41. Draw a box from 15 to 40 with a line at 37.5 and whiskers out to 7 and 41 and you have the box plot. Notice how asymmetric it is: the median sits close to Q3, so the lower quarter of the box is stretched. That is a left-skewed distribution, and the single value of 7 sitting eight units below Q1 is what causes it - even though it is nowhere near the fence.

Now add a seventh value, 200. Sorted: 7, 15, 36, 39, 40, 41, 200. The median is now 39. By Tukey's hinges the halves are 7,15,36 and 40,41,200, so Q1 = 15 and Q3 = 41. IQR = 26, and the upper fence is 41 + 39 = 80. The value 200 is flagged, and Q1 has not moved at all - the resistance in action.

How to read the IQR and the flagged points

The IQR is in the units of your data and describes the concentration of the bulk of it. An IQR of 25 on values running from 7 to 41 means the middle half spans most of the observed range, so the data are widely spread. An IQR of 2 on the same range would mean the data are tightly clustered with long thin tails.

Compare the median's position within the box to judge skew. If the median sits nearer Q1, the upper half of the middle is stretched and the distribution leans right; if it sits nearer Q3, it leans left. This reading is more reliable than comparing the mean with the median, because it is not affected by how extreme the extremes are.

Treat a flagged point as a question, not a verdict. The 1.5 x IQR rule identifies observations that are unusual relative to this data set's own middle half, which is a useful trigger for checking a transcription, a unit, or an instrument. It is not evidence that the value is wrong, and deleting flagged points because they were flagged is how genuine findings get thrown away. On a perfectly normal distribution the rule still flags about 7 observations in every 1,000, and on a heavy-tailed or skewed distribution such as incomes or waiting times it flags far more than that - which is a statement about the shape of the data, not about data quality.

For a stricter screen, raise the multiplier. Tukey's own terminology called points beyond 1.5 IQR outside and points beyond 3.0 IQR far out, and this calculator lets you set the multiplier directly. Raising it always flags the same points or fewer, never more, since the fences move outward on both sides.

The three quartile conventions on the same data

Every cell was produced by running this calculator's own quartile routines on the listed data set.
DatanMethodQ1MedianQ3IQR
1 to 99Tukey2.557.55
1 to 99Moore & McCabe3574
1 to 99Excel QUARTILE.INC3574
1 to 88Tukey2.54.56.54
1 to 88Excel QUARTILE.INC2.754.56.253.5
7, 15, 36, 39, 40, 416Tukey1537.54025
7, 15, 36, 39, 40, 416Excel QUARTILE.INC20.2537.539.7519.5

With an even n the two half-splitting methods always agree with each other, but the interpolating method can still differ from both, as the last two rows show.

Assumptions, limits and common errors

  • Comparing quartiles computed by different conventions. If your homework uses Moore & McCabe and your spreadsheet uses QUARTILE.INC, the two will disagree on odd-sized data sets and neither is wrong. Fix the convention before you compare.
  • Reading a flagged point as an error. The rule marks points for inspection. Removing them because the rule marked them biases every subsequent estimate and is not a defensible cleaning step on its own.
  • Applying the 1.5 multiplier to skewed data without thinking. The multiplier is calibrated on a symmetric normal distribution. On right-skewed data such as incomes or durations it flags large values much more often than 0.7% and never flags small ones, which is a property of the rule rather than a finding.
  • Using the IQR on very small samples. With fewer than about eight observations the quartiles are determined by one or two data points each and move dramatically when a single value changes. Report the range and the sorted data instead.
  • Assuming IQR and standard deviation are interchangeable. For a normal distribution IQR is about 1.349 standard deviations, and dividing the IQR by 1.349 is a standard robust estimate of sigma. That relationship holds only for the normal distribution and fails badly on skewed data.
  • Forgetting that the fences are not data values. Box plot whiskers are drawn to the most extreme observation inside each fence, not to the fence itself. The fence is a threshold; the whisker end is always an actual observation.

Where the IQR fits among measures of spread

Choose between the IQR and the standard deviation the same way you choose between the median and the mean. Skewed data, heavy tails, or values you do not fully trust point to the median and IQR; symmetric well-behaved measurements point to the mean and standard deviation. Quoting a median with a standard deviation, or a mean with an IQR, mixes the two schemes and confuses readers.

The quartiles are just three particular percentiles - the 25th, 50th and 75th - so the percentile calculator will reproduce them and will also give you the 90th or 99th when the tails are what matter, as in latency reporting. The median itself is available directly from the mean, median and mode calculator.

For a formal outlier test on data you believe to be normal, standardise the suspect observation with the z-score calculator and read the tail probability from the normal distribution calculator. That approach makes a distributional assumption the IQR rule does not, so it is more powerful when the assumption holds and misleading when it does not. The robust alternative to both is the median absolute deviation, which uses the median of the absolute distances from the median and is even less sensitive to extremes than the IQR.

Finally, the five-number summary on this page is a complete description of a box plot. If you are drawing one by hand, take the minimum, Q1, median, Q3 and maximum from the table, draw the box between the quartiles, mark the median inside it, and extend whiskers to the furthest observations still inside the fences, plotting anything beyond as an individual point.

Frequently asked questions

Why does my textbook give a different Q1 from Excel?

Because they use different quartile conventions. Textbooks commonly split the sorted data at the median and take the median of each half, while Excel's QUARTILE.INC interpolates at position 1 + (n - 1) x 0.25. On the integers 1 to 9 the first approach gives 2.5 or 3 depending on whether the median is excluded, and Excel gives 3. Pick the convention your course or software uses and stay with it.

What does the 1.5 in the outlier rule come from?

It is a convention John Tukey introduced in Exploratory Data Analysis in 1977, chosen so that a normal distribution produces very few false flags - about 7 points in 1,000. It is not derived from a probability model of your particular data. Tukey also used 3.0 IQR to mark points he called far out, and this calculator lets you set the multiplier directly.

Can the interquartile range be zero?

Yes, whenever Q1 and Q3 are the same value, which happens when at least half the observations share one number. The fences then collapse onto that value and every different observation is flagged. That is a limitation of the rule on highly discrete or heavily tied data, not a signal that something is wrong with the data.

How many data points do I need?

Arithmetically, one. Practically, at least eight before the quartiles mean much, because below that each quartile is pinned to one or two observations and jumps whenever any of them changes. For fewer than eight values, report the sorted data and the range instead.

Is the IQR the same as the middle 50% of the range?

It is the width of the middle 50% of the data, not of the range. Half the observations lie inside the box, but the box need not be half as wide as the full spread. In the worked example on this page the IQR of 25 covers most of the 34-unit range, because the data are clustered high with one low value.

How do I turn an IQR into a standard deviation?

For normally distributed data, divide by 1.349. That constant is the distance in standard deviations between the 25th and 75th percentiles of a normal curve, and IQR/1.349 is a standard robust estimate of sigma that ignores outliers. The conversion is valid only under normality and should not be applied to skewed data.

Should I delete the values the calculator flags?

Not on the strength of the flag alone. Investigate each one: check the transcription, the units, the instrument and the conditions. Remove a point only when you have an identified reason unrelated to its value, and say in your write-up what you removed and why. Silent deletion of flagged points biases every estimate that follows.

Do I need to sort my data before pasting it?

No. The calculator sorts the values before doing anything else. Order in the input box has no effect on any output, which is not true of a hand calculation - forgetting to sort is the most common way to get the quartiles wrong on paper.

References