Making a histogram and choosing the bin width
Twenty numbers in a list say little at a glance. How do you turn them into bars, and how wide should each bar be?
Where you are 4 in Histograms
When you reach for it
Fidel wrote down how many texts he sent each day for twenty days. Twenty numbers in a row are hard to take in. A histogram turns them into a picture: the number line is cut into bins of equal width that run end to end, and on each bin stands a bar as tall as the number of values in it. Reading a histogram reads a histogram already drawn. This lesson draws one, from a list of numbers to a frequency table of bins and from the table to bars, and then asks how wide the bins should be.
You reach for it whenever you have numerical data and want to see where the values crowd together and where they thin out. It helps most when the values are spread over a long stretch, or measured in decimals so that few of them repeat: a dot plot of such data has one dot over almost every value and no clear picture.
The procedure
Day 1: from a list to bars
Bins. A bin is a stretch of the number line, written “20 to 30”. Every bin in one histogram has the same bin width, here 30 - 20 = 10, and the bins run end to end with no gaps and no overlaps, so the edges go up in equal steps: 0, 10, 20, 30 and so on.
The edge rule. The number 30 ends one bin and starts the next. As in Reading a histogram, a value on an edge goes in the bar to its right: the bin “20 to 30” holds every value x with 20 \le x < 30, and 30 itself is counted in “30 to 40”. So every value lies in exactly one bin. For whole-number data, “20 to 30” holds 20, 21, \dots, 29, and some tables write that same bin as “20 to 29”.
Where the bins start and stop. The first edge is a round number at or below the smallest value, usually a multiple of the width, so every edge is easy to read: 10, 15, 20 rather than 13, 18, 23. It cannot be above the smallest value, or that value would have no bin. Bins are added until one holds the largest value. Since a bin leaves out its right edge, a largest value sitting exactly on an edge needs one more bin: with a width of 10 and a largest value of 40, the bins go on to “40 to 50”.
The frequency table. List the bins in order and count the values in each. Sorting the list first makes the counting safe, since each bin’s values then sit together; tally marks work too (Data tables, tallies and frequency tables). Before drawing, confirm that the counts add to the number of values, because each value is counted once, and that every bin from the first to the last is listed, even one with a count of 0.
Drawing. The horizontal axis is a number line: edges marked at equal spacing and labeled, the axis named with the quantity and its unit, such as “Mass (g)”. It begins at the first edge, which need not be 0. The vertical axis counts values, from 0 in equal steps to at least the largest count, and is named, such as “Number of days”. Each bar covers exactly its bin and is as tall as its count. Neighboring bars touch, because neighboring bins touch. An empty bin gets no bar but keeps its place, a gap at height zero; leaving it out would make the number line skip a stretch.
Day 2: choosing the bin width
The width is a choice. Nothing in the data fixes it. The same list can be drawn with narrow bins or wide ones, and every such histogram is correct, but they are not equally useful (Example 4).
- Too narrow. Most bins hold one or two values, and some none. Each height depends on exactly where a value happened to land, so the bars jump about, and empty bins appear that are only accidents.
- Too wide. Two or three bars hold everything. Where values crowd, where they thin out and any gap all vanish inside the wide bars.
- About right. Enough bins for the bars to rise and fall, few enough that most bars hold several values.
The shape can change. The eye reads the outline of the bars, and the outline depends on the width: one list can look like one hump at one width and two humps at another. The words for shapes belong to Symmetric and skewed distributions and Uniform and bimodal shapes. Before describing a shape, it is worth drawing a second width to see whether the shape survives.
Picking a width. Decide roughly how many bins you want; a common guide is 5 to 15, fewer for smaller data sets. Then
rounded up to a convenient width: 1, 2 or 5, or these times 10 or divided by 10 (0.5, 20, 50). Rounding up makes the planned bins together at least as long as the spread of the data. A first edge below the smallest value, or a largest value landing exactly on the last edge, can still add one bin, and rounding up can leave one fewer (Example 5), so count the bins you actually get.
Edges where the questions are. A histogram answers “how many are at least 25?” exactly only when 25 is an edge; a number inside a bin cuts a bar that cannot be split (Reading a histogram). When a question is known in advance, choose the width and first edge to put its numbers on edges (Example 6).
Worked examples
Day 1: Fidel’s texts
Fidel counted the texts he sent each day for 20 days. (All the data in this lesson is made up.)
Make a frequency table with bins 10 texts wide starting at 0, and draw the histogram.
SolutionThe smallest value is 8, and 0 is at or below it. The largest, 40, sits on an edge, so by the edge rule it belongs to “40 to 50” and that bin is needed: five bins in all. Sorting puts each bin’s values together:
| Texts in a day | Count |
|---|---|
| 0 to 10 | 2 |
| 10 to 20 | 4 |
| 20 to 30 | 9 |
| 30 to 40 | 4 |
| 40 to 50 | 1 |
The values 20, 30 and 40 sit on edges, and each is the first value of the bin it starts. The counts add to the number of days, 2 + 4 + 9 + 4 + 1 = 20, so no value was missed or counted twice.
The horizontal axis marks the edges 0 to 50 in equal steps. The largest count is 9, so the vertical axis runs from 0 to 10 in steps of 2. The five bars touch.
Day 1: Filippa’s acorns and an empty bin
Filippa weighed 16 acorns, to the nearest tenth of a gram:
Make a frequency table with bins 1 g wide and draw the histogram.
SolutionThe smallest mass is 2.5 g, so the first edge is 2, the whole number just below it. The largest, 7.3 g, lies in “7 to 8”, so there are six bins. Each bin’s masses, in order:
| Mass (g) | Values | Count |
|---|---|---|
| 2 to 3 | 2.5, 2.8, 2.9 | 3 |
| 3 to 4 | 3.0, 3.2, 3.4, 3.5, 3.7, 3.9 | 6 |
| 4 to 5 | 4.0, 4.1, 4.4, 4.6 | 4 |
| 5 to 6 | 5.0, 5.6 | 2 |
| 6 to 7 | none | 0 |
| 7 to 8 | 7.3 | 1 |
The masses 3.0, 4.0 and 5.0 sit on edges and go in the bin to their right. Check: 3 + 6 + 4 + 2 + 0 + 1 = 16.
No acorn lies from 6 g up to 7 g, but the bin stays in the table with a count of 0 and in the drawing as a gap. Without it the bar for 7 to 8 would stand next to 5 to 6, and the heaviest acorn, 1.7 g heavier than the next, would look like just another acorn.
Day 1: Flavio’s class, where to start and stop
Flavio’s class of 24 counted how many push-ups each student could do in one minute. Sorted:
Using bins 5 wide, (a) where should the first bin start, and how many bins are needed? (b) Make the frequency table and draw the histogram.
Solution(a) The largest multiple of 5 at or below the smallest value, 13, is 10, so the first edge is 10. Starting at 15 would leave 13 with no bin; starting at 13 would work, but edges 13, 18, 23, \dots are hard to read. The largest value, 41, lies in “40 to 45”, so the edges run 10, 15, \dots, 45, and the number of bins is
(b)
| Push-ups | Count |
|---|---|
| 10 to 15 | 1 |
| 15 to 20 | 3 |
| 20 to 25 | 5 |
| 25 to 30 | 7 |
| 30 to 35 | 5 |
| 35 to 40 | 2 |
| 40 to 45 | 1 |
The values 20, 25, 25, 30 and 35 sit on edges, and each is counted in the bin it starts. Check: 1 + 3 + 5 + 7 + 5 + 2 + 1 = 24, one count for each student.
Day 2: Galina’s texts at three widths
Galina counted her texts for 24 days. Sorted:
The three histograms below draw these days with bins 2, 20 and 5 texts wide, all starting at 0. What does each show, and what does each hide?
Width 2. From 0 to 40 there are \displaystyle \frac{40}{2} = 20 bins for 24 values, so no bar holds more than 3 days, and the bars jump about. The bin from 24 to 26 is empty and looks like a gap, yet it sits between days with 23 and 26 texts; one day with 25 would fill it. The empty bins at 18 to 22 look just the same, so the picture cannot tell a real gap from an accident.
Width 20. Two bars of 11 days and 13 days, almost level. They suggest the days are spread fairly evenly from 0 to 40 texts, which hides the most striking thing about the data.
Width 5. Counts 1, 5, 4, 1, 1, 4, 6, 2. A group of quiet days from 0 to 15 texts, 1 + 5 + 4 = 10 days, a group of busy days from 25 to 40, 4 + 6 + 2 = 12 days, and only 1 + 1 = 2 days between them. Check: 10 + 2 + 12 = 24.
The data are the same in all three. Width 2 buries the two groups in noise, width 20 hides them, and width 5 shows them. Two humps like these make a bimodal shape (Uniform and bimodal shapes). Width 5 is the one to choose.
Day 2: Fredrik chooses a width
Fredrik weighed 40 acorns from another oak. The lightest was 1.8 g and the heaviest 9.3 g. (a) Choose a bin width that gives about 6 bins, and say where the bins start and stop. (b) Compare widths of 1, 0.5 and 5 g.
Solution(a) The distance from lightest to heaviest is 9.3 - 1.8 = 7.5 g, and
Rounding up to a convenient width gives 2 g. The largest multiple of 2 at or below 1.8 is 0, and 9.3 lies in “8 to 10”, so the bins are 0 to 2, 2 to 4, up to 8 to 10: five bins, near the six planned, with \displaystyle \frac{40}{5} = 8 acorns a bin on average.
(b) Width 1 g: first edge 1, last bin 9 to 10, so \displaystyle \frac{10 - 1}{1} = 9 bins, between 4 and 5 acorns a bin on average. Also sensible. Width 0.5 g: first edge 1.5, last bin 9 to 9.5, so \displaystyle \frac{9.5 - 1.5}{0.5} = 16 bins and \displaystyle \frac{40}{16} = 2.5 acorns a bin: as ragged as Galina’s width 2. Width 5 g: bins 0 to 5 and 5 to 10, only 2. Far too few.
So 1 g or 2 g both suit 40 acorns. There is no single correct width, only widths that show the data and widths that hide it.
Day 2: putting an edge where the question is
Flavio’s teacher wants a histogram of the class in Example 3 with bins 10 push-ups wide that answers exactly: how many students did at least 25 push-ups? Compare starting the bins at 10 and at 5.
SolutionFirst edge 10. From the sorted list in Example 3, the bins 10 to 20, 20 to 30, 30 to 40 and 40 to 50 hold 4, 12, 7, 1. The number 25 lies inside “20 to 30”, whose 12 students could have done anything from 20 to 29. The bars from 30 up give 7 + 1 = 8 students who surely did at least 25, so the answer is only known to lie from 8 to 8 + 12 = 20.
First edge 5. The edge 5 is below the smallest value, 13, so every value has a bin. The bins 5 to 15, 15 to 25, 25 to 35 and 35 to 45 hold 1, 8, 12, 3. Now 25 is an edge, and “at least 25” is two whole bars: 12 + 3 = 15 students. Check with Example 3’s table, where 25 is also an edge: 7 + 5 + 2 + 1 = 15.
Both histograms are correct, yet even their tallest bars differ: 20 to 30 in one, 25 to 35 in the other. Moving the first edge changes which values share a bar. The teacher’s question decides it: start at 5.
Boundaries
- Numerical data only. A bin is a stretch of a number line. Categories, such as favorite colors, go in a bar graph.
- Equal widths. A bin twice as wide collects more values just by being wide, and its taller bar would wrongly suggest a crowded stretch.
- The edge rule must be stated. Left edge in and right edge out is one choice; a histogram using the other rule can have different counts for the same data.
- No going back to narrower bins. Neighboring bins can be merged by adding their counts, but a bin cannot be split from the histogram alone, because the separate values are gone.
- Very few values. With only a handful of values every width is too narrow or too wide; a dot plot keeps each value and suits them better (Choosing a display for a question).
- Counts depend on group size. Histograms of groups of different sizes cannot be compared bar for bar; that needs the Relative frequency histograms.
Where this goes next
The Relative frequency histograms keeps these bins and makes each bar’s height a share of the total. Running totals of the counts, drawn as a graph, become a Cumulative frequency graphs and percentiles. Once a sensible width shows the outline of the data, its shape can be named (Shape of a distribution), and Choosing a display for a question weighs a histogram against a dot plot or a box plot for a given question.
Exercises
Day 1: from a list to a table
- Filippa counted her texts for 15 days: 14, 3, 22, 9, 17, 11, 25, 6, 19, 10, 13, 20, 8, 16, 12. Make a frequency table with bins 5 texts wide starting at 0.
- Which of Filippa’s values in Exercise 1 sit on a bin edge, and in which bin is each counted?
- Describe the histogram of Exercise 1: what each axis shows, how tall each bar is, and which bar is tallest.
- Galina weighed 12 acorns, in grams: 4.2, 5.7, 3.9, 6.0, 4.8, 5.1, 9.4, 4.5, 6.3, 5.0, 3.6, 5.5. Make a frequency table with bins 1 g wide starting at 3.
- Which bins of Exercise 4 are empty, and how are they drawn?
- Make a frequency table for Galina’s acorns with bins 2 g wide starting at 2. How many bins are there?
Day 1: where the bins start and stop
For each data set, give the first edge (the largest multiple of the width at or below the smallest value), the number of bins, and the last bin.
- Push-ups, smallest 7, largest 30, width 5.
- Push-ups, smallest 18, largest 52, width 10.
- Acorn masses, smallest 2.3 g, largest 4.6 g, width 0.5 g.
- Fredrik’s frequency table of texts in a day has the bins 0 to 10, 10 to 20, 20 to 30, 30 to 40 and 40 to 50, with counts 3, 7, 12, 0 and 2. For how many days did he count? How high must the vertical axis reach, and which bin shows as a gap?
Day 2: choosing the bin width
- Flavio’s school recorded push-ups for 30 students, from 12 to 58. Starting each time at the largest multiple of the width at or below 12, how many bins do widths of 2, 5, 10 and 25 give? Which widths are sensible for 30 values?
- Filippa weighed 50 acorns, from 1.2 g to 4.9 g. Choose a convenient width for about 8 bins, give the first edge, and count the bins.
- Galina’s group counted push-ups, sorted: 8, 11, 12, 14, 15, 15, 16, 18, 21, 27, 28, 29. Make one frequency table with bins 10 wide starting at 0, and another with bins 5 wide starting at 5.
- What does the width 5 histogram of Exercise 13 show that the width 10 histogram hides?
- In Exercise 13, how many did at least 15 push-ups? Which of the two histograms answers this exactly, and what can the other one say?
- A histogram has bins 5 wide from 0 to 30 with counts 2, 3, 6, 4, 3, 2. Find the counts for bins 10 wide from 0 to 30. Could you go the other way?
Explaining
- Explain why every bin in a histogram must have the same width.
- Explain why the first edge may be below the smallest value but never above it, and why a round number is chosen.
- The same data drawn with two widths shows one hump at one width and two humps at the other. Is either histogram wrong? What should you conclude about the shape?
- The largest value in a data set is 60, and the bins are 10 wide starting at 0. Explain why the histogram needs a bin from 60 to 70.
Answers
- Sorted: 3, 6, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 20, 22, 25. The bins 0 to 5 up to 25 to 30 (needed for 25) hold 1, 3, 5, 3, 2, 1. Check: 1 + 3 + 5 + 3 + 2 + 1 = 15.
- 10, 20 and 25, each in the bin it starts: 10 in 10 to 15, 20 in 20 to 25, 25 in 25 to 30.
- Horizontal: a number line marked 0, 5, \dots, 30, named “Texts sent in a day”. Vertical: days from 0 to at least 5, named “Number of days”. Six touching bars reach 1, 3, 5, 3, 2, 1; the tallest stands on 10 to 15.
- Bins 3 to 4 up to 9 to 10 (needed for 9.4) hold 2, 3, 4, 2, 0, 0, 1. Check: 2 + 3 + 4 + 2 + 0 + 0 + 1 = 12. The masses 5.0 and 6.0 go right.
- 7 to 8 and 8 to 9. They stay on the number line as one gap 2 g wide at height zero, between the bars on 6 to 7 and 9 to 10.
- 4 bins, 2 to 4 up to 8 to 10, holding 2, 7, 2, 1. Check: 2 + 7 + 2 + 1 = 12.
- First edge 5; 30 is on an edge, so the last bin is 30 to 35: \displaystyle \frac{35 - 5}{5} = 6 bins.
- First edge 10; 52 lies in 50 to 60: \displaystyle \frac{60 - 10}{10} = 5 bins.
- First edge 2; 4.6 lies in 4.5 to 5: \displaystyle \frac{5 - 2}{0.5} = 6 bins.
- 3 + 7 + 12 + 0 + 2 = 24 days. The axis must reach at least 12. The bin 30 to 40 is a gap.
- 24, 10, 5 and 3 bins: \displaystyle \frac{60 - 12}{2} = 24, \displaystyle \frac{60 - 10}{5} = 10, \displaystyle \frac{60 - 10}{10} = 5 and \displaystyle \frac{75}{25} = 3. Widths 5 and 10 suit 30 values; 24 bins are too many and 3 too few.
- 4.9 - 1.2 = 3.7 and 3.7 \div 8 = 0.4625, so round up to 0.5 g. First edge 1; 4.9 lies in 4.5 to 5: \displaystyle \frac{5 - 1}{0.5} = 8 bins.
- Width 10 from 0: 1, 7, 4. Width 5 from 5: 1, 3, 4, 1, 3. Both add to 12.
- A low bar, 1, on 20 to 25 between bars of 4 and 3: a small group from 25 to 30 stands apart from the rest. At width 10 those three share the bar on 20 to 30 with 21, and the dip disappears.
- 8 students. The width 5 histogram answers exactly, since 15 is an edge: 4 + 1 + 3 = 8. At width 10, 15 cuts the bar on 10 to 20, so it says only at least 4 and at most 4 + 7 = 11.
- 5, 10, 5, from 2 + 3 = 5, 6 + 4 = 10 and 3 + 2 = 5. Not the other way: a count of 10 on 10 to 20 does not say how many of those values are below 15.
- A taller bar should mean a more crowded stretch. A wider bin collects more values just by covering more of the line, so with unequal widths a tall bar could mean a wide bin rather than a crowded one.
- Every value needs a bin, so a first edge above the smallest value leaves that value out; below it, the first bin simply starts with a stretch holding no values. A round number, usually a multiple of the width, makes every edge easy to read.
- Neither is wrong: both count the same values correctly. The shape seen depends on the width, so a shape that appears at only one width is weak evidence; a shape that survives several sensible widths is a real feature of the data.
- The bin 50 to 60 leaves out 60. By the edge rule 60 goes in the bar to its right, 60 to 70; without that bin the largest value would have nowhere to go, and the counts would add to one fewer than the number of values.