Bookmarks    
nPr and nCr    
Random Number    
SD Calculator    
Sample Size    
Percent Error    
Density    
Molarity    
Molar Mass    
Ohm's Law    
Watts to Amps    
Voltage Drop    
Long Division    
Mixed Numbers    
Rounding    
Nth Root    
Exponents    
Half-Life    
Polar Form    
De Moivre    
3D Distance    
Point to Line    
Cross Product    
Determinant    
Sin Cos Tan    
Triangle Area    
Scale Factor    
Sector Area    
Ellipse Area    
Cube Volume    
Box Volume    
Sphere Volume    
Cone Volume    
Pipe Volume    
Time Duration    
Time Card    
Present Value    
Future Value    
Churn Rate    
A/B Test Calc    
SEO Traffic    
Ideal Weight    
Fat Intake    
Child Height    
Golf Handicap    
Heat Index    
Wind Chill    
Dew Point    
Download Time    
kWh to Cost    
AC Size (BTU)    
Heating Costs    
LED Savings    
Trip Gas Cost    
Tire Size    
Solar Output    
Solar Payback    
Battery Size    
Wall Area    
Gravel Needed    
Mortar Mix    
Slope Grade    
Curtain Size    
Soil Needed    
Sod Needed    
Ramp Length    
Blind Size    
Drain Slope    
Board Feet    
Heat Loss    
Furniture Fit    
Moving Boxes    
Plywood Cuts    
Shelf Sag    
   Add
Probability and random number calculators
Independent Events
Independent Events
Two Events Solver
Two Events Solver
Repeated Trials
Repeated Trials
Bayes' Theorem
Bayes' Theorem
Expected Value
Expected Value
Binomial Distribution
Binomial Distribution
nPr and nCr
nPr and nCr
Circular Permutation
Circular Permutation
With Repetition
With Repetition
Random Number
Random Number
Averages and statistics calculators
Average Calculator
Average Calculator
Mean Median Mode
Mean Median Mode
SD Calculator
SD Calculator
Quartiles & IQR
Quartiles & IQR
Frequency Table
Frequency Table
Correlation (r)
Correlation (r)
Normal Probability
Normal Probability
Z-Score Calculator
Z-Score Calculator
Confidence Interval
Confidence Interval
Sample Size
Sample Size
Mark & Recapture
Mark & Recapture
P-Value Calculator
P-Value Calculator
Percentage and ratio calculators
Percentage Calc
Percentage Calc
Percent Change
Percent Change
Percent Difference
Percent Difference
Percent Error
Percent Error
Ratio Calculator
Ratio Calculator
Discount Calculator
Discount Calculator
Sales Tax Calculator
Sales Tax Calculator
Margin Calculator
Margin Calculator
Speed calculators
Speed Calculator
Speed Calculator
Density and concentration calculators
Density
Density
Molarity
Molarity
Molar Mass
Molar Mass
Physics and electricity calculators
Ohm's Law
Ohm's Law
Watts to Amps
Watts to Amps
Resistor Colors
Resistor Colors
Voltage Drop
Voltage Drop
Unit conversion calculators
Weight Converter
Weight Converter
Shoe Size Converter
Shoe Size Converter
Integer and signed number calculators
Long Division
Long Division
LCM Calculator
LCM Calculator
GCF Calculator
GCF Calculator
Integer Calculator
Integer Calculator
Prime Factorization
Prime Factorization
Diophantine Solver
Diophantine Solver
Modulo Calculator
Modulo Calculator
Factor Calculator
Factor Calculator
Roman Numerals
Roman Numerals
Fraction, decimal and rounding calculators
Fraction Calculator
Fraction Calculator
Mixed Numbers
Mixed Numbers
Simplify Fractions
Simplify Fractions
Fraction to Decimal
Fraction to Decimal
Decimal to Fraction
Decimal to Fraction
Rounding
Rounding
Equation and inequality calculators
Linear Equation
Linear Equation
Linear Systems
Linear Systems
Quadratic Formula
Quadratic Formula
Absolute Value
Absolute Value
Quadratic Inequality
Quadratic Inequality
Polynomial calculators
Binomial Theorem
Binomial Theorem
Square root and nth root calculators
Simplify Radicals
Simplify Radicals
Nth Root
Nth Root
Exponent and logarithm calculators
Exponents
Exponents
Log Calculator
Log Calculator
Number of Digits
Number of Digits
Scientific Notation
Scientific Notation
Sci. Notation Math
Sci. Notation Math
Half-Life
Half-Life
Complex number calculators
Complex Numbers
Complex Numbers
Polar Form
Polar Form
De Moivre
De Moivre
Function and graph calculators
Slope Calculator
Slope Calculator
Linear Function
Linear Function
Direct & Inverse Variation
Direct & Inverse Variation
y = ax² Calculator
y = ax² Calculator
Distance Formula
Distance Formula
3D Distance
3D Distance
Section Formula
Section Formula
Point to Line
Point to Line
Lat/Long Distance
Lat/Long Distance
Complete the Square
Complete the Square
Circle Equation
Circle Equation
Conic Sections
Conic Sections
Polar Coordinates
Polar Coordinates
Sequence calculators
Arithmetic Sequence
Arithmetic Sequence
Geometric Sequence
Geometric Sequence
Fibonacci Sequence
Fibonacci Sequence
Recurrence Relation
Recurrence Relation
Vector calculators
Vector Calculator
Vector Calculator
Cross Product
Cross Product
Matrix calculators
Matrix Calculator
Matrix Calculator
Determinant
Determinant
Inverse Matrix
Inverse Matrix
Plane geometry calculators
Sin Cos Tan
Sin Cos Tan
Degrees ⇔ Radians
Degrees ⇔ Radians
a sin θ + b cos θ
a sin θ + b cos θ
Triangle Solver
Triangle Solver
Triangle Area
Triangle Area
Right Triangle
Right Triangle
Pythagorean Theorem
Pythagorean Theorem
Polygon Angles
Polygon Angles
Scale Factor
Scale Factor
Parallel Lines
Parallel Lines
Rectangle Area
Rectangle Area
Parallelogram Area
Parallelogram Area
Trapezoid Area
Trapezoid Area
Circle Calculator
Circle Calculator
Sector Area
Sector Area
Inscribed Angle
Inscribed Angle
Ellipse Area
Ellipse Area
Solid geometry calculators
Cube Volume
Cube Volume
Cube Surface Area
Cube Surface Area
Box Volume
Box Volume
Box Surface Area
Box Surface Area
Cylinder Volume
Cylinder Volume
Cylinder Surface
Cylinder Surface
Sphere Volume
Sphere Volume
Sphere Surface
Sphere Surface
Spherical Cap Volume
Spherical Cap Volume
Cap Surface Area
Cap Surface Area
Ellipsoid Volume
Ellipsoid Volume
Ellipsoid Surface
Ellipsoid Surface
Pyramid Volume
Pyramid Volume
Pyramid Surface
Pyramid Surface
Cone Volume
Cone Volume
Cone Surface Area
Cone Surface Area
Frustum Volume
Frustum Volume
Frustum Surface Area
Frustum Surface Area
Pipe Volume
Pipe Volume
Capsule Volume
Capsule Volume
Capsule Surface Area
Capsule Surface Area
Date and time calculators
Age Calculator
Age Calculator
Days Between Dates
Days Between Dates
Date Calculator
Date Calculator
Hours From Now
Hours From Now
Day of the Week
Day of the Week
Time Calculator
Time Calculator
Time Zone Converter
Time Zone Converter
Hours Calculator
Hours Calculator
Time Duration
Time Duration
Time Card
Time Card
Finance and economics calculators
Compound Interest
Compound Interest
Simple Interest
Simple Interest
Interest Calculator
Interest Calculator
TVM Calculator
TVM Calculator
Present Value
Present Value
Future Value
Future Value
ROI Calculator
ROI Calculator
IRR Calculator
IRR Calculator
Payback Period
Payback Period
Average Return
Average Return
GDP Calculator
GDP Calculator
Web marketing and ad metric calculators
CTR Calculator
CTR Calculator
Conversion Rate
Conversion Rate
CPC, CPM & CPA
CPC, CPM & CPA
ROAS Calculator
ROAS Calculator
Break-Even CPA
Break-Even CPA
LTV Calculator
LTV Calculator
CAC Calculator
CAC Calculator
Churn Rate
Churn Rate
A/B Test Calc
A/B Test Calc
A/B Sample Size
A/B Sample Size
SEO Traffic
SEO Traffic
Break-Even Point
Break-Even Point
Markup vs. Margin
Markup vs. Margin
CAGR Calculator
CAGR Calculator
Health and fitness calculators
BMI Calculator
BMI Calculator
Sleep Calculator
Sleep Calculator
Calorie Calculator
Calorie Calculator
BMR Calculator
BMR Calculator
TDEE Calculator
TDEE Calculator
Ideal Weight
Ideal Weight
Body Fat Calculator
Body Fat Calculator
Lean Body Mass
Lean Body Mass
Calories Burned
Calories Burned
Protein Intake
Protein Intake
Macro Calculator
Macro Calculator
Carb Calculator
Carb Calculator
Fat Intake
Fat Intake
Child Height
Child Height
Sports calculators
Golf Handicap
Golf Handicap
Pace Calculator
Pace Calculator
1RM Calculator
1RM Calculator
Target Heart Rate
Target Heart Rate
Weather calculators
Heat Index
Heat Index
Wind Chill
Wind Chill
Dew Point
Dew Point
Computer calculators
Base Converter
Base Converter
Subnet Calculator
Subnet Calculator
Download Time
Download Time
Household energy and budget calculators
Electricity Cost
Electricity Cost
kWh to Cost
kWh to Cost
Yearly kWh to Cost
Yearly kWh to Cost
AC Size (BTU)
AC Size (BTU)
AC Running Cost
AC Running Cost
Heating Costs
Heating Costs
Gas vs Electric
Gas vs Electric
LED Savings
LED Savings
Salary Calculator
Salary Calculator
Budget Calculator
Budget Calculator
Car calculators
Trip Gas Cost
Trip Gas Cost
EV Charging Cost
EV Charging Cost
EV vs Gas Cost
EV vs Gas Cost
MPG Calculator
MPG Calculator
Tire Size
Tire Size
Solar power and battery calculators
Solar Output
Solar Output
Solar Panel Count
Solar Panel Count
Solar Payback
Solar Payback
Battery Size
Battery Size
Home and DIY calculators
Tile Calculator
Tile Calculator
Stair Calculator
Stair Calculator
Concrete Volume
Concrete Volume
Wall Area
Wall Area
Wallpaper Rolls
Wallpaper Rolls
Paint Calculator
Paint Calculator
Flooring Needed
Flooring Needed
Exterior Walls
Exterior Walls
Gravel Needed
Gravel Needed
Mortar Mix
Mortar Mix
Slope Grade
Slope Grade
Lumber Cut List
Lumber Cut List
Lot Coverage/FAR
Lot Coverage/FAR
Sheet Vinyl Roll
Sheet Vinyl Roll
Insulation Needed
Insulation Needed
Curtain Size
Curtain Size
TV Size & Distance
TV Size & Distance
Soil Needed
Soil Needed
Sod Needed
Sod Needed
Block Calculator
Block Calculator
Brick Calculator
Brick Calculator
Deck Materials
Deck Materials
Ramp Length
Ramp Length
Pilot Hole Size
Pilot Hole Size
Room Ventilation
Room Ventilation
Paint Thinning
Paint Thinning
Baseboard & Trim
Baseboard & Trim
Blind Size
Blind Size
Picture Hanging
Picture Hanging
Drain Slope
Drain Slope
Screw Calculator
Screw Calculator
Board Feet
Board Feet
Fence Calculator
Fence Calculator
Wood Shrinkage
Wood Shrinkage
Caulk Calculator
Caulk Calculator
Heat Loss
Heat Loss
Furniture Fit
Furniture Fit
Moving Boxes
Moving Boxes
Storage Capacity
Storage Capacity
Plywood Cuts
Plywood Cuts
Shelf Sag
Shelf Sag

Quartile and Box Plot Calculator (Q1, Q2, Q3, IQR, Outliers)

Enter your data values separated by commas (,) or spaces. They can be in any order (they are sorted from smallest to largest when calculated).

Separate the numbers with commas or spaces (data pasted with one value per line works as is). Negative numbers and decimals are OK.
Result and graph
Enter your data values in the field on the left and press "Calculate". The result and a box plot will appear here.

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
This page focuses on quartiles and box plots. To find the mean, the mode or the range (maximum − minimum), use the related page "Mean, Median, Mode and Range Calculator".

What is this calculation used for?

Looking at test results as a distribution (school and tests)

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.

Reading data where the average feels wrong, such as pay (statistics and economics)

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.

Screening for measurement errors and unusual values (quality control and data analysis)

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.

Comparing how consistent records are (sports and weather)

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

How to find the quartiles (Q1, Q2, Q3)
Figure
Standard notation (the usual math form)
\(Q_2\) \(=\) \(\text{median of all the data}\)
\(Q_1\) \(=\) \(\text{median of the lower half}\)
\(Q_3\) \(=\) \(\text{median of the upper half}\)
In words (symbols replaced with words)
① \(Q_2\): median (second quartile) \(=\) median of all the data
\(Q_1\): first quartile \(=\) ② median of the lower half
\(Q_3\): third quartile \(=\) ③ median of the upper half
The formula in words
① Sort the data from smallest to largest. Use the \(Q_2\): median (second quartile) to split the data into a lower half and an upper half (with an odd number of values, the median goes in neither half)
② The median of the lower half is the first quartile \(Q_1\)
③ The median of the upper half is the third quartile \(Q_3\)
Quick example
For the 9 values 1, 2, 3, 4, 5, 6, 7, 8, 9, leave out the median 5. The lower half is 1, 2, 3, 4 and the upper half is 6, 7, 8, 9, so
\(Q_2\): median \(=\) 5th value from the smallest (5)
\(Q_1\): first quartile \(=\) median of the lower half 1, 2, 3, 4
\(Q_3\): third quartile \(=\) median of the upper half 6, 7, 8, 9
\(Q_2 = 5\)
\(Q_1 = \dfrac{2 + 3}{2} = 2.5\)
\(Q_3 = \dfrac{7 + 8}{2} = 7.5\)
Key idea
Quartiles are the three values that divide sorted data into four parts with equal numbers of values. About 25% of the data falls in each part: up to \(Q_1\), from \(Q_1\) to \(Q_2\), from \(Q_2\) to \(Q_3\), and from \(Q_3\) up. \(Q_2\) is exactly in the middle of all the data, so it is the median itself. There are several methods for finding quartiles. This page uses the median-of-halves method taught in most school textbooks (the same one TI-84 calculators use). Functions such as QUARTILE.INC in Excel use a different method that interpolates between data values, so their results can differ slightly from this page (the Excel section below explains more).
Interquartile range (IQR) and quartile deviation
Standard notation (the usual math form)
\(\text{IQR}\) \(=\) \(Q_3\) \(-\) \(Q_1\)
\(\text{quartile deviation}\) \(=\) \(\text{IQR}\) \(\div\) \(2\)
In words (symbols replaced with words)
③ IQR: interquartile range \(=\) ① \(Q_3\): third quartile \(-\) ② \(Q_1\): first quartile
⑤ quartile deviation \(=\) ④ IQR: interquartile range \(\div\) \(2\)
The formula in words
① Take the \(Q_3\): third quartile
② subtract the \(Q_1\): first quartile
③ and you get the IQR: interquartile range (the width of the "box" in a box plot).
④ Divide the IQR: interquartile range by 2
⑤ and you get the quartile deviation
Quick example
For the 9 values 1 to 9 (\(Q_1 = 2.5\), \(Q_3 = 7.5\))
IQR: interquartile range \(=\) third quartile (7.5) \(-\) first quartile (2.5)
\(7.5 - 2.5 = 5\)
\(5 \div 2 = 2.5\)
Key idea
The interquartile range IQR is the width that holds the middle 50% or so of the data, and it measures how spread out the data is. Unlike the range (maximum − minimum), it is hardly affected by extreme values at either end (outliers), which is its strength. IQR stands for interquartile range. The quartile deviation (also called the semi-interquartile range) is half of the IQR. It is used as a guide to spread: the middle half of the data lies within about this distance on either side of the median.
Finding outliers (the 1.5 × IQR rule)
Figure
Standard notation (the usual math form)
\(x\) \(<\) \(Q_1\) \(-\) \(1.5 \times \text{IQR}\)
\(x\) \(>\) \(Q_3\) \(+\) \(1.5 \times \text{IQR}\)
In words (symbols replaced with words)
④ \(x\): data value \(<\) ① \(Q_1\): first quartile \(-\) ② 1.5 times the IQR
\(x\): data value \(>\) ③ \(Q_3\): third quartile \(+\) 1.5 times the IQR
The formula in words
① A value is treated as an outlier if it is below the \(Q_1\): first quartile
② minus 1.5 times the IQR , or above
③ the \(Q_3\): third quartile plus the same amount.
④ Such a \(x\): data value is flagged as a likely outlier
Quick example
For the 7 values 10, 11, 12, 13, 14, 15, 40 (\(Q_1 = 11\), \(Q_3 = 15\), interquartile range 4)
data value (40) \(>\) third quartile (15) \(+\) 1.5 times the IQR (6)
\(Q_3 + 1.5 \times 4 = 15 + 6 = 21\)
\(40 > 21\)
Key idea
The 1.5×IQR rule is a common rule of thumb: a value that is more than 1.5 box widths away from the end of the box is treated as extremely far from the rest. It is taught in school statistics as one standard way to identify outliers, but it is not an absolute definition, and some fields use other rules. Like most US textbooks, graphing calculators and statistics software, this page uses strict inequalities (< and >), so a value exactly on a fence is not an outlier. Some textbooks, such as those in Japan, count a value exactly on a fence as an outlier (≤ and ≥). The two only differ when a value lands exactly on a fence. In the basic box plot, the whiskers run all the way to the minimum and the maximum. In the style that shows outliers separately, the whiskers stop at the smallest and largest values that are not outliers, and each outlier is plotted as its own dot (the box plot on this page uses this style, often called a modified box plot). An outlier is not always a wrong value. It may be a typing or measuring mistake, or it may be a truly unusual value, so do not throw it away automatically. It is important to check why the value came out that way.
To find the quartiles \(Q_1\), \(Q_2\) and \(Q_3\), sort the data, split it at the median \(Q_2\) into a lower half and an upper half, and take the median of each half (with an odd number of values, the median goes in neither half). The interquartile range \(\mathrm{IQR} = Q_3 - Q_1\) is the width that holds the middle 50% or so of the data, and it is the width of the "box" in a box plot.

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)
  • Being able to sort numbers, including decimals and negative numbers, from smallest to largest
  • Being able to picture where each value sits on a number line
Measures of center such as the mean and the median (Grade 6)
  • Knowing that the median is the middle value of the sorted data, and the mean of the two middle values when there is an even number of values
  • Knowing that the mean and the median are different values, and that the mean moves much more when there is an extreme value
Box plots and the interquartile range (Grade 6)
  • Being able to draw a box plot from the five values: the minimum, \(Q_1\), the median, \(Q_3\) and the maximum
  • Knowing that the width of the box shows the interquartile range, and that a smaller box means the middle half of the data is more tightly packed
Working with decimals and fractions (Grades 5–6)
  • Being able to calculate the mean of two values, \(\dfrac{a + b}{2}\) (example: \(\dfrac{2 + 3}{2} = 2.5\))
  • Being able to multiply by a decimal such as 1.5 (example: \(4 \times 1.5 = 6\))
Data analysis (high school statistics)
  • Knowing that the range, the interquartile range, the variance and the standard deviation all measure spread, and that each is best in different situations
  • Being able to read the shape of a distribution (where the peak is, which way it leans) from a histogram or a box plot

How to calculate it in Excel

Copy the whole table below and paste it into cell A1 in Excel. It works as is.
Table to find the quartiles with the median-of-halves method (example with 10 values)
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
Table to compare with the Excel quartile function QUARTILE.INC (same data)
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)
Table to find the outlier fences (1.5×IQR rule)
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 first table finds the quartiles with the same median-of-halves method as this page. Enter the data sorted from smallest to largest, and use the MEDIAN function on three ranges: all the data, the first half and the second half. In this example (10 values), the first half is B1:B5 and the second half is B6:B10, giving Q2 = 6.5, Q1 = 4, Q3 = 7, IQR = 3 and quartile deviation = 1.5. With an odd number of values, leave out the one in the middle when you set the ranges for the two halves (for 9 values, B1:B4 and B6:B9).
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

Copy the whole table below and paste it into cell A1 in Google Sheets. It works as is.
Table to find the quartiles with the median-of-halves method (example with 10 values)
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
Table to compare with the Google Sheets quartile function QUARTILE (same data)
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)
Table to find the outlier fences (1.5×IQR rule)
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 same formulas as in Excel work as is. Copy the whole table and paste it into cell A1. The QUARTILE function in Google Sheets uses the same interpolation as QUARTILE.INC in Excel, so its results can differ from the median-of-halves method (the first table).

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'}")
The statistics.quantiles function in the standard library interpolates between data values, which is a different method, so the median-of-halves method is calculated by hand as in this example. When you run it, it shows Q1 = 4, Q2 = 6.5, Q3 = 7, interquartile range = 3, quartile deviation = 1.5 and no outliers. Replace the contents of data and run it.

How to write it in LaTeX and other math languages (copy and paste)

How to find the quartiles (Q1, Q2, Q3)
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)
Interquartile range (IQR) and quartile deviation
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>&#x2212;</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
Finding outliers (the 1.5 × IQR rule)
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>&lt;</mo>
    <msub><mi>Q</mi><mn>1</mn></msub>
    <mo>&#x2212;</mo>
    <mn>1.5</mn><mo>&#x00D7;</mo><mi>IQR</mi>
    <mtext>&#x2003;or&#x2003;</mtext>
    <mi>x</mi><mo>&gt;</mo>
    <msub><mi>Q</mi><mn>3</mn></msub>
    <mo>+</mo>
    <mn>1.5</mn><mo>&#x00D7;</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
  1. 1
    Enter your numbers
    Type the numbers you want to calculate with into the input fields
  2. 2
    Calculate
    Press the "Calculate" button
  3. 3
    Check the result
    The result appears on the spot. The same page also explains the idea behind the calculation and the formula
  DataChef Features
Easy and Free
Unlimited conversions for free.
No technical knowledge required.
Intuitive and user-friendly operation.
No Registration Required
Available immediately after access.
Can be used without registering personal information.
Safe and Secure
Fully SSL encrypted communication.
Automatic file deletion by clicking "download".
Fast
High-speed site access
and rapid file conversion.
No Watermark
No watermark.
No attribution required.
Commercial Use Available
Free for commercial use.
No need to contact us for commercial use permission.