Chalk−1

Math · Introductory statistics · Concept

Mean, median and standard deviation

Three numbers describe most data sets. The mean is the balance point, the median is the middle value, and the standard deviation measures how far values typically sit from the mean. The median resists outliers, but the mean and the standard deviation do not.

A concrete case

Two quizzes with the same average

Two groups of five students take the same 15-point quiz. Group A scores 6, 7, 8, 9 and 10. Group B scores 2, 5, 8, 11 and 14.

Both groups total 40 points, so both average 8. Both have 8 as their middle score, too. Yet the groups are different. Every score in group A is within 2 points of 8, while group B has scores 6 points away on either side.

To put a number on that difference, measure how far each score sits from the average. For group A the distances are 2, 1, 0, 1 and 2. For group B they are 6, 3, 0, 3 and 6, three times as far. A good measure of spread should come out three times as large for group B. The standard deviation does, at about 1.58 points for A and 4.74 for B.

Same center, different spread
GroupScoresDistance from 8Standard deviation
A6, 7, 8, 9, 102, 1, 0, 1, 21.58
B2, 5, 8, 11, 146, 3, 0, 3, 64.74

The rule

The mean and the median

The mean x¯, read “x-bar”, adds the n values and divides by n. The median is the middle value once the data are sorted. With an even number of values there are two middle ones, and the median is their average. Half the data lie at or below the median and half at or above it.

x¯=1n∑i=1nxi=x1+x2+⋯+xnn
x¯=1n∑i=1nxi=x1+x2+⋯+xnn

The standard deviation

Each value’s deviation is its signed distance from the mean, xi−x¯. Square every deviation, add the squares and divide by n−1. The result is the sample variance s2. Its square root is the sample standard deviation s, a typical distance of a value from the mean, in the data’s own units.

When the data are a whole population rather than a sample, its mean is written μ and the sum of squares is divided by the population size N. That gives the population variance σ2 and the population standard deviation σ.

s=∑(xi−x¯)2n−1,σ=∑(xi−μ)2N
s=∑(xi−x¯)2n−1σ=∑(xi−μ)2N

Quartiles, the IQR and outliers

The first quartile Q1 has about a quarter of the data below it, and the third quartile Q3 about three quarters. Chalk Inverse, like many calculators, finds them as the medians of the lower and upper halves of the sorted data. When n is odd, the median itself is left out of both halves. The interquartile range, IQR=Q3−Q1, is the spread of the middle half.

The minimum, Q1, the median, Q3 and the maximum make the five-number summary, which a box plot draws. A common screen flags a value as a possible outlier when it lies more than 1.5×IQR below Q1 or above Q3. Those two cutoffs are called fences.

IQR=Q3−Q1,Q1−1.5⋅IQR,Q3+1.5⋅IQR
IQR=Q3−Q1Q1−1.5⋅IQR,Q3+1.5⋅IQR

Why it works

Why square the deviations

Deviations from the mean always add to zero. The mean is the balance point, so the values above it lie exactly as far above, in total, as the values below it lie below. The algebra agrees. The sum of the xi−x¯ is the sum of the xi minus n times x¯, and n times x¯ is that same sum. An average of the deviations is 0 for every data set, whatever its spread.

Squaring removes the signs, so every value adds to the total. It also weights a value 6 away four times as heavily as a value 3 away, which is why one extreme value can inflate s. The square root at the end undoes the squaring of the units, and hours squared become hours again.

∑(xi−x¯)=∑xi−nx¯=0

Why divide by n−1

The mean of a sample sits closer to its own data than any other number does. In group A, the squared distances from 8 add to 10, but from 7 they add to 15. Any center other than x¯ gives a larger sum.

The population mean μ is unknown and is almost never exactly x¯. Squared deviations measured from x¯ therefore run a little small compared with distances from μ. Dividing by n−1 instead of n makes up for that shortfall, so that on average s2 equals the population variance σ2. For a whole population, where μ itself is known, divide by N.

Why the median ignores an outlier

The median depends only on which values sit in the middle of the sorted list. Make the largest value ten times larger and the middle does not move. The mean adds every value, so the same change moves it, and the standard deviation squares the new, larger distance as well. The median and the IQR are called resistant for this reason.

The method

The standard deviation in seven steps

The table finds s for group B. Keep the mean unrounded while you work, and round only the final answer.

36+9+0+9+365−1≈4.74
The sample standard deviation of 2, 5, 8, 11, 14
StepWhat to doFor group B
1Add the values and divide by n(2+5+8+11+14)⁢/5 =8
2Subtract the mean from each value−6, −3, 0, 3, 6
3Check that the deviations add to 0−6−3+0+3+6 =0
4Square each deviation36, 9, 0, 9, 36
5Add the squares90
6Divide by n−1 for a sample90⁢/4 =22.5, the variance s2
7Take the square root and give the unitss =22.5 ≈4.74 points

The median and quartiles in five steps

The same five scores give the five-number summary 2, 3.5, 8, 12.5, 14. No score lies outside the fences, so none is flagged.

The median, quartiles and fences of 2, 5, 8, 11, 14
StepWhat to doFor group B
1Sort the data2, 5, 8, 11, 14
2Take the middle value, or average the two middle values8
3Split into a lower and an upper half, leaving out the median when n is odd2, 5 and 11, 14
4Take the median of each halfQ1=3.5 and Q3 =12.5
5Subtract, then find the fencesIQR=9, fences −10 and 26

Where it breaks

Where it breaks

The mean and the standard deviation describe a symmetric, single-peaked data set well. For skewed data or data with an outlier they mislead. In the pay of 40, 42, 45, 48 and 300 thousand dollars, the mean is 95 thousand, more than any employee but one earns. The median, 45 thousand, and the IQR describe a typical value and spread better.

The standard deviation is not the average distance from the mean. For group A the distances 2, 1, 0, 1 and 2 average 1.2, while s≈1.58. Squaring gives the larger distances extra weight.

A sample and a population use different divisors. s divides by n−1 and σ divides by N. A calculator often shows both, labelled Sx and σx, and picking the wrong one is a common slip. The variance is in squared units, so a variance of 4 hours2 is not a length of time. Report s as the spread, not s2.

The 1.5×IQR screen is a rule of thumb, not a test. With very few values it can miss a value that stands far from the rest. In 2, 3, 3, 4 and 18 the fences are −10.25 and 23.75, so 18 is not flagged. A flagged value may also be perfectly real, so check the record before deleting anything.

Quartile methods differ. Software that interpolates gives 4.75 and 7.25 for the sleep data in the third example, where the halves method gives 4.5 and 7.5. Both are accepted, so say which one you use.

A mean needs numbers that measure something. The mean of zip codes or jersey numbers is arithmetic on labels.

Check your answer

Check your answer

A standard deviation is a long chain of small sums, and each link can be tested on its own.

Add the deviations. They must total 0, up to rounding. If they do not, the mean is wrong.

Find the sum of squares a second way. The squared deviations add to Σxi2−n⋅x¯2. The first example’s sleep data are 4, 8, 6, 5, 3, 7, 9 and 6 hours. Their squares add to 316 and x¯2=62=36, so the sum is 316−8×36=28, the same as adding the eight squares one by one.

Check the size. s is never negative, and it is 0 only when every value is the same. It can never exceed the range, the largest value minus the smallest. Summarize the data in Statistics gives an independent answer, with the mean, the median, the quartiles and both standard deviations.

To have Chalk check the work, put the data list on the first row of a Math box, such as 4, 8, 6, 5, 3, 7, 9, 6. Write each calculation as arithmetic on its own row below it. The Checker marks each row’s arithmetic ✓ or ✗.

A row that names the statistic, such as x¯=48⁢/8=6, reads “?”. Its message says the arithmetic was checked and the formula for x¯ was not. Chalk has checked the numbers but cannot tell that 48⁢/8 is the right formula for this mean. The same holds for s, s2, Q1 and IQR written by name. The arithmetic is still checked, so a wrong sum shows ✗. One exception: with s=28⁢/7=2 on a row above, s2=28⁢/7=4 is checked against that s and reads ✓.

The data sets 0, 5, 5, 5, 10 and 0, 0, 5, 10, 10 have the same mean and the same range. Do they have the same s?

No. Both have mean 5, but the second keeps four of its five values 5 away from it, and the first only two. Their squared deviations add to 50 and 100, so s≈3.54 and s=5. s uses the distance of every value from the mean, not only the two ends, which is why the range cannot stand in for it.

Degrees of freedom, and what spread can promise

The n deviations from x¯ add to zero, so once n−1 of them are known, the last one is forced. Only n−1 of them are free to vary, and that count is called the degrees of freedom. A longer calculation shows that the expected sum of squared deviations from x¯ is exactly (n−1)σ2. Dividing by n−1 therefore makes s2 right on average. The square root spoils this a little, and s itself runs slightly below σ on average.

The mean and the median each make a kind of distance as small as possible. The mean minimizes the sum of squared distances to the data, and the median minimizes the sum of plain distances. That is the deeper reason the median shrugs off an outlier and the mean does not.

For any data at all, Chebyshev’s inequality guarantees that at least 1−1⁢/k2 of the values lie within k standard deviations of the mean. Within two standard deviations that is at least 75⁢%. For bell-shaped data the share is about 95⁢%, the 68–95–99.7 rule of the normal distribution.

Common mistakes

  • Finding the median without sorting. In the list 4, 8, 6, 5, 3, 7, 9, 6, the 4th and 5th entries are 5 and 3, which average 4. Sorted, the middle two are 6 and 6, so the median is 6. The median is defined by order.
  • Dividing by n for a sample. 28⁢/8≈1.87 is the population formula. The sleep data are a sample, so s=28⁢/7=2. Deviations from x¯ run small, and dividing by n−1 corrects for that.
  • Averaging the deviations without squaring them. The sleep deviations −2, 2, 0, −1, −3, 1, 3 and 0 add to 0, as every set of deviations does. Square them first, and the squares add to 28.
  • Reporting the variance as the spread. The sleep data have s2=4 in hours squared, which is not a length of time. The standard deviation, s=2 hours, is in the data’s units and can sit beside the mean.
  • Rounding the mean before taking deviations. For the mistyped sleep data 4, 8, 6, 5, 3, 7, 30, 6, x¯=8.625. If it is rounded to 9, the squared deviations add to 541 instead of 539.875. Keep the mean unrounded and round only the final s.
  • Describing skewed data with the mean. In 2, 3, 3, 4 and 18 the mean is 6, larger than four of the five values. The median, 3, describes a typical value, because one large value pulls the mean and not the middle.

Key terms

Mean
The average: mean =(sum of the values) ÷(number of values), written x¯=∑⁢x÷n for a sample and μ for a whole population. One extreme value can pull it a long way.
Median
The middle value when the data are in order. With an even count, it is the average of the two middle values. Extreme values affect it less than the mean.
Standard deviation
How spread out the values are around the mean, in the data’s own units: the square root of the variance. It describes individual values, not how precise the mean is.
Sample variance
The average squared distance from the sample mean, with n−1 in the denominator: s2=Σ⁢(x−x¯)2/⁢(n−1). Dividing by n−1 instead of n corrects the tendency to underestimate the population variance.
Variance
The average of the squared distances from the mean, a measure of spread in squared units. The population variance divides by N, and the sample variance divides by n−1.
Quartile
The three values that split ordered data into four equal parts: Q1 (25th percentile), the median (50th) and Q3 (75th). Methods differ slightly for samples. Chalk Inverse takes the median of each half, leaving the overall median out of both halves when the count is odd.
Interquartile range
Q3−Q1, the spread of the middle half of the data. Extreme values affect it much less than the full range.
Outlier
A value far from the rest of the data, often flagged when it lies more than 1.5×IQR beyond a quartile. It may be an error, a rare real case or a sign of something different, so don’t delete it without a reason.

Work through an example

Eight students report how many hours they slept: 4, 8, 6, 5, 3, 7, 9 and 6. Find the mean, the median and the sample standard deviation.

Find the mean, median and standard deviation →

How an outlier moves the mean, not the median →

Find quartiles and the interquartile range →

Sources and scope

Authored study material. Tool results depend on the stated inputs and model assumptions.

After reading

Try it, then study it

Open the example in its tool to check steps or change values, then review the key terms as flashcards.

Summarize the data in Statistics Check the arithmetic in Math Study the 8 key terms Open worked example on a board Sample standard deviation in Math Reference

Your existing work stays on this device. Examples open as editable copies.