The mean $\bar{x}$ uniquely minimizes the sum of squared deviations, since $\sum (x_i - c)^2 = \sum (x_i - \bar{x})^2 + n(\bar{x} - c)^2$, and a median minimizes the sum of absolute deviations. The median, the trimmed mean and the interquartile range resist wild values. On eleven NHANES systolic pressures, entering 170.7 as 1707.0 moves the mean from 126.55 to 266.21 mm Hg and the standard deviation from 23.52 to 478.21, but not the median (120.0) or the interquartile range (32.65). That range is 41.30 by another quartile method. Under $y = a + bx$, centers become $a + b(\cdot)$ and spreads are multiplied by $|b|$. What to report, in short: the mean and the standard deviation for a roughly symmetric distribution, and the median and the interquartile range for a skewed one or one with outliers.
The systolic blood pressures of the 5,247 adults in the National Health and Nutrition Examination Survey (NHANES) of 2017 to 2018 (National Center for Health Statistics, 2020) have a mean of 126.36 mm Hg and a median of 123.33. Their standard deviation is 20.12 and their interquartile range is 24.67. A histogram shows the whole distribution, but a report often has room for two numbers. Which two should it give, and why do the candidates disagree? The candidates disagree because the first pair uses the size of every value and the second pair uses only their order.
The usual two answer two questions. "About how large are the values?" is answered by a measure of center (or location). "How much do they vary?" is answered by a measure of spread (or scale, or dispersion). Each question has several reasonable answers, and each answer is sensitive to different features of the data. This article is the course's home for these summaries. Later units, such as Sampling Distributions, use them without defining them again.
First we define the mean, median and mode on a hand-sized sample of eleven adults, and prove what makes the mean and the median best. Then we watch them separate under skewness and a recording error. Next come the measures of spread and their behavior under a change of units. Finally we say what to report. The uses of the standard deviation as a ruler (z-scores, the empirical rule and Chebyshev's inequality) and summaries from a frequency table are in the next article, Standard Scores, Chebyshev's Inequality and Grouped Data.
The notation is that of the course:
- $x_1, \ldots, x_n$ for a sample of $n$ values;
- $\bar{x}$ for the sample mean and $s$ for the sample standard deviation;
- Greek letters $\mu$ and $\sigma$ for the mean and standard deviation of a population.
A sample of eleven
The script draws 11 adults at random from the 5,247 (seed 11). Their mean systolic pressures, rounded to one decimal and analyzed as rounded, are, in the order drawn,
$$98.0,\ 120.0,\ 119.3,\ 156.7,\ 170.7,\ 136.0,\ 147.3,\ 102.0,\ 112.0,\ 124.0,\ 106.0,$$
and in increasing order,
$$98.0,\ 102.0,\ 106.0,\ 112.0,\ 119.3,\ 120.0,\ 124.0,\ 136.0,\ 147.3,\ 156.7,\ 170.7.$$
The sorted values are the order statistics, written $x_{(1)} \le x_{(2)} \le \cdots \le x_{(n)}$. Here $x_{(1)} = 98.0$ and $x_{(11)} = 170.7$.
Measures of center
The mean
The mean is the sum of the values divided by their number:
$$\bar{x} = \frac{1}{n}\sum_{i=1}^{n} x_i.$$
For the eleven adults the sum is 1,392.0, and $\bar{x} = 1392.0/11 = 126.55$ mm Hg. For a whole population of $N$ values, the same formula gives the population mean $\mu$. For the 5,247 adults, $\mu = 126.36$.
The mean has a physical picture: it is the balance point of the values placed as equal weights on a number line. The algebraic form of that statement is that the deviations from the mean, $x_i - \bar{x}$, sum to zero:
$$\sum_{i=1}^{n}(x_i - \bar{x}) = \sum_{i=1}^{n} x_i - n\bar{x} = n\bar{x} - n\bar{x} = 0.$$
For the eleven adults, the deviations in the order drawn are $-28.55$, $-6.55$, $-7.25$, $30.15$, $44.15$, $9.45$, $20.75$, $-24.55$, $-14.55$, $-2.55$ and $-20.55$. They add to zero, up to rounding.
Why is the mean the natural center? Suppose we summarize the data by a single number $c$, and measure the loss by the sum of squared deviations $\sum (x_i - c)^2$. The idea in one sentence: moving $c$ away from $\bar{x}$ adds a penalty that grows with the square of the distance, and the cross term that might offset it vanishes because deviations from the mean sum to zero.
Proposition 1. For any number $c$,
$$\sum_{i=1}^{n}(x_i - c)^2 = \sum_{i=1}^{n}(x_i - \bar{x})^2 + n(\bar{x} - c)^2,$$
so the sum of squared deviations is smallest, uniquely, at $c = \bar{x}$.
Proof. Write $x_i - c = (x_i - \bar{x}) + (\bar{x} - c)$ and square:
$$\sum (x_i - c)^2 = \sum (x_i - \bar{x})^2 + 2(\bar{x} - c)\sum (x_i - \bar{x}) + n(\bar{x} - c)^2.$$
The middle sum is zero by the previous identity. The last term is never negative, and is zero only when $c = \bar{x}$. $\square$
The same identity reappears in two later places. It is the decomposition of variation in one-way analysis of variance, and the reason the least-squares line passes through the point of means in Simple Linear Regression.
The median
The median is the middle value of the ordered data: half the values are at or below it and half at or above. For $n$ values,
$$\text{median} = \begin{cases} x_{((n+1)/2)} & n \text{ odd,} \\[4pt] \tfrac{1}{2}\left(x_{(n/2)} + x_{(n/2+1)}\right) & n \text{ even,} \end{cases}$$
the definition given in the NIST/SEMATECH e-Handbook (§1.3.5.1). For the eleven adults, the median is the sixth ordered value, $x_{(6)} = 120.0$ mm Hg. A twelfth adult drawn by the script (seed 12) has a pressure of 106.7. With $n = 12$, the median is the average of the sixth and seventh ordered values, $(119.3 + 120.0)/2 = 119.65$.
The median plays the same role for absolute deviations that the mean plays for squared ones. The plan of the proof: the sum of absolute deviations is a broken line in $c$. Its slope at any point counts the values below $c$ minus the values above, so it falls while fewer than half the values are below $c$ and rises after.
Proposition 2. The sum of absolute deviations $\sum |x_i - c|$ is smallest when $c$ is a median.
Proof. Let $D(c) = \sum |x_i - c|$. It is continuous in $c$, and between two neighboring order statistics it is a straight line.
Take an open interval that contains no data value, with $b$ values below it and $a = n - b$ above. Moving $c$ to the right by $\delta$, while staying in the interval, takes each of the $b$ values $\delta$ farther away and brings each of the $a$ values $\delta$ closer. So $D$ changes by $(b - a)\delta$, and the slope there is $b - a = 2b - n$. The slope is negative while $b < n/2$ and positive once $b > n/2$, and it can only increase as $c$ passes data values.
For odd $n$, the slope is negative to the left of $x_{((n+1)/2)}$ and positive to its right, so $D$ is smallest exactly at that middle value. For even $n$, the slope is negative to the left of $x_{(n/2)}$, zero between $x_{(n/2)}$ and $x_{(n/2+1)}$, and positive to the right of $x_{(n/2+1)}$. So $D$ takes its smallest value at every point of that interval, which includes the median. $\square$
The numbers for the eleven adults agree. At the mean, the sum of squared deviations is 5,531.89; at the median it is 6,003.16, which is $5{,}531.89 + 11 \times (126.55 - 120.0)^2$, as Proposition 1 requires. At the median, the sum of absolute deviations is 197.40; at the mean it is 209.04. Neither center is better in general. They answer different questions, and the difference matters most when the data are skewed or contain errors.
The mode
The mode is the most frequent value. It is the only measure of center for nominal data, such as the commonest category of race and Hispanic origin in Types of Numerical Data. It is also natural for counts: the most common household size among the NHANES adults is 2 people.
For continuous data, the mode of the raw values is fragile. The commonest single systolic value among the 5,247 adults is 125.33 mm Hg, shared by 92 people. It is closely followed by 114.0 and 116.67, with 89 each. Those counts mostly reflect which averages of even readings are possible. The NIST/SEMATECH handbook (§1.3.5.1) suggests the midpoint of the tallest histogram class as a more meaningful mode for continuous data. With classes of 10 mm Hg, the modal class is 110 to 120.
The word is used more loosely for the peaks of a histogram. A distribution with one peak is unimodal, and one with two is bimodal, often a sign that two different groups have been mixed.
Skewness and the choice of center
For the eleven adults, the mean (126.55) is above the median (120.0). For all 5,247 it is too (126.36 against 123.33). Is that a coincidence?
In a sample of eleven it could be, but for the whole survey it is not. In a symmetric distribution the mean and the median coincide. In a skewed one they separate, and the mean moves toward the long tail. The mean is affected by how far out the extreme values are, while the median is affected only by which side of the middle they are on.
| Variable | $N$ | Mean | Median | 10% trimmed mean | Skewness $g_1$ |
|---|---|---|---|---|---|
| Height of men (cm) | 2,517 | 173.53 | 173.50 | 173.52 | 0.005 |
| Systolic pressure (mm Hg) | 5,247 | 126.36 | 123.33 | 124.48 | 1.038 |
| BMI (kg/m²) | 5,176 | 29.67 | 28.40 | 28.97 | 1.206 |
The skewness in the table is the Fisher–Pearson coefficient,
$$g_1 = \frac{\frac{1}{N}\sum (x_i - \bar{x})^3}{s_N^3},$$
where $s_N$ is the standard deviation computed with divisor $N$ (NIST/SEMATECH, §1.3.5.11). Cubing the deviations keeps their signs and magnifies the large ones. So a long right tail gives a positive value, and a symmetric distribution a value near zero.
A trimmed mean drops a fixed share of the smallest and largest values before averaging; the 10% trimmed mean drops 10% at each end. It keeps most of the mean's use of the data while ignoring the tails (NIST/SEMATECH, §1.3.5.1). For the skewed variables it falls between the mean and the median.
Which center to report depends on the question. For blood pressure, the median describes the typical adult better: half the adults are below 123.33, and the mean is pulled up by a minority with very high pressures. The mean answers a different question. It is the total divided by the number of people, the quantity that matters for anything that adds up over a population, such as total doses or total costs. It is also the quantity that the sampling theory of the sampling distribution of the mean and the $t$ methods of later units estimate.
A rule with exceptions
A rule often taught with these pictures says that the mean lies on the side of the median toward the longer tail. It holds for these three variables, and it usually holds for continuous data, but it is a tendency rather than a theorem. Von Hippel (2005) collected violations. He found them most often in discrete data, where many values coincide with the median and the shares on either side of it are unequal. They occur occasionally in continuous data with several peaks, or with one long tail and one heavy one.
Skewness itself can be measured in more than one way. Galton's (or Bowley's) measure, $(Q_1 + Q_3 - 2\,\text{median})/(Q_3 - Q_1)$, uses only the quartiles (NIST/SEMATECH, §1.3.5.11). For household size, whose quartiles are 2 and 4 around a median of 3, it is exactly 0, while $g_1 = 0.656$ reflects the long tail of large households.
Resistance to errors
Skewness pulls the mean a few mm Hg from the median. A recording error can pull it much farther. Suppose the largest of the eleven pressures, 170.7, is entered as 1707.0, a slip of the decimal point.
Example (one misplaced decimal point). Of six summaries, the error changes three (the mean, the standard deviation and the range) and leaves three alone (the median, the trimmed mean and the interquartile range):
| Summary | Correct data | With the error |
|---|---|---|
| Mean | 126.55 | 266.21 |
| Median | 120.00 | 120.00 |
| Trimmed mean (one value dropped at each end) | 124.81 | 124.81 |
| Standard deviation | 23.52 | 478.21 |
| Interquartile range | 32.65 | 32.65 |
| Range | 72.7 | 1609.0 |
One bad value more than doubles the mean and multiplies the standard deviation by twenty. The median, the trimmed mean and the interquartile range stay where they were. The trimmed mean drops the bad value, and the other two never look at how far out the largest value is.
A summary that a small share of wild values cannot carry arbitrarily far is called resistant (or robust). The mean can be moved anywhere by changing a single value: changing one value by $t$ moves the mean by $t/n$, and $t$ is unlimited. The median stays within the range of the good data as long as fewer than half the values are bad.
Proof of the last claim. Suppose fewer than $n/2$ of the $n$ values are bad, and call the rest good. For odd $n$ the median is $x_{((n+1)/2)}$. At least $(n+1)/2$ values are less than or equal to it, more than the number of bad values, so one of them is good: the median is at least the smallest good value. In the same way, at least $(n+1)/2$ values are greater than or equal to it, one of them is good, and the median is at most the largest good value. For even $n$, fewer than $n/2$ bad values means at most $n/2 - 1$. At least $n/2$ values are less than or equal to $x_{(n/2)}$, so one is good, and $x_{(n/2)}$ is at least the smallest good value; then so is the larger value $x_{(n/2+1)}$. At least $n/2$ values are greater than or equal to $x_{(n/2+1)}$, so it is at most the largest good value, and then so is the smaller value $x_{(n/2)}$. Their average, the median, lies between the smallest and largest good values. $\square$
This is a reason to compute both kinds of summary when data are first examined. A large gap between the mean and the median, or between the standard deviation and what the interquartile range suggests, is often the first sign of an error, as well as of skewness.
The same tension, between using every value and resisting wild ones, runs through the measures of spread.
Measures of spread
Range
The range is the largest value minus the smallest. For the eleven adults it is $170.7 - 98.0 = 72.7$ mm Hg. It is easy to compute and to explain. But it depends on only two values, the two most likely to be unusual.
It also grows with the sample size, because a larger sample reaches further into the tails. The script drew 30 samples of each size from the 5,247 adults, with replacement. The table reports the median of the 30 values, with the middle half of them in parentheses:
| Sample size | Range | Interquartile range | Standard deviation |
|---|---|---|---|
| 10 | 70.7 (52.8 to 78.0) | 19.75 (17.88 to 25.54) | 21.70 (15.92 to 24.44) |
| 100 | 98.7 (89.2 to 111.2) | 23.25 (21.08 to 25.75) | 20.33 (18.71 to 21.14) |
| 1,000 | 144.7 (130.7 to 150.7) | 24.67 (24.00 to 25.33) | 20.30 (19.66 to 20.81) |
| Population (5,247) | 165.3 | 24.67 | 20.12 |
The range doubles between samples of 10 and of 1,000, while the other two measures settle near their population values. Ranges from samples of different sizes cannot be compared, and a range from a sample is a poor estimate of anything about the population.
Example (the range cannot outgrow the population). A sample of 100,000 drawn from the 5,247 adults, with replacement, cannot have a range above 165.3 mm Hg. Every value drawn is one of the 5,247 pressures, so the sample's largest value is at most the population's largest and its smallest at least the population's smallest. The sample range can only approach the population's own, 165.3.
Quartiles and the interquartile range
The quartiles split the ordered data into four parts with equal counts. The first quartile $Q_1$ has a quarter of the data below it, the median is the second quartile, and the third quartile $Q_3$ has three quarters below it. More generally, the $p$th percentile has (about) $p\%$ of the data below it.
The interquartile range $\mathrm{IQR} = Q_3 - Q_1$ is the width of the middle half of the data. Like the median, it is resistant, and it is the measure of spread that goes with the median in the box plots of Tables and Graphs for Data.
Why software disagrees about quartiles
Unlike the median, a quartile has no single agreed definition for a sample. With 11 values, the first quartile should have "a quarter of 11", 2.75 values, below it, and there are several defensible ways to land between data points. (For a random variable or a whole population there is one definition, the quantile function, which Random Variables and Distribution Functions develops and applies to the 5,247 pressures.)
The NIST/SEMATECH handbook (§7.2.6.2) explains its own method, the default of NIST's Dataplot software. It sets $p(n+1) = k + d$, with $k$ an integer and $0 \le d < 1$, and interpolates a share $d$ of the way from $x_{(k)}$ to $x_{(k+1)}$. For the eleven adults and $p = 0.25$, $p(n+1) = 3$, so $Q_1 = x_{(3)} = 106.0$. For $p = 0.75$, $p(n+1) = 9$, so $Q_3 = x_{(9)} = 147.3$.
The handbook then lists the alternatives in common use, referring to Hyndman and Fan's (1996) survey of nine methods in statistical software. NumPy's percentile computes types 6, 7 and 8 as its methods weibull, linear and median_unbiased (NumPy, percentile). The common methods give, for the same eleven values:
| Method | $Q_1$ | $Q_3$ | IQR |
|---|---|---|---|
| $p(n+1)$, the NIST default (Hyndman–Fan type 6) | 106.000 | 147.300 | 41.300 |
$1 + p(n-1)$, the default of R, Excel and NumPy's percentile (type 7) |
109.000 | 141.650 | 32.650 |
| $p(n + 1/3) + 1/3$, recommended by Hyndman and Fan (type 8) | 107.000 | 145.417 | 38.417 |
| Medians of the lower and upper halves, median excluded | 106.000 | 147.300 | 41.300 |
| Medians of the halves, median included (Tukey's hinges) | 109.000 | 141.650 | 32.650 |
The type 7 calculation, for instance, sets $1 + 0.25 \times 10 = 3.5$, halfway between $x_{(3)} = 106.0$ and $x_{(4)} = 112.0$, giving 109.0. It sets $1 + 0.75 \times 10 = 8.5$, halfway between $x_{(8)} = 136.0$ and $x_{(9)} = 147.3$, giving 141.65. With twelve values (adding 106.7) the methods spread differently. The type 6, 7 and 8 values of $Q_1$ are 106.175, 106.525 and 106.292, and both "halves" methods give 106.35.
For small samples these differences are large: the IQR of the eleven values is 32.65 by one method and 41.30 by another.
Example (the methods agree for the whole survey). For all 5,247 adults the methods do not disagree at all: every method in the table gives exactly 112.0 and 136.67. The reason is that the positions the methods use are never far apart. Types 6 and 7 place a quantile at positions $p(n+1)$ and $1 + p(n-1)$ in the ordered data, which differ by $2p - 1$: half a place for the quartiles, whatever $n$ is. Type 8 lies between them, and the two "halves" methods take medians of the same lower and upper halves, give or take the middle value. In a sample of eleven, half a place is half the gap between 106.0 and 112.0. Among the 5,247 pressures, which have many tied values, the order statistics around the two quartile positions are tied, so every method returns the same value.
The practical rule is to know which method a program uses, and to state it when the sample is small. The NIST handbook judges types 6, 7 and 8 all acceptable for most purposes. The library's Summarizing Data with pandas compares nine quantile definitions on ten blood pressures, and the defaults of the Python libraries for both quantiles and the standard deviation's divisor.
Variance and standard deviation
The range and the IQR use two values each. Can a measure of spread use every value, the way the mean does for center? It can, and it starts from the deviations $x_i - \bar{x}$. Their sum is always zero, so they cannot simply be averaged; squaring them removes the signs. The sample variance is
$$s^2 = \frac{1}{n-1}\sum_{i=1}^{n}(x_i - \bar{x})^2,$$
and the sample standard deviation is its square root, $s = \sqrt{s^2}$, which is in the units of the data.
For the eleven adults, the squared deviations in the order drawn are 814.84, 42.84, 52.50, 909.30, 1,949.62, 89.39, 430.75, 602.48, 211.57, 6.48 and 422.12. Their sum is 5,531.89, so
$$s^2 = \frac{5531.89}{10} = 553.19 \text{ (mm Hg)}^2, \qquad s = \sqrt{553.19} = 23.52 \text{ mm Hg}.$$
The same sum can be computed without the deviations, from $\sum (x_i - \bar{x})^2 = \sum x_i^2 - n\bar{x}^2$. To see it, expand the square and use $\sum x_i = n\bar{x}$:
$$\sum (x_i - \bar{x})^2 = \sum x_i^2 - 2\bar{x}\sum x_i + n\bar{x}^2 = \sum x_i^2 - 2n\bar{x}^2 + n\bar{x}^2 = \sum x_i^2 - n\bar{x}^2.$$
(It is also Proposition 1 with $c = 0$.) Here $181{,}683.16 - 176{,}151.27 = 5{,}531.89$. The shortcut was useful for hand calculation. In floating-point arithmetic, though, it subtracts two large, nearly equal numbers and can lose accuracy, so software uses the deviations.
Why divide by $n - 1$? The divisor is $n - 1$, not $n$, and two reasons point the same way.
- The deviations from $\bar{x}$ satisfy one constraint: they sum to zero. So only $n - 1$ of them are free to vary. Once ten are known, the eleventh is determined. These are the degrees of freedom of $s^2$.
- Dividing by $n - 1$ makes $s^2$ an unbiased estimate of the population variance, as Confidence Intervals for a Mean: z and t proves. Dividing by $n$ underestimates it on average by the factor $(n-1)/n$. The deviations are measured from the sample's own mean, which is closer to the sample than the population mean is.
With divisor $n$, the eleven adults give a variance of 502.90 and a standard deviation of 22.43.
For a whole population of $N$ values, nothing is being estimated, and the population variance and standard deviation divide by $N$:
$$\sigma^2 = \frac{1}{N}\sum_{i=1}^{N}(x_i - \mu)^2.$$
For the 5,247 adults, $\sigma = 20.12$ mm Hg. With divisor $N - 1$ it would be 20.127, a difference invisible at this size.
Example (two divisors, two purposes). "The variance is $\sum (x - \bar{x})^2/n$" and "the variance is $\sum (x_i - \bar{x})^2/(n-1)$" both appear as the definition, and a text that gives one formula in one place and the other in another is not contradicting itself. They are two quantities. The divisor $N$ gives the variance $\sigma^2$ of a complete population. The divisor $n - 1$ gives the sample variance $s^2$ that estimates it. A common misstatement is to treat them as interchangeable: for the eleven adults they are 502.90 and 553.19.
Example (adding a value can lower the standard deviation). Adding the twelfth adult, at 106.7 mm Hg, lowers the mean from 126.55 to 124.89, and it lowers the standard deviation too, from 23.52 to 23.15. The general rule: adding a value $x$ to $n$ others lowers the standard deviation exactly when $|x - \bar{x}| < s\sqrt{(n+1)/n}$, that is, when the new value lies within a little more than one standard deviation of the old mean. Here $|106.7 - 126.55| = 19.85$, below $23.52 \times \sqrt{12/11} = 24.57$.
Proof of the rule. Write $S = \sum_{i=1}^{n}(x_i - \bar{x})^2$ and $d = x - \bar{x}$. The new mean of the $n + 1$ values is $\bar{x}' = (n\bar{x} + x)/(n+1) = \bar{x} + d/(n+1)$. By Proposition 1 with $c = \bar{x}'$, the old values contribute $S + n(\bar{x} - \bar{x}')^2 = S + n d^2/(n+1)^2$ to the new sum of squares. The new value contributes $(x - \bar{x}')^2 = n^2 d^2/(n+1)^2$, since $x - \bar{x}' = d - d/(n+1)$. Together,
$$S' = S + \frac{n + n^2}{(n+1)^2}\,d^2 = S + \frac{n}{n+1}\,d^2.$$
The new variance is $S'/n$ and the old one is $s^2 = S/(n-1)$. So the variance falls exactly when $S + \frac{n}{n+1}d^2 < \frac{n}{n-1}S$, that is, when $\frac{n}{n+1}d^2 < \frac{S}{n-1} = s^2$, which is $d^2 < s^2 (n+1)/n$. $\square$
For the twelve adults, $S' = 5{,}531.89 + \tfrac{11}{12} \times 19.845^2 = 5{,}892.91$ (with $d = 19.845$ before rounding), and $\sqrt{5{,}892.91/11} = 23.15$.
Other typical distances
The standard deviation is roughly the typical distance of a value from the mean, but it weights large deviations heavily. A value 20 mm Hg from the mean adds 400 to the sum of squares; one 40 away adds 1,600 (NIST/SEMATECH, §1.3.5.6). That is why one recording error inflated it twentyfold above. Two other measures of the typical distance avoid the squaring (NIST/SEMATECH, §1.3.5.6).
- The mean absolute deviation, $\frac{1}{n}\sum |x_i - \bar{x}|$, weights each deviation by its size rather than its square. It is 19.00 for the eleven adults. It is less dominated by one large deviation than the standard deviation, but a single wild value can still move it without limit.
- The median absolute deviation (MAD), the median of $|x_i - \text{median}|$, is resistant in the sense of the previous section. It is 16.00 for the eleven adults. The library's Detecting Outliers builds modified z-scores on the median and the MAD, which flag recording errors that ordinary z-scores can mask.
The coefficient of variation
The standard deviation is in the units of the data, so it cannot compare the variability of quantities measured in different units. The coefficient of variation divides it by the mean, $\mathrm{CV} = s/\bar{x}$ (or $\sigma/\mu$), giving a unitless ratio.
Among the NHANES adults, the CV is 0.044 for men's height, 0.159 for systolic pressure and 0.249 for BMI. Relative to their averages, heights vary little and BMI varies most. The CV needs a meaningful zero, which is why Types of Numerical Data lists it among the statistics of ratio scales.
Changes of units
What happens to all these summaries when the units change? If every value is transformed by $y_i = a + b x_i$:
- the mean and the median transform the same way, $\bar{y} = a + b\bar{x}$, and so do the quartiles when $b > 0$;
- measures of spread ignore the shift and scale by $|b|$: $s_y = |b|\,s_x$ and $s_y^2 = b^2 s_x^2$, and likewise the range and the IQR.
Proof. For the mean, $\bar{y} = \frac{1}{n}\sum (a + b x_i) = a + b\,\frac{1}{n}\sum x_i = a + b\bar{x}$. Subtracting, $y_i - \bar{y} = b(x_i - \bar{x})$, so $\sum (y_i - \bar{y})^2 = b^2 \sum (x_i - \bar{x})^2$. Dividing by $n - 1$ gives $s_y^2 = b^2 s_x^2$, and the square root gives $s_y = |b|\,s_x$.
For the order-based summaries, suppose first that $b > 0$. Then $x_i \le x_j$ exactly when $y_i \le y_j$, so the order statistics correspond: $y_{(k)} = a + b\,x_{(k)}$ for every $k$. The median, and every quartile method of the table above, is an order statistic or a weighted average of two of them with fixed weights that sum to 1, so each transforms as $a + b\,(\cdot)$. The range and the IQR are differences of two such values, so the shift cancels and they are multiplied by $b$. If $b < 0$ the order reverses, $y_{(k)} = a + b\,x_{(n+1-k)}$. The middle position is its own mirror image, so the median still transforms as $a + b\,(\cdot)$. For the quartiles, each method in the table places the $p$th quantile at a position $h(p)$ in the ordered data with $h(1-p) = n + 1 - h(p)$. For type 6, $(1-p)(n+1) = n + 1 - p(n+1)$. For type 7, $1 + (1-p)(n-1) = n + 1 - \big(1 + p(n-1)\big)$. For type 8, $(1-p)(n + \tfrac13) + \tfrac13 = n + 1 - \big(p(n + \tfrac13) + \tfrac13\big)$. The two "halves" methods take medians of halves that are mirror images of each other, and a median transforms as $a + b\,(\cdot)$ by the argument just given, so the lower half's median for the $y$ values is $a + b$ times the upper half's for the $x$ values. For the three position rules, write $h(p) = k + d$ with $k$ a whole number and $0 \le d < 1$. The $p$th quantile of the $y$ values is a share $d$ of the way from $y_{(k)}$ to $y_{(k+1)}$, that is, $a + b$ times the value a share $d$ of the way from $x_{(n+1-k)}$ down to $x_{(n-k)}$. That value sits at position $n + 1 - k - d = h(1-p)$ of the $x$ values, so it is their $(1-p)$th quantile. With $p = 0.25$ and $p = 0.75$: the first quartile of the $y$ values is $a + b\,Q_3$ and the third is $a + b\,Q_1$. The range and the IQR are multiplied by $|b|$. $\square$
The statement about quartiles covers the five methods of the table. Not every quantile rule in software has the symmetry: two of NumPy's other methods, closest_observation and interpolated_inverted_cdf, do not exchange the quartiles of the eleven values when the sign is reversed. The script checks both facts.
Example (the coefficient of variation in kilopascals). Converting the NHANES pressures from mm Hg to kilopascals, multiplying by 0.133322, leaves the coefficient of variation unchanged. The mean and the standard deviation are both multiplied by 0.133322, so their ratio is unchanged. The script gives a mean of 16.847 kPa, a median of 16.443 kPa and a standard deviation of 2.683 kPa, each 0.133322 times its value in mm Hg, and a coefficient of variation of 0.1593 in both units.
The standard deviation also serves as a ruler. Subtracting the mean and dividing by the standard deviation gives a value's z-score, and by the rules above z-scores have mean 0 and standard deviation 1. For roughly normal data about 68%, 95% and 99.7% of the values lie within one, two and three standard deviations of the mean (the empirical rule), and for data of any shape at least $1 - 1/k^2$ lie within $k$ standard deviations (Chebyshev's inequality). Standard Scores, Chebyshev's Inequality and Grouped Data develops and proves these, and shows how the mean, the standard deviation and the median are recovered from a frequency table.
What to report
- For a roughly symmetric distribution without outliers, report the mean and the standard deviation. Together with the empirical rule (Standard Scores, Chebyshev's Inequality and Grouped Data) they describe the data well.
- For a skewed distribution, or data with outliers, report the median and the interquartile range, often as the five-number summary (minimum, $Q_1$, median, $Q_3$, maximum). Reporting the mean as well is useful when totals matter.
- For ordinal data, report the median and quartiles, or the full table of shares. For nominal data, report the table of shares.
- State $n$, the units and, for small samples, how quartiles were computed.
The mean and the standard deviation remain the summaries that inference is built on, even for skewed data. The behavior of a sample mean is known whatever the shape of the population (the central limit theorem). The choice of descriptive summary and the choice of inferential method are related but separate decisions.
Worked problems
The first two problems are exercises from the course text's chapter on descriptive statistics (Pagano, Gauvreau and Mattie, 2022), restated in our own words with their data. The third is posed on this article's eleven adults. The script named under "In Python" computes every number and asserts the main ones.
Problem 1 (times to seizure). In a study of the long-term outlook for children who have had an acute episode of bacterial meningitis, the times to the onset of seizure for 13 children were, in months,
$$0.10,\ 0.25,\ 0.50,\ 4,\ 12,\ 12,\ 24,\ 24,\ 31,\ 36,\ 42,\ 55,\ 96.$$
Find the mean, median, mode, range, interquartile range and standard deviation.
Solution. The values are already in increasing order, so the order statistics can be read off.
- Mean. The sum is 336.85, so $\bar{x} = 336.85/13 = 25.91$ months.
- Median. With $n = 13$, the median is the seventh ordered value, 24 months.
- Mode. Two values occur twice, 12 and 24, and no value occurs more often. The data have two modes, 12 and 24 months. With thirteen values on a continuous scale, neither says much.
- Range. $96 - 0.10 = 95.9$ months.
- Interquartile range. It depends on the quartile method, as it must for a sample this small. By the type 7 rule (the default of R, Excel and NumPy), the positions are $1 + 0.25 \times 12 = 4$ and $1 + 0.75 \times 12 = 10$, so $Q_1 = x_{(4)} = 4$, $Q_3 = x_{(10)} = 36$ and the IQR is 32 months. Tukey's hinges give the same. By the type 6 rule, the positions are $0.25 \times 14 = 3.5$ and $0.75 \times 14 = 10.5$, so $Q_1 = (0.50 + 4)/2 = 2.25$, $Q_3 = (36 + 42)/2 = 39$ and the IQR is 36.75 months. The medians of the two halves with the median excluded give the same as type 6.
- Standard deviation. By the shortcut, $\sum x_i^2 = 17{,}718.32$ and $n\bar{x}^2 = 8{,}728.30$, so the sum of squared deviations is 8,990.02. Then $s^2 = 8{,}990.02/12 = 749.17$ and $s = 27.37$ months.
The summaries also describe the shape. The mean, 25.91, is above the median, 24, and eight of the thirteen values are below the mean. The largest value, 96 months, is $(96 - 25.91)/27.37 = 2.56$ standard deviations above the mean and lies beyond the upper fence $36 + 1.5 \times 32 = 84$ of a box plot. It accounts for more than half of the sum of squared deviations: $(96 - 25.91)^2 = 4{,}912$ of 8,990. For data like these the median and the interquartile range, with the quartile method named, describe the typical child better than the mean and the standard deviation.
Problem 2 (daily caloric intake in two groups). A study compared adolescent girls with bulimia with healthy girls of similar body composition and physical activity. The daily caloric intakes, in kilocalories per kilogram, were
Bulimic (23 girls): 15.9, 16.0, 16.5, 17.0, 17.6, 18.1, 18.4, 18.9, 18.9, 19.6, 21.5, 21.6, 22.9, 23.6, 24.1, 24.5, 25.1, 25.2, 25.6, 28.0, 28.7, 29.2, 30.9.
Healthy (15 girls): 20.7, 22.4, 23.1, 23.8, 24.5, 25.3, 25.7, 30.6, 30.6, 33.2, 33.7, 36.6, 37.1, 37.4, 40.8.
(a) Find the median of each group. (b) Find each interquartile range. (c) Construct box plots. (d) Which group has the larger typical intake, and which the greater variability?
Solution. (a) Both lists are in increasing order. For the bulimic group, $n = 23$ and the median is the twelfth value, 21.6 kcal/kg. For the healthy group, $n = 15$ and the median is the eighth value, 30.6 kcal/kg.
(b) By the type 7 rule:
- Bulimic: the positions are $1 + 0.25 \times 22 = 6.5$ and $1 + 0.75 \times 22 = 17.5$. So $Q_1 = (18.1 + 18.4)/2 = 18.25$ and $Q_3 = (25.1 + 25.2)/2 = 25.15$, and the IQR is 6.90 kcal/kg.
- Healthy: the positions are $1 + 0.25 \times 14 = 4.5$ and $1 + 0.75 \times 14 = 11.5$. So $Q_1 = (23.8 + 24.5)/2 = 24.15$ and $Q_3 = (33.7 + 36.6)/2 = 35.15$, and the IQR is 11.00 kcal/kg.
By the type 6 rule the positions are whole numbers, $0.25 \times 24 = 6$ and $0.75 \times 24 = 18$ for the bulimic group and $0.25 \times 16 = 4$ and $0.75 \times 16 = 12$ for the healthy group. The quartiles are then data values, 18.1 and 25.2 (IQR 7.10) and 23.8 and 36.6 (IQR 12.80). The two rules agree on the comparison.
(c) The box plots follow the construction in Tables and Graphs for Data, here with the type 7 quartiles.
| Bulimic | Healthy | |
|---|---|---|
| Box, from $Q_1$ to $Q_3$ | 18.25 to 25.15 | 24.15 to 35.15 |
| Median line | 21.6 | 30.6 |
| Fences, $Q_1 - 1.5\,\mathrm{IQR}$ and $Q_3 + 1.5\,\mathrm{IQR}$ | 7.90 and 35.50 | 7.65 and 51.65 |
| Whiskers end at | 15.9 and 30.9 | 20.7 and 40.8 |
| Points beyond the fences | none | none |
No value in either group lies beyond a fence, so each whisker ends at the group's smallest or largest value. Drawn on one axis, the healthy group's box sits to the right of the bulimic group's and is longer. Its lower quartile, 24.15, is above the bulimic group's median, 21.6.
(d) The typical intake is larger for the healthy girls: their median is 30.6 kcal/kg against 21.6, and 22 of the 23 bulimic girls are below the healthy group's median. The healthy group is also the more variable, by every measure computed here: an IQR of 11.00 against 6.90 and a range of $40.8 - 20.7 = 20.1$ against $30.9 - 15.9 = 15.0$.
Problem 3 (Proposition 1 and the rule for an added value, on the eleven adults). (a) Compute the sum of squared deviations of the eleven pressures from 120.0 without squaring eleven differences. (b) Decide, without recomputing the standard deviation, whether adding a twelfth value of 150.0 or of 152.0 would raise it.
Solution. (a) By Proposition 1 with $c = 120.0$, the sum is $\sum (x_i - \bar{x})^2 + n(\bar{x} - c)^2 = 5{,}531.89 + 11 \times (126.5455 - 120.0)^2 = 5{,}531.89 + 471.27 = 6{,}003.16$, the value quoted in the section on the median.
(b) By the rule proved in the section on variance, a new value lowers the standard deviation exactly when it lies within $s\sqrt{(n+1)/n} = 23.52 \times \sqrt{12/11} = 24.57$ of the mean, that is, between $126.55 - 24.57 = 101.98$ and $126.55 + 24.57 = 151.11$ mm Hg. So 150.0 would lower the standard deviation and 152.0 would raise it.
What we have learned
The mean minimizes squared deviations and the median absolute ones. They agree for symmetric data such as men's heights, separate under the skew of blood pressure, and part completely when one value is misrecorded. Spread splits the same way. The standard deviation uses every value. The interquartile range resists wild values, but in small samples it depends on how software computes quartiles. Under a change of units the measures of center follow the values and the measures of spread are multiplied by the size of the scale factor.
The standard deviation is also the ruler for z-scores, the empirical rule and Chebyshev's guarantee. Those, and the summaries that can be recovered from a frequency table, are established in the next article, Standard Scores, Chebyshev's Inequality and Grouped Data.
In Python
Software disagrees about the default divisor of the standard deviation, which is worth knowing before any number is reported:
import numpy as np, pandas as pd, statistics
x = np.array([98.0, 120.0, 119.3, 156.7, 170.7, 136.0, 147.3, 102.0, 112.0, 124.0, 106.0])
x.std() # 22.4254 NumPy: divisor n (ddof=0) by default
x.std(ddof=1) # 23.5200 divisor n - 1
pd.Series(x).std() # 23.5200 pandas: divisor n - 1 by default
statistics.stdev(x) # 23.5200 sample; statistics.pstdev(x) gives 22.4254
np.percentile(x, [25, 75]) # [109.0, 141.65], type 7
np.percentile(x, [25, 75], method='weibull') # [106.0, 147.3], type 6, the NIST default
pd.Series(x).describe() # count, mean, std (n - 1), min, quartiles (type 7), max
Every number in this article is computed by tools/experiments/applied-statistics/measures-of-center-and-spread.py in the site's repository, and the figures are drawn by tools/figures/measures-of-center-and-spread.py from its output.
References
- Hyndman, R. J., and Fan, Y. (1996). Sample quantiles in statistical packages. The American Statistician, 50(4), 361–365. record · 2 pages
- National Center for Health Statistics (2020). National Health and Nutrition Examination Survey 2017–2018: Demographic Variables and Sample Weights (DEMO_J), Blood Pressure (BPX_J) and Body Measures (BMX_J) data files. Centers for Disease Control and Prevention. https://wwwn.cdc.gov/nchs/nhanes/continuousnhanes/default.aspx?BeginYear=2017 record · 109 pages
- NIST/SEMATECH. e-Handbook of Statistical Methods, §1.3.5.1 (Measures of location), §1.3.5.6 (Measures of scale), §1.3.5.11 (Measures of skewness and kurtosis) and §7.2.6.2 (Percentiles). National Institute of Standards and Technology. https://www.itl.nist.gov/div898/handbook/ record · 37 pages
- NumPy Developers.
numpy.percentile, documentation for NumPy 2.2. https://numpy.org/doc/2.2/reference/generated/numpy.percentile.html record - Pagano, M., Gauvreau, K., and Mattie, H. (2022). Principles of Biostatistics (3rd ed.). CRC Press. The course text. record · 48 pages
- von Hippel, P. T. (2005). Mean, median, and skew: correcting a textbook rule. Journal of Statistics Education, 13(2). record
Reviewed: verified, 16 Nov 2026 · checked against sources, 23 Nov 2026 · citations checked, 16 Nov 2026 · editorial review, 23 Nov 2026 · 8 revisions