Math explained
Describing data by hand: mean, median, mode, variance and standard deviation, quartiles, the box plot and the histogram, all from one set of eight numbers
Standard deviation by hand on eight numbers, with the mean, median, mode, variance, quartiles and box plot from the same data, and when to divide by n − 1.
The standard deviation is the typical distance of the data from their mean: square each deviation, average the squares, take the square root. The squaring is the step students skip, and without it the deviations always add to zero. This page computes every descriptive statistic on one set of eight numbers, by hand: the mean, median and mode, the variance and standard deviation (both the population and the sample version, and when each is right), the quartiles and interquartile range, the five-number summary for a box plot, and the bins for a histogram.
One data set for everything
The eight values are hours of sleep over eight nights, recorded in the order they happened:
4, 8, 6, 5, 3, 7, 9, 6.
They are ours, and they were chosen so that every answer comes out clean. Real data are not this tidy: a test will give you a standard deviation of 2.138 rather than 2, and the decimals are not a sign you went wrong. The method is the same.
In the MDM4U course these statistics are four ideas in a row: idea 18, frequency tables, histograms and box plots; idea 19, measures of central tendency; idea 20, range, variance and standard deviation; idea 21, quartiles and the interquartile range. Before them is idea 17, experiments and observational studies, which is where the data come from; after them is idea 22, scatter plots and the correlation coefficient, which uses the same deviations on two variables at once. In the first-year statistics course the same material is ideas 2 to 4: displaying distributions, measures of centre and measures of spread. The MDM4U course map places the four ideas in the course, and AP Statistics asks the same computations in its first unit.
Mean, median and mode
The mean is the sum divided by the count: 4 + 8 + 6 + 5 + 3 + 7 + 9 + 6 = 48; 48/8 = 6.
The median is the middle value of the sorted data. Sort first: 3, 4, 5, 6, 6, 7, 8, 9. With eight values there is no single middle; the fourth and fifth are 6 and 6, so the median is (6 + 6)/2 = 6.
The mode is the value that appears most often. Only 6 appears twice, so the mode is 6.
All three are 6 here. That is a feature of the chosen data, not a rule; a skewed set has a mean pulled toward its tail and a median that stays put, and the gap between them is itself a description of the shape.
The common wrong line
The median read from the unsorted list. A student takes the middle two of 4, 8, 6, 5, 3, 7, 9, 6 as written, which are 5 and 3, and reports (5 + 3)/2 = 4. The median is a position in the ordered data, not in the data as collected. Sort, then count in.
Worked example: variance and standard deviation, line by line
How to calculate standard deviation, on the eight values, with the mean already known to be 6.
Line 1, the deviations, each value minus the mean: 4 − 6 = −2; 8 − 6 = 2; 6 − 6 = 0; 5 − 6 = −1; 3 − 6 = −3; 7 − 6 = 1; 9 − 6 = 3; 6 − 6 = 0. Their sum: −2 + 2 + 0 − 1 − 3 + 1 + 3 + 0 = 0. It is always zero, which is a check that the mean is right and the reason the next line squares.
Line 2, the squared deviations: 4, 4, 0, 1, 9, 1, 9, 0.
Line 3, the sum of squares: 4 + 4 + 0 + 1 + 9 + 1 + 9 + 0 = 28.
Line 4, the population version, dividing by n = 8: variance σ² = 28/8 = 3.5; standard deviation σ = √3.5 ≈ 1.871.
Line 5, the sample version, dividing by n − 1 = 7: variance s² = 28/7 = 4; standard deviation s = √4 = 2.
Which one: n or n − 1
Divide by n when the eight values are the whole population you care about: these eight nights, and nothing beyond them. Divide by n − 1 when the eight values are a sample standing in for a larger population: a typical eight nights, meant to describe your sleep in general. The reason, in words: a sample's mean sits closer to its own values than the true population mean does, so the squared deviations measured from the sample mean come out a little too small, and dividing by the smaller number n − 1 enlarges the result enough to correct that on average. Statistics software and most calculators label the two versions separately, and a test question's wording decides which it wants. When the question says "a sample", or the data are a few measurements out of many possible ones, use n − 1.
The common wrong lines
Averaging the deviations without squaring. Line 1's sum is 0, and 0/8 = 0, so the student concludes there is no spread. The deviations cancel by construction; the spread is in their sizes, and squaring is what keeps the sizes and drops the signs.
Stopping at the variance. A student reports 4 as the standard deviation. The variance is in squared units, hours squared here, and does not compare with the mean. The square root brings it back to hours: the standard deviation is 2.
Using n for a sample without saying so. The two answers differ, 1.871 against 2, and both are "correct" for their own question. Write which you used and why; a marker who sees 1.871 beside the word "sample" takes the mark.
What the standard deviation tells you
In the data's own units, the standard deviation is the typical distance from the mean. Here a night is typically about two hours from the six-hour average. A set with a standard deviation of half an hour would be a sleeper who is remarkably regular; a set with a standard deviation of three hours would be a sleeper with some very long and some very short nights.
For a roughly bell-shaped set, about two thirds of the values lie within one standard deviation of the mean. Six of our eight do: 4, 5, 6, 6, 7 and 8 all lie within 6 ± 2, and only 3 and 9 sit outside. The full version of that rule, with the 95 % and 99.7 % bands, belongs to the normal distribution and z-scores, where the mean and standard deviation computed here become the two numbers that describe a whole curve.
Quartiles, the interquartile range and the box plot
The quartiles cut the sorted data into quarters. Split the sorted list at the median into a lower half and an upper half:
3, 4, 5, 6 | 6, 7, 8, 9.
Q1 is the median of the lower half: (4 + 5)/2 = 4.5. Q3 is the median of the upper half: (7 + 8)/2 = 7.5. The interquartile range is IQR = Q3 − Q1 = 7.5 − 4.5 = 3.
The five number summary is the minimum, Q1, the median, Q3 and the maximum: 3, 4.5, 6, 7.5, 9. A box plot draws the box from Q1 to Q3 with a line at the median, and whiskers out to the smallest and largest values that are not outliers. An outlier is a value more than 1.5 × IQR beyond the box: 1.5 × 3 = 4.5, so the fences are 4.5 − 4.5 = 0 and 7.5 + 4.5 = 12. No value lies below 0 or above 12, so there are no outliers and the whiskers run to 3 and 9.
Textbooks differ on how quartiles are found for a small set. The method here, the median of each half, is the one most introductory courses use, and it is the one the OpenStax descriptive statistics chapter states for quartiles. The same chapter also gives a position formula for percentiles, (k/100)(n + 1), which on these eight values puts Q1 at position 2.25, between 4 and 5, so 4.25, and Q3 at 7.75. Some texts include the median in both halves when n is odd; with our even n that changes nothing. A test marker follows the course's convention, so use the one your course teaches and say which it is.
The common wrong line
Q1 taken as the second value. A student reasons that a quarter of 8 is 2, so Q1 is the second sorted value, 4. The quartile is the median of the lower half, which falls between the second and third values, 4.5. The same reasoning gives Q3 as 8 instead of 7.5 and an IQR of 4 instead of 3.
The histogram
A histogram groups the data into bins of equal width and draws a bar for each whose height is the count. With bins of width 2 the eight values fall as follows:
| Bin | Values in it | Count |
|---|---|---|
| 3 to 4 | 3, 4 | 2 |
| 5 to 6 | 5, 6, 6 | 3 |
| 7 to 8 | 7, 8 | 2 |
| 9 to 10 | 9 | 1 |
State the bin edges so that no value can fall into two bins: here each bin holds the two whole numbers it names. The bars touch, because the scale is continuous, and the heights are counts. The tallest bar, 5 to 6, is where the mode sits.
A histogram and a box plot show the same shape in different ways. The histogram shows where the data pile up, so the mode is visible; the box plot shows the quartiles, so the spread of the middle half is visible, and the outliers are marked. For this set the histogram shows a peak at 5 to 6 with a light tail toward 9, and the box plot shows a box from 4.5 to 7.5 with the median in its middle.
Sibling to try cold
Try this with the page closed. Compute everything, then compare under the check heading. Attempting first is chapter 1 of the free playbook, and the reason it works is the finding of Roediger and Karpicke (2006): a retrieval attempt builds recall that rereading does not. Testing yourself before you reread has the marking rules.
The eight values 2, 4, 4, 4, 5, 5, 7, 9. Find the mean, median and mode, the sum of squared deviations, the population and sample variance and standard deviation, Q1, Q3 and the IQR.
Check
Mean 5. Median (4 + 5)/2 = 4.5. Mode 4. Sum of squared deviations 32. Population variance 32/8 = 4, so σ = 2. Sample variance 32/7 ≈ 4.571, so s ≈ 2.138. Q1 = 4, Q3 = 6, IQR = 2. If your sum of squares was not 32, check your mean first: with a wrong mean the deviations do not sum to zero, and that is how you catch it.
Where this sits in the course, and where it goes next
In MDM4U these are ideas 18 to 21 of 24, after sampling and experiments (ideas 16 and 17) and before correlation and regression (ideas 22 and 23). In the statistics course they are ideas 2 to 4 of 25, the first computations after data collection.
Everything that builds on them uses them. The normal distribution and z-scores (MDM4U ideas 12 and 13; statistics idea 12) take the mean and standard deviation computed here as the two numbers that describe a curve. The correlation coefficient (MDM4U idea 22) is built from the same deviations, on two variables at once. And a lab report's uncertainty is a standard deviation of repeated measurements: how to write a lab report shows where it goes.
To learn the procedures: compute each on one small set as this page did, then on a set where the numbers are not clean, then on a set you have to sort first. Sweller and Cooper (1985) found that studying worked examples beside the problems they solve teaches a procedure faster than unguided attempts; worked examples, then practice problems has the order to follow.
Descriptive statistics on one screen
- The standard deviation in four steps: deviations from the mean; square them; add and divide (n for a population, n − 1 for a sample); square root.
- The check: the deviations sum to zero. If they do not, the mean is wrong.
- n or n − 1: the whole population, n; a sample standing in for more, n − 1. Say which.
- Variance vs standard deviation: the variance is in squared units; report the standard deviation.
- The five-number summary: min, Q1, median, Q3, max; Q1 and Q3 are the medians of the two halves.
- The outlier fence: 1.5 × IQR beyond the box.
- This page's data: mean 6, median 6, mode 6, σ ≈ 1.871, s = 2, Q1 = 4.5, Q3 = 7.5, IQR = 3, no outliers.
Questions students ask
How do you calculate standard deviation by hand?
Find the mean, subtract it from each value to get the deviations, square each deviation, add the squares, divide by n for a population or n − 1 for a sample, and take the square root. The deviations themselves always add to zero, so the squaring step cannot be skipped.
What does standard deviation tell you?
How far the data typically sit from their mean, in the same units as the data. A small standard deviation means the values cluster near the mean; a large one means they spread out. For a roughly bell-shaped set, about two thirds of the values lie within one standard deviation of the mean.
Why divide by n − 1 for a sample?
Because a sample's values sit closer to their own mean than to the true population mean, so the squared deviations come out a little too small. Dividing by n − 1 instead of n enlarges the result enough to correct that on average. If the data are the whole population, divide by n.
What is the difference between variance and standard deviation?
The variance is the average of the squared deviations and is in squared units. The standard deviation is its square root, back in the original units, which is why it is the one you report and compare with the mean. On this page's data the sample variance is 4 and the sample standard deviation is 2.
How do you find the interquartile range?
Sort the data, find the median of the lower half (Q1) and of the upper half (Q3), and subtract: IQR = Q3 − Q1. It is the width of the box in a box plot, and values more than 1.5 times the IQR beyond the box are flagged as outliers.
Put tonight's studying on rails
YSR Studies turns your notes, lectures and course into cards that come back before you forget, a tutor that makes you try first, and a map of what you know. Free, five hours a month, no card asked.
Read next
- MathThe normal distribution and z-scores: the sketch, the table, and the three questions every normal-curve problem turns out to be
- CoursesMDM4U Mathematics of Data Management: the course map (24 ideas in the order they are taught), the three ideas everything leans on, and how to study it
- MethodsActive recall: how to study by testing yourself (five ways to do it tonight, and how to grade yourself honestly)
- How to studyWorked examples, practice problems and past exams: the order that teaches, and where to find them
Sources
- OpenStax (2023). Introductory Statistics 2e, chapter 2, Descriptive Statistics, sections 2.3 Measures of the Location of the Data and 2.7 Measures of the Spread of the Data. Houston: OpenStax. CC BY 4.0.
- Sweller, J., & Cooper, G. A. (1985). The use of worked examples as a substitute for problem solving in learning algebra. Cognition and Instruction, 2(1), 59–89. https://doi.org/10.1207/s1532690xci0201_3
- Roediger, H. L., & Karpicke, J. D. (2006). Test-enhanced learning: Taking memory tests improves long-term retention. Psychological Science, 17(3), 249–255. https://doi.org/10.1111/j.1467-9280.2006.01693.x
- YSR Studies (2026). The MDM4U course map: displays, central tendency, spread and quartiles are ideas 18 to 21 of 24; the statistics course map: displaying distributions, measures of centre and measures of spread are ideas 2 to 4 of 25.