| Relative frequency | |
|---|---|
| Interquartile range | |
| Outlier |
Lesson
The theory — Displaying Data
The distribution of a variable says which values it takes and how often. A categorical variable puts each individual into a group; a quantitative one gives a number it makes sense to do arithmetic with.
Where the formula comes from
- Decide what kind of variable it is. Categories are counted and drawn as a bar chart; numbers are drawn on a number line. A number that only labels, such as a postcode or a shirt number, is categorical.
- Count. The frequency f of a category or a class is how many individuals fall in it, and its relative frequency is f divided by the number of individuals n. The relative frequencies add to 1, and their running total is the cumulative relative frequency.
- Keep every value: dotplot and stemplot. A dotplot puts one dot per value above a number line, stacking equal values. A stemplot splits each value into a stem (every digit but the last) and a leaf (the last digit), so 47 is 4 | 7; the leaf unit u says what a leaf counts, and with u = 0.1 the same 4 | 7 means 4.7.
- Group into bins: the histogram. Choose a width w and an edge a. Each bin runs from its left edge up to, but not including, its right edge, and its bar is as tall as its count. The bins cover the number line without gaps, so the bars touch.
- Summarise in five numbers: the boxplot. Sort the data. The median M is the middle value, or the mean of the two middle values when n is even. Q₁ and Q₃ are the medians of the lower and upper halves, with M left out of both when n is odd. The box runs from Q₁ to Q₃; a value more than 1.5 IQR beyond the box is drawn on its own as an outlier, and each whisker stops at the last value that is not one.
- Assumes
- Calculators disagree about quartiles. This page uses the halves method of the TI-84 and of AP Statistics; spreadsheet functions interpolate between values and can give a different Q₁ and Q₃ for the same data.
Problems solved in full
-
Categorical or quantitative? 2 steps
For each student a school records (a) the number of brothers and sisters, (b) height in centimetres, (c) favourite subject, (d) postcode and (e) the time to run 100 m. Which variables are categorical and which quantitative, and which quantitative ones are discrete?
-
Ask whether an average of the values would mean anything. An average height or an average number of siblings does. An average favourite subject is nonsense, and so is an average postcode, although postcodes are written in digits.
-
Of the quantitative variables, a count can only take whole values, while a measurement can land anywhere in an interval.
Answer
Categorical: (c) and (d). Quantitative: (a), (b) and (e), of which (a) is discrete and (b) and (e) are continuous.
-
-
A frequency table and a bar chart 3 steps
Twenty students answered “how do you usually get to school?”: car, bus, walk, car, bike, bus, car, walk, car, bus, car, bike, walk, car, bus, car, walk, car, bus, car. Make a frequency table with relative frequencies, name the mode, and say which graph to draw.
Show solution
-
Tally each answer. The counts must add to n:
-
Divide each count by n = 20:
-
The way a student travels is categorical, so the graph is a bar chart: one bar per answer, gaps between the bars, in whatever order is clearest.
Answer
Car 9 (45%), bus 5 (25%), walk 4 (20%), bike 2 (10%). The mode is car. Draw a bar chart.
-
-
Reading a dotplot 2 steps
The dotplot of Old Faithful’s first 25 waits shows these values, in minutes: 47, 47, 51, 51, 52, 52, 54, 54, 55, 62, 62, 69, 74, 74, 78, 78, 79, 79, 83, 84, 84, 85, 85, 85, 88. What share of the waits were longer than 80 minutes, and where are the clusters?
Show solution
-
Count the dots to the right of 80: 83, 84, 84, 85, 85, 85 and 88.
-
Read the shape: the dots crowd between 47 and 55 and between 74 and 88, with only 62, 62 and 69 in the stretch between.
Answer
7 of 25 waits, or 28%, were longer than 80 minutes. There are two clusters, 47 to 55 and 74 to 88, with three waits between them.
-
-
A stemplot, and the quartiles read from it 3 steps
Draw a stemplot of the same 25 waits and use it to find the median and the quartiles.
Show solution
-
The stems are the tens digits 4 to 8 and the leaves are the units, written in order:
-
With n = 25 the median is the 13th leaf, counting from the top:
-
Leave the median out. The lower half is the first 12 values, so Q₁ is the mean of the 6th and 7th; the upper half is the last 12, so Q₃ is the mean of the 19th and 20th:
Answer
M = 74 minutes, Q₁ = 53 and Q₃ = 83.5.
-
-
A histogram, and the class that holds the median 3 steps
Group the same 25 waits into classes 10 minutes wide starting at 40. Give each class’s relative and cumulative relative frequency, and say which class contains the median.
Show solution
-
Count the classes [40, 50), [50, 60) and so on; a value on an edge, such as 50, would belong to the class on its right:
-
Divide by 25, then keep a running total:
-
The median is the 13th value. The running count is 12 at the end of [60, 70) and 18 at the end of [70, 80), so the 13th value lies in [70, 80).
Answer
Relative frequencies 8%, 28%, 12%, 24%, 28%; cumulative 8%, 36%, 48%, 72%, 100%. The median lies in [70, 80).
-
-
Fences, outliers and whiskers 3 steps
Newcomb’s 66 timings of light have Q₁ = 24, M = 27 and Q₃ = 31. The smallest values are −44, −2, 16 and 16, and the largest are 37, 39 and 40. Find the fences and the outliers, and say where the whiskers of the boxplot end.
Show solution
-
The interquartile range, then the fences 1.5 IQR beyond the box:
-
A value below 13.5 or above 41.5 is an outlier. −44 and −2 are below 13.5, and nothing reaches 41.5:
-
Each whisker runs to the most extreme value that is not an outlier: 16 at the bottom and 40 at the top. −44 and −2 are drawn as separate points.
Answer
Fences 13.5 and 41.5; outliers −44 and −2; the box runs from 24 to 31 with the median at 27, and the whiskers from 16 to 40.
-
-
What a boxplot cannot show 2 steps
Class A scored 40, 48, 50, 51, 53, 57, 58, 59, 60, 62, 78, 80, 81, 83, 84, 86, 87, 89, 92, 100, and Class B scored 40, 43, 47, 50, 54, 56, 59, 62, 66, 69, 71, 74, 78, 81, 84, 86, 90, 94, 97, 100. Compare their boxplots, then their histograms with bins 10 points wide.
Show solution
-
With n = 20 the median is the mean of the 10th and 11th values. Each half has 10 values, so Q₁ is the mean of the 5th and 6th and Q₃ the mean of the 15th and 16th:
-
Both classes run from 40 to 100, so the boxplots are identical. The histograms, bin by bin from [40, 50), are not:
Answer
The same boxplot, 40, 55, 70, 85, 100, for two different distributions. Class A is two clusters with nobody between 62 and 78: the dotplot and the stemplot show that gap exactly, the histogram shows the two clusters, and the boxplot shows neither. Class B is spread evenly.
-
Supplementary problems, answers only
-
Find the five-number summary of 12, 15, 15, 18, 20, 22, 25, 31, 47, and say whether 47 is an outlier.
Show answer
12, 15, 20, 28, 47. The upper fence is 47.5, so 47 is not an outlier.
-
Of the 2,201 people aboard the Titanic, 885 were crew. What is the crew’s relative frequency, and which graph suits the variable “class”?
Show answer
885/2,201 ≈ 40.2%; a bar chart.
-
In a stemplot with leaf unit 0.1, what values do 3 | 4 and −0 | 2 stand for?
Show answer
3.4 and −0.2
-
Old Faithful’s 272 waits, in 5-minute classes from 40, have counts 1, 20, 32 and 24 in the first four classes. What share of the waits were shorter than 60 minutes?
Show answer
77/272 ≈ 28.3%
-
Which of the dotplot, stemplot, histogram and boxplot let you read back every data value?
Show answer
The dotplot, and the stemplot to its leaf unit.
-
A boxplot has Q₁ = 30 and Q₃ = 50. Is a value of 82 an outlier? Is a value of 0?
Show answer
82 is (the upper fence is 80); 0 is not, because the lower fence is 0 and 0 is not below it.
Learning path
Statistics: from data to proportions
References (6)
- The stem-and-leaf display, the box-and-whisker plot, and the fences 1.5 times the spread between the hinges beyond the box, which the outlier rule on this page follows: Tukey, J. W. (1977). Exploratory Data Analysis. Reading, MA: Addison-Wesley. ISBN 0-201-07616-0.
- Why quartiles differ between calculators and packages: nine sample-quantile definitions in use, compared. This page uses the medians of the two halves: Hyndman, R. J. & Fan, Y. (1996). Sample quantiles in statistical packages. The American Statistician, 50(4), 361–365.
- The rule behind the page's starting bin width, about 1 + log₂ n classes: Sturges, H. A. (1926). The choice of a class interval. Journal of the American Statistical Association, 21(153), 65–66.
- Old Faithful's 272 waiting times between eruptions, the data set behind the first three presets and insight block 1; R's documentation gives the source as Härdle (1991): R Core Team. faithful: Old Faithful Geyser Data. R datasets package documentation; source: Härdle, W. (1991). Smoothing Techniques: With Implementation in S. New York: Springer.
- Simon Newcomb's 66 measurements of the passage time of light (1882), as listed in Table 5; the Newcomb preset and solved problem 6: Stigler, S. M. (1977). Do robust estimators work with real data? The Annals of Statistics, 5(6), 1055–1098.
- The Titanic preset: 325 first-class, 285 second-class and 706 third-class passengers and 885 crew, 2,201 people, from the British Board of Trade inquiry: Dawson, R. J. MacG. (1995). The “unusual episode” data revisited. Journal of Statistics Education, 3(3).