Displaying Data

Type numbers or pick a data set. The dotplot, histogram and boxplot share one scale, so a value sits at the same place in all three; the stemplot and the frequency table are underneath. Switch to categories for a bar chart.

Relative frequency fn\frac{f}{n}
Interquartile range IQR=Q3−Q1\mathrm{IQR}=Q_3-Q_1
Outlier x<Q1−1.5 IQRx>Q3+1.5 IQR\begin{aligned}&x<Q_1-1.5\,\mathrm{IQR}\\&x>Q_3+1.5\,\mathrm{IQR}\end{aligned}
Loading interactive simulation...

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

  1. 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.
  2. 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.
    f1n+f2n+⋯+fkn=1\frac{f_1}{n}+\frac{f_2}{n}+\dots+\frac{f_k}{n}=1
  3. 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.
    x=(10s+ℓ) ux=(10s+\ell)\,u
  4. 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.
    [a+jw, a+(j+1)w),j=0,1,2,…[a+jw,\ a+(j+1)w),\qquad j=0,1,2,\dots
  5. 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.
    IQR=Q3−Q1,x<Q1−1.5 IQR  ∨  x>Q3+1.5 IQR\mathrm{IQR}=Q_3-Q_1,\qquad x<Q_1-1.5\,\mathrm{IQR}\ \ \lor\ \ x>Q_3+1.5\,\mathrm{IQR}
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

  1. 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?

    1. 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.

    2. 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.

  2. 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.

    Open this problem in the tool

    Show solution
    1. Tally each answer. The counts must add to n:

      fcar=9,fbus=5,fwalk=4,fbike=2,9+5+4+2=20f_{\mathrm{car}}=9,\quad f_{\mathrm{bus}}=5,\quad f_{\mathrm{walk}}=4,\quad f_{\mathrm{bike}}=2,\qquad 9+5+4+2=20
    2. Divide each count by n = 20:

      920=0.45,520=0.25,420=0.20,220=0.10\frac{9}{20}=0.45,\qquad\frac{5}{20}=0.25,\qquad\frac{4}{20}=0.20,\qquad\frac{2}{20}=0.10
    3. 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.

    mode=car,fn=45%\mathrm{mode}=\mathrm{car},\qquad\frac{f}{n}=45\%
  3. 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?

    Open this problem in the tool

    Show solution
    1. Count the dots to the right of 80: 83, 84, 84, 85, 85, 85 and 88.

      725=0.28\frac{7}{25}=0.28
    2. 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.

    725=28%\frac{7}{25}=28\%
  4. 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.

    Open this problem in the tool

    Show solution
    1. The stems are the tens digits 4 to 8 and the leaves are the units, written in order:

      47 751 1 2 2 4 4 562 2 974 4 8 8 9 983 4 4 5 5 5 8\begin{array}{r|l}4&7\,7\\5&1\,1\,2\,2\,4\,4\,5\\6&2\,2\,9\\7&4\,4\,8\,8\,9\,9\\8&3\,4\,4\,5\,5\,5\,8\end{array}
    2. With n = 25 the median is the 13th leaf, counting from the top:

      M=x(13)=74M=x_{(13)}=74
    3. 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:

      Q1=x(6)+x(7)2=52+542=53,Q3=x(19)+x(20)2=83+842=83.5Q_1=\frac{x_{(6)}+x_{(7)}}{2}=\frac{52+54}{2}=53,\qquad Q_3=\frac{x_{(19)}+x_{(20)}}{2}=\frac{83+84}{2}=83.5

    Answer

    M = 74 minutes, Q₁ = 53 and Q₃ = 83.5.

    M=74,Q1=53,Q3=83.5M=74,\qquad Q_1=53,\qquad Q_3=83.5
  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.

    Open this problem in the tool

    Show solution
    1. 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:

      f=2, 7, 3, 6, 7,2+7+3+6+7=25f=2,\ 7,\ 3,\ 6,\ 7,\qquad 2+7+3+6+7=25
    2. Divide by 25, then keep a running total:

      f25=0.08, 0.28, 0.12, 0.24, 0.28;∑f25=0.08, 0.36, 0.48, 0.72, 1\frac{f}{25}=0.08,\ 0.28,\ 0.12,\ 0.24,\ 0.28;\qquad\sum\frac{f}{25}=0.08,\ 0.36,\ 0.48,\ 0.72,\ 1
    3. 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).

      2+7+3=12<13≤2+7+3+6=182+7+3=12<13\le 2+7+3+6=18

    Answer

    Relative frequencies 8%, 28%, 12%, 24%, 28%; cumulative 8%, 36%, 48%, 72%, 100%. The median lies in [70, 80).

    M∈[70, 80)M\in[70,\ 80)
  6. 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.

    Open this problem in the tool

    Show solution
    1. The interquartile range, then the fences 1.5 IQR beyond the box:

      IQR=31−24=7,24−1.5×7=13.5,31+1.5×7=41.5\mathrm{IQR}=31-24=7,\qquad 24-1.5\times7=13.5,\qquad 31+1.5\times7=41.5
    2. A value below 13.5 or above 41.5 is an outlier. −44 and −2 are below 13.5, and nothing reaches 41.5:

      −44<13.5,−2<13.5,40<41.5-44<13.5,\qquad -2<13.5,\qquad 40<41.5
    3. 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.

    16, 24, 27, 31, 40;−44, −216,\ 24,\ 27,\ 31,\ 40;\qquad -44,\ -2
  7. 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.

    Open this problem in the tool

    Show solution
    1. 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:

      A: 53+572=55, 62+782=70, 84+862=85B: 54+562=55, 69+712=70, 84+862=85A:\ \frac{53+57}{2}=55,\ \frac{62+78}{2}=70,\ \frac{84+86}{2}=85\qquad B:\ \frac{54+56}{2}=55,\ \frac{69+71}{2}=70,\ \frac{84+86}{2}=85
    2. Both classes run from 40 to 100, so the boxplots are identical. The histograms, bin by bin from [40, 50), are not:

      A: 2, 6, 2, 1, 7, 1, 1B: 3, 4, 3, 3, 3, 3, 1A:\ 2,\ 6,\ 2,\ 1,\ 7,\ 1,\ 1\qquad B:\ 3,\ 4,\ 3,\ 3,\ 3,\ 3,\ 1

    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.

    40, 55, 70, 85, 10040,\ 55,\ 70,\ 85,\ 100

Supplementary problems, answers only

  1. 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.

    12, 15, 20, 28, 47;28+1.5×13=47.5>4712,\ 15,\ 20,\ 28,\ 47;\qquad 28+1.5\times13=47.5>47
  2. 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.

    8852201≈40.2%\frac{885}{2201}\approx40.2\%
  3. 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

    3.4,−0.23.4,\qquad -0.2
  4. 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%

    1+20+32+24272=77272≈28.3%\frac{1+20+32+24}{272}=\frac{77}{272}\approx28.3\%
  5. 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.

  6. 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.

    50+1.5×20=80<82,30−1.5×20=050+1.5\times20=80<82,\qquad 30-1.5\times20=0

Old Faithful has two humps at 5 minutes and one at 20

Press All 272, 5-minute bins: the waits between eruptions pile up near 50 minutes and near 80, two humps with a dip between them. Guess what bins four times as wide will show, then press All 272, 20-minute bins. The bars read 77, 103 and 92, a single hump, and it stays a single hump wherever the first bin starts. Nothing about the geyser changed between the two pictures. Slide the width down to 2 minutes and the histogram grows eight peaks, most of them noise. So a histogram’s shape is partly the drawer’s choice, and before you call a distribution bimodal, look at it at more than one width. The dotplot above it has no width to choose, and it shows both clumps whatever the slider says.

Class A and Class B draw the same boxplot

Press Class A, then Class B, and watch the boxplot: it does not move. Both classes have the five-number summary 40, 55, 70, 85, 100, and a boxplot with no outliers is drawn from those five numbers and nothing else. The dotplot tells them apart at a glance. In Class A nobody scored between 62 and 78, so the class is really two groups, while Class B is spread evenly from 40 to 100. Any data set with the same five numbers draws the same box, which is how a boxplot can hide a gap, a second hump and even how many values there are. It is the right picture for comparing several groups side by side and the wrong one for finding the shape of a single group.

A bar chart has no shape

Press Titanic by class: 325 in first class, 285 in second, 706 in third and 885 crew. Tick “Order bars by count” and the bars fall from left to right the way a right-skewed histogram falls; untick it and they dip and then climb. The order was yours to choose all along, because crew is neither more nor less than first class, so skewed and symmetric describe nothing here. A histogram’s bars cannot be shuffled, since each one sits at its place on a number line, and that is also why they touch while a bar chart’s bars stand apart. Describe a categorical variable by its counts and proportions (crew, 40.2% of the 2,201 aboard) and keep shape for numbers.

Learning path

Statistics: from data to proportions

References (6)