Enter your data values separated by commas (,) or spaces. They can be in any order (they are sorted from smallest to largest when calculated).
Table of Contents
-
What you can do on this page
-
What is this calculation used for?
-
How to Use
-
Formulas and figures
-
Symbols and terms
-
Good to know before you start
-
How to calculate it in Excel
-
How to calculate it in Google Sheets
-
How to calculate it in Python
-
How to write it in LaTeX and other math languages (copy and paste)
-
How to have ChatGPT do the calculation
-
DataChef Features
-
Related Features
-
NumberChef Calculators List
What you can do on this page
- Enter your data and get the first quartile \(Q_1\), the median (second quartile) \(Q_2\), the third quartile \(Q_3\), the interquartile range IQR, the quartile deviation, the minimum and the maximum all at once
- A box plot (box-and-whisker plot) is drawn on the spot from the result (you can save it as PNG or SVG)
- Outliers (values below \(Q_1 - 1.5 \times \mathrm{IQR}\), or above \(Q_3 + 1.5 \times \mathrm{IQR}\)) are found automatically and shown as separate dots on the box plot
- Quartiles are found with the median-of-halves method taught in school textbooks, and the steps (how the data is split into a lower half and an upper half) are shown too
- A plain-language explanation of the formulas and copy-and-paste formulas for Excel, Google Sheets and Python are all on this page
What is this calculation used for?
The class average alone does not tell you how the test scores are spread out. With quartiles you can read "the middle half of the students scored between what and what" and "what score you need to be in the top 25%".
In school grade reports and practice test analysis, box plots for each class or subject are placed side by side so the differences in distribution can be compared at a glance.
With data such as pay or savings, a few extremely large values pull the mean up, so "the mean" is not what a typical person has. For such data, the median and the first and third quartiles give a picture closer to real life. The US Bureau of Labor Statistics, for example, publishes wages for each occupation as the 25th percentile, the median and the 75th percentile (that is, Q1, Q2 and Q3) along with the mean.
When you want to know where you stand in the whole group, quartiles are a more reliable yardstick than the mean.
When you look for suspicious values in product measurements, sensor readings or a data set before analysis, the 1.5×IQR rule is one of the most widely used guides. Unlike the mean and the standard deviation, it is hardly affected by the outliers themselves, which makes it a convenient yardstick for finding them.
But an outlier is not always an error, so in practice it is not thrown away automatically. First check the cause (a typing mistake, or a truly unusual event), then decide how to handle it.
For track and swimming times, being consistent matters as well as being fast on average. Put the records of several athletes, or of different seasons, side by side as box plots, and you can compare speed and consistency (how small the box is) at the same time.
In weather and climate work too, box plots are often used to compare how much temperature or rainfall varies by city or by month.
Formulas and figures
Symbols and terms
Symbols
| \(Q_1\) | Q one | The first quartile. \(Q\) comes from the first letter of "quartile". It is the value about one quarter (25%) of the way up the sorted data, found as the median of the lower half. |
| \(Q_2\) | Q two | The second quartile. It is the value exactly in the middle of all the data, which is the median itself. In a box plot it is the line that divides the box. |
| \(Q_3\) | Q three | The third quartile. It is the value about three quarters (75%) of the way up the sorted data, found as the median of the upper half. |
| \(\mathrm{IQR}\) | I Q R | The interquartile range, from the first letters of "interquartile range" (the range between the quartiles). It means \(Q_3 - Q_1\), the width that holds the middle 50% or so of the data. |
| \(x\) | x | A letter that stands for each single data value. On this page it appears in the outlier test (such as \(x < Q_1 - 1.5 \times \mathrm{IQR}\)). |
| \(n\) | n | The number of values, from the first letter of "number". How the median is handled when finding quartiles depends on whether \(n\) is even or odd. |
Terms
| quartile | The three values that divide sorted data into four parts with equal numbers of values. From the smallest, they are the first quartile \(Q_1\), the second quartile \(Q_2\) (= the median) and the third quartile \(Q_3\). |
| median | The value exactly in the middle when the data is sorted from smallest to largest. With an even number of values, it is the mean of the two middle values. Unlike the mean, it is a measure of center that extremely large or small values hardly affect. |
| lower half | The first half of the data (the side below the median) when the data is split at the median. With an odd number of values, the median itself is left out. The median of the lower half is \(Q_1\). |
| upper half | The second half of the data (the side above the median) when the data is split at the median. With an odd number of values, the median itself is left out. The median of the upper half is \(Q_3\). |
| interquartile range | It means \(Q_3 - Q_1\) (the IQR). It is the width that holds the middle 50% or so of the data and is used to measure spread. Its strong point is that outliers hardly affect it. |
| quartile deviation (semi-interquartile range) | The interquartile range divided by 2. It is a guide to how far on either side of the median the middle half of the data is spread. |
| box plot (box-and-whisker plot) | A diagram that shows five values, the minimum, \(Q_1\), the median, \(Q_3\) and the maximum (the five-number summary), as a "box" and "whiskers" above a number line. It is good for comparing the spread of several data sets side by side. In US schools it is first taught in Grade 6 and used again in high school statistics. |
| whisker | A line that extends to the left or right from the box in a box plot. In the basic form, it runs to the minimum or the maximum. In the style that shows outliers separately, it stops at the smallest or largest value that is not an outlier, and outliers are plotted as separate dots. |
| outlier | A value extremely far from the other values. A commonly used guide is the 1.5×IQR rule (values below \(Q_1 - 1.5 \times \mathrm{IQR}\), or above \(Q_3 + 1.5 \times \mathrm{IQR}\)). |
| measure of center | A single number that sums up where the data is centered, such as the mean, the median or the mode. Quartiles extend the idea of the median to "the points that cut the data into four parts". |
| range | The maximum minus the minimum. It shows how widely all the data is spread, but its weak point is that a single outlier can change it a lot. The interquartile range makes up for this. |
Good to know before you start
Here is what helps you use the calculation on this page with real understanding, not just by pressing the button.
If you get stuck, going back to review these topics is the fastest way forward.
| Comparing numbers and the number line (elementary school to Grade 6) |
|
| Measures of center such as the mean and the median (Grade 6) |
|
| Box plots and the interquartile range (Grade 6) |
|
| Working with decimals and fractions (Grades 5–6) |
|
| Data analysis (high school statistics) |
|
How to calculate it in Excel
| Value 1 (enter in order from smallest) | 2 |
| Value 2 | 3 |
| Value 3 | 4 |
| Value 4 | 5 |
| Value 5 | 6 |
| Value 6 | 7 |
| Value 7 | 7 |
| Value 8 | 7 |
| Value 9 | 8 |
| Value 10 | 10 |
| Median Q2 (median of all the data) | =MEDIAN(B1:B10) |
| First quartile Q1 (median of the lower half = first 5 values) | =MEDIAN(B1:B5) |
| Third quartile Q3 (median of the upper half = last 5 values) | =MEDIAN(B6:B10) |
| Interquartile range IQR | =B13-B12 |
| Quartile deviation | =B14/2 |
| Value 1 | 2 |
| Value 2 | 3 |
| Value 3 | 4 |
| Value 4 | 5 |
| Value 5 | 6 |
| Value 6 | 7 |
| Value 7 | 7 |
| Value 8 | 7 |
| Value 9 | 8 |
| Value 10 | 10 |
| Q1 (QUARTILE.INC) | =QUARTILE.INC(B1:B10,1) |
| Q2 (QUARTILE.INC) | =QUARTILE.INC(B1:B10,2) |
| Q3 (QUARTILE.INC) | =QUARTILE.INC(B1:B10,3) |
| First quartile Q1 | 4 |
| Third quartile Q3 | 7 |
| Interquartile range IQR | =B2-B1 |
| Lower fence Q1−1.5×IQR | =B1-1.5*B3 |
| Upper fence Q3+1.5×IQR | =B2+1.5*B3 |
The QUARTILE.INC function in the second table uses a different method that interpolates between data values, so its results can differ from the median-of-halves method. For the same data, QUARTILE.INC returns Q1 = 4.25, which differs from Q1 = 4 in the first table (in this example Q2 = 6.5 and Q3 = 7 happen to match). To check homework answers, use the first table.
The third table gives the outlier fences: −0.5 for the lower fence and 11.5 for the upper fence. Data values below the lower fence (−0.5), or above the upper fence (11.5), are outliers.
How to calculate it in Google Sheets
| Value 1 (enter in order from smallest) | 2 |
| Value 2 | 3 |
| Value 3 | 4 |
| Value 4 | 5 |
| Value 5 | 6 |
| Value 6 | 7 |
| Value 7 | 7 |
| Value 8 | 7 |
| Value 9 | 8 |
| Value 10 | 10 |
| Median Q2 (median of all the data) | =MEDIAN(B1:B10) |
| First quartile Q1 (median of the lower half = first 5 values) | =MEDIAN(B1:B5) |
| Third quartile Q3 (median of the upper half = last 5 values) | =MEDIAN(B6:B10) |
| Interquartile range IQR | =B13-B12 |
| Quartile deviation | =B14/2 |
| Value 1 | 2 |
| Value 2 | 3 |
| Value 3 | 4 |
| Value 4 | 5 |
| Value 5 | 6 |
| Value 6 | 7 |
| Value 7 | 7 |
| Value 8 | 7 |
| Value 9 | 8 |
| Value 10 | 10 |
| Q1 (QUARTILE) | =QUARTILE(B1:B10,1) |
| Q2 (QUARTILE) | =QUARTILE(B1:B10,2) |
| Q3 (QUARTILE) | =QUARTILE(B1:B10,3) |
| First quartile Q1 | 4 |
| Third quartile Q3 | 7 |
| Interquartile range IQR | =B2-B1 |
| Lower fence Q1−1.5×IQR | =B1-1.5*B3 |
| Upper fence Q3+1.5×IQR | =B2+1.5*B3 |
How to calculate it in Python
# data (replace with your own comma-separated values)
data = [3, 7, 7, 4, 10, 8, 6, 5, 7, 2]
def median(sorted_values):
# median of a sorted list (for an even count, the mean of the two middle values)
count = len(sorted_values)
middle = count // 2
if count % 2 == 1:
return sorted_values[middle]
return (sorted_values[middle - 1] + sorted_values[middle]) / 2
values = sorted(data)
n = len(values)
lower_half = values[: n // 2] # lower half (for an odd count, the first half without the median)
upper_half = values[(n + 1) // 2:] # upper half (the second half, in the same way)
q1 = median(lower_half)
q2 = median(values)
q3 = median(upper_half)
iqr = q3 - q1
quartile_deviation = iqr / 2
fence_low = q1 - 1.5 * iqr
fence_high = q3 + 1.5 * iqr
outliers = [v for v in values if v < fence_low or v > fence_high]
print(f"Q1 = {q1}, Q2 (median) = {q2}, Q3 = {q3}")
print(f"Interquartile range IQR = {iqr}, quartile deviation = {quartile_deviation}")
print(f"Outliers (1.5×IQR rule): {outliers if outliers else 'None'}")
How to write it in LaTeX and other math languages (copy and paste)
Q₂ = Med(all data), Q₁ = Med(lower half), Q₃ = Med(upper half)
Q_2 = \mathrm{Med}(\text{all data}),\quad Q_1 = \mathrm{Med}(\text{lower half}),\quad Q_3 = \mathrm{Med}(\text{upper half})
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mrow>
<msub><mi>Q</mi><mn>2</mn></msub><mo>=</mo>
<mi>Med</mi><mo>(</mo><mtext>all data</mtext><mo>)</mo>
<mo>,</mo>
<msub><mi>Q</mi><mn>1</mn></msub><mo>=</mo>
<mi>Med</mi><mo>(</mo><mtext>lower half</mtext><mo>)</mo>
<mo>,</mo>
<msub><mi>Q</mi><mn>3</mn></msub><mo>=</mo>
<mi>Med</mi><mo>(</mo><mtext>upper half</mtext><mo>)</mo>
</mrow>
</math>
Q_2 = "Med"("all data"), Q_1 = "Med"("lower half"), Q_3 = "Med"("upper half")
q2 = Median[data]; q1 = Median[lower]; q3 = Median[upper] (* lower/upper = the lower and upper halves split at the median *)
q2 := Statistics:-Median(data); q1 := Statistics:-Median(lower); q3 := Statistics:-Median(upper);
q2 = median(x); q1 = median(lower); q3 = median(upper);
Q_2 = Med(all data), Q_1 = Med(lower half), Q_3 = Med(upper half)
IQR = Q₃ − Q₁, quartile deviation = IQR ÷ 2
\mathrm{IQR} = Q_3 - Q_1,\quad \text{quartile deviation} = \dfrac{\mathrm{IQR}}{2}
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mrow>
<mi>IQR</mi><mo>=</mo>
<msub><mi>Q</mi><mn>3</mn></msub>
<mo>−</mo>
<msub><mi>Q</mi><mn>1</mn></msub>
<mo>,</mo>
<mtext>quartile deviation</mtext><mo>=</mo>
<mfrac><mi>IQR</mi><mn>2</mn></mfrac>
</mrow>
</math>
IQR = Q_3 - Q_1, "quartile deviation" = IQR / 2
iqr = q3 - q1; quartileDeviation = iqr/2
iqr := q3 - q1; qd := iqr/2;
iqr_value = q3 - q1; qd = iqr_value/2;
IQR = Q_3 − Q_1, quartile deviation = IQR/2
x < Q₁ − 1.5×IQR or x > Q₃ + 1.5×IQR
x < Q_1 - 1.5 \times \mathrm{IQR} \quad \text{or} \quad x > Q_3 + 1.5 \times \mathrm{IQR}
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mrow>
<mi>x</mi><mo><</mo>
<msub><mi>Q</mi><mn>1</mn></msub>
<mo>−</mo>
<mn>1.5</mn><mo>×</mo><mi>IQR</mi>
<mtext> or </mtext>
<mi>x</mi><mo>></mo>
<msub><mi>Q</mi><mn>3</mn></msub>
<mo>+</mo>
<mn>1.5</mn><mo>×</mo><mi>IQR</mi>
</mrow>
</math>
x < Q_1 - 1.5 xx IQR " or " x > Q_3 + 1.5 xx IQR
Select[data, # < q1 - 1.5 iqr || # > q3 + 1.5 iqr &]
select(v -> v < q1 - 1.5*iqr or v > q3 + 1.5*iqr, data);
outliers = x(x < q1 - 1.5*iqr | x > q3 + 1.5*iqr);
x < Q_1 − 1.5×IQR or x > Q_3 + 1.5×IQR
How to have ChatGPT do the calculation
You are a calculation assistant for statistics (data analysis). Do the following calculation by actually running Python code, and base your answer only on the numbers from the execution result (do not answer by mental math or guessing). Calculate the quartiles of the following data with the median-of-halves method taught in school textbooks. Data: 3, 7, 7, 4, 10, 8, 6, 5, 7, 2 The method: sort the data from smallest to largest and split it at the median into a lower half and an upper half (with an odd number of values, the median goes in neither half). The first quartile Q1 is the median of the lower half, and the third quartile Q3 is the median of the upper half. Do not use functions that interpolate, such as statistics.quantiles. Show each of the following: 1. The sorted data and how it is split into the lower half and the upper half 2. The values of Q1, the median Q2 and Q3 3. The interquartile range IQR and the quartile deviation 4. The outliers by the 1.5×IQR rule (values below Q1 − 1.5×IQR, or above Q3 + 1.5×IQR)
How to Use
-
1Enter your numbersType the numbers you want to calculate with into the input fields
-
2CalculatePress the "Calculate" button
-
3Check the resultThe result appears on the spot. The same page also explains the idea behind the calculation and the formula
DataChef Features
No technical knowledge required.
Intuitive and user-friendly operation.
Can be used without registering personal information.
Automatic file deletion by clicking "download".
and rapid file conversion.
No attribution required.
No need to contact us for commercial use permission.
