This article needs additional citations for verification. (January 2013) (Learn how and when to remove this template message)
- the sample minimum (smallest observation)
- the lower quartile or first quartile
- the median (the middle value)
- the upper quartile or third quartile
- the sample maximum (largest observation)
In addition to the median of a single set of data there are two related statistics called the upper and lower quartiles. If data are placed in order, then the lower quartile is central to the lower half of the data and the upper quartile is central to the upper half of the data. These quartiles are used to calculate the interquartile range, which helps to describe the spread of the data, and determine whether or not any data points are outliers.
Use and representation
The five-number summary provides a concise summary of the distribution of the observations. Reporting five numbers avoids the need to decide on the most appropriate summary statistic. The five-number summary gives information about the location (from the median), spread (from the quartiles) and range (from the sample minimum and maximum) of the observations. Since it reports order statistics (rather than, say, the mean) the five-number summary is appropriate for ordinal measurements, as well as interval and ratio measurements.
It is possible to quickly compare several sets of observations by comparing their five-number summaries, which can be represented graphically using a boxplot.
The five-number summary is sometimes represented as in the following table:
|1st quartile||3rd quartile|
This example calculates the five-number summary for the following set of observations: 0, 0, 1, 2, 63, 61, 27, 13. These are the number of moons of each planet in the Solar System.
It helps to put the observations in ascending order: 0, 0, 1, 2, 13, 27, 61, 63. There are eight observations, so the median is the mean of the two middle numbers, (2 + 13)/2 = 7.5. Splitting the observations either side of the median gives two groups of four observations. The median of the first group is the lower or first quartile, and is equal to (0 + 1)/2 = 0.5. The median of the second group is the upper or third quartile, and is equal to (27 + 61)/2 = 44. The smallest and largest observations are 0 and 63.
So the five-number summary would be 0, 0.5, 7.5, 44, 63.
Example in R
It is possible to calculate the five-number summary in the R programming language using the
fivenum function. The
summary function, when applied to a vector, displays the five-number summary together with the mean (which is not itself a part of the five-number summary).
> moons <- c(0, 0, 1, 2, 63, 61, 27, 13) > fivenum(moons)  0.0 0.5 7.5 44.0 63.0 > summary(moons) Min. 1st Qu. Median Mean 3rd Qu. Max. 0.0 0.5 7.5 20.88 44.0 63
Example in Python
This python example uses Python3 and the numerical library
import numpy as np moons = np.array([0, 0, 1, 2, 63, 61, 27, 13]) tukey = [np.min(moons), np.percentile(moons, 25, interpolation='midpoint'), np.median(moons), np.percentile(moons, 75, interpolation='midpoint'), np.max(moons)] for v in tukey: print(v)
0 0.5 7.5 44.0 63
Example in SAS
You can use
PROC UNIVARIATE in SAS (software) to get the five number summary:
input x @@;
1 2 3 4 20 202 392 4 38 20
ods select Quantiles; proc univariate data = fivenum;
output out = fivenums min = min Q1 = Q1 Q2 = median Q3 = Q3 max = max;
proc print data = fivenums;
Example in Stata
input byte y 0 0 1 2 63 61 27 13 end list tabstat y, statistics(min q max)
- David C. Hoaglin, Frederick Mosteller and John W. Tukey. "Understanding robust and exploratory data analysis". Wiley, 1983. ISBN 0-471-09777-2.
- Cambridge university(2016). "Chapter 9 statistics". Retrieved 11 August 2016, from http://cambridge.edu.au/go/resource/?pid=1145