Relative frequency histograms
Forty earthworms from a back garden and 250 from an orchard. How can one picture show whose worms tend to be longer?
Where you are 4 in Histograms
When you reach for it
A histogram groups numerical data into bins of equal width and draws one bar per bin, as tall as the number of values in it; Making a histogram and choosing the bin width is where the bins are chosen. A count answers “how many?”. That is the right question for one group and the wrong one for two groups of different sizes.
Teodora measured the 40 earthworms she dug up in her back garden, and Melchior measured 250 from a large orchard. (All the data in this lesson is made up.) Drawn as counts, the orchard has more worms of every length simply because it has more worms. Its bars tower over the garden’s, and setting them side by side says nothing about whose worms tend to be longer.
Relative frequency tables met the same problem with categories and solved it by replacing each count with its share of the total. A relative frequency histogram does the same for a histogram: the same bins, but each bar’s height is the share of the data in that bin, written as a decimal or a percent. Two groups of any sizes then stand on one footing.
The procedure
Equal bins, and a rule for the edges. Exactly as for a count histogram. A value landing on the edge between two bars has to belong to one of them, so state a rule and keep it. In this lesson a value on an edge goes in the bar to its right: the bin “8 to 10 cm” holds lengths x with 8 \le x < 10, and a worm exactly 10 cm long is counted in the 10 to 12 bar. The last bar has no bar to its right, so it keeps a value sitting on its top edge: a worm of exactly 16 cm would go in the 14 to 16 bar.
Divide each count by the total. A bin holding f of the n values gets the height
Multiply by 100 for a percent.
The heights add to 1. Every value sits in exactly one bin, so the counts f_1, \dots, f_k add to n, and
As percents, 100\%. Once the shares are rounded the total can come out slightly off, such as 0.99 or 101\%. That is rounding, not an error; the exact shares still add to 1.
The shape does not change. Every count is divided by the same number n, so every bar shrinks by the same factor. A bar twice as tall as another is still twice as tall, the tallest bar is still the tallest, and an empty bin stays empty. Put a share scale beside the count scale and the bars are the very same bars; only the numbers up the side are new.
So for one group on its own, the relative histogram shows nothing new about shape. Its use is setting two groups side by side.
A share of a range is a sum of bars. The bins do not overlap, so the share of the data in several bins is the sum of their heights: “at least 10 cm” is the 10 to 12, 12 to 14 and 14 to 16 bars together. Only whole bars can be added, because a bar does not show how its values spread inside it.
Back to counts by multiplying. From \displaystyle \text{share} = \frac{f}{n} the count is f = \text{share} \times n. That needs n, which the bars do not show, so a relative histogram should state its total.
Shape, center and spread are read as before, since the picture is the same. Shape: peaks, symmetry and tails (Shape of a distribution, Symmetric and skewed distributions). Center: the median lies in the bar where the running total of heights, added from the left, passes 0.5; if the total reaches 0.5 exactly at an edge, the median is close to that edge (center and spread). Spread: how far the bars reach and how wide their bulk is (Range and interquartile range). Then say what it means for the thing measured (Describing a distribution).
Worked examples
Teodora’s garden
Teodora sorted her 40 worms into bins 2 cm wide.
| Length (cm) | Count |
|---|---|
| 4 to 6 | 2 |
| 6 to 8 | 6 |
| 8 to 10 | 12 |
| 10 to 12 | 10 |
| 12 to 14 | 8 |
| 14 to 16 | 2 |
Find the height of each bar of the relative frequency histogram.
SolutionThe bins all have width 2 cm, so they can be used as they are. Each count is divided by the total, 40:
Check: 0.05 + 0.15 + 0.30 + 0.25 + 0.20 + 0.05 = 1, as it must be, since the counts add to 40. The first figure draws these bars. Its share scale is its count scale divided by 40, which is why 12 and 0.30 sit at the same height. The tallest bar, 8 to 10 cm, holds 30\% of the worms.
The garden and the orchard
Melchior’s 250 orchard worms went into the same bins.
| Length (cm) | Garden | Orchard |
|---|---|---|
| 4 to 6 | 2 | 25 |
| 6 to 8 | 6 | 60 |
| 8 to 10 | 12 | 75 |
| 10 to 12 | 10 | 50 |
| 12 to 14 | 8 | 30 |
| 14 to 16 | 2 | 10 |
(a) Which place has more worms from 10 to 12 cm long? (b) Which has the larger share of its worms that long? (c) Compare the two distributions.
Solution(a) The orchard: 50 worms against 10. True, and nearly useless: the orchard sample is over six times bigger, so on one count scale every orchard bar stands above the garden’s.
(b) Divide the orchard counts by 250:
They add to 1. In the 10 to 12 bin the garden’s share is 0.25 and the orchard’s is 0.20, so the garden has the larger share: the opposite of what the counts suggested.
(c) On one share scale the bars compare one for one. Both distributions peak at 8 to 10 cm with 0.30, and both run from 4 to 16 cm. The orchard carries more weight on the short side. Under 8 cm: 0.10 + 0.24 = 0.34 against 0.05 + 0.15 = 0.20. At least 10 cm: 0.20 + 0.12 + 0.04 = 0.36 against 0.25 + 0.20 + 0.05 = 0.50. The garden’s running total reaches 0.50 exactly at 10 cm, so its median is close to 10 cm; the orchard’s runs 0.10, 0.34, 0.64 and passes 0.5 inside the 8 to 10 bar, so its median is lower. In these samples the orchard worms tend to be somewhat shorter. Another dig would give somewhat different shares (Sampling variability and simulating it).
Adding bars on Silvan’s playlist
Silvan’s playlist has 60 songs, shown below. What percent of them last (a) at least 4 minutes, (b) less than 3 minutes, (c) at least 3 but less than 6 minutes? (d) Can the histogram say what percent last at least 4.5 minutes?
(a) “At least 4” takes the bars from 4 up to 8. A song of exactly 4 minutes is in the 4 to 5 bar by the edge rule, so it is counted. 30 + 15 + 5 + 5 = 55, so 55\%. Check with the rest: the two bars below 4 hold 10 + 35 = 45, and 100 - 45 = 55.
(b) Only the first bar: 10\%.
(c) 35 + 30 + 15 = 80, so 80\%.
(d) No. The value 4.5 is inside the 4 to 5 bar, which says that 30\% of the songs lie somewhere from 4 to 5 minutes but not where. The answer is at least the 25\% from 5 minutes up and at most the 55\% from 4 minutes up, and the bars cannot narrow it further.
Back to counts
Silvan’s playlist again. (a) How many songs last from 4 to 5 minutes? (b) How many last at least 5 minutes? (c) Silvan deletes every song shorter than 3 minutes. What percent of the songs left last from 3 to 4 minutes?
Solution(a) 30\% of 60 is 0.30 \times 60 = 18 songs.
(b) The bars from 5 minutes up add to 15 + 5 + 5 = 25, so 25\%, and 0.25 \times 60 = 15 songs.
(c) The total changes, so every share changes; work from counts. Under 3 minutes there are 0.10 \times 60 = 6 songs, leaving 54. From 3 to 4 there are 0.35 \times 60 = 21. The new share is
about 38.9\%, up from 35\%. Every remaining bar grows by the same factor \displaystyle \frac{60}{54}, so the new heights again add to 100\%.
Rounded shares, and two playlists
Ludovic’s playlist has 30 songs: 4, 7, 7, 7 and 5 of them in the bins 2 to 3, 3 to 4, 4 to 5, 5 to 6 and 6 to 7 minutes. (a) Find the heights as whole-number percents and add them. (b) Whose playlist, Ludovic’s or Silvan’s, has the larger share of songs lasting at least 4 minutes? Whose has more such songs?
Solution(a) \displaystyle \frac{4}{30} \approx 13.3\% rounds to 13\%; \displaystyle \frac{7}{30} \approx 23.3\% rounds to 23\%, three times; \displaystyle \frac{5}{30} \approx 16.7\% rounds to 17\%. The rounded heights add to 13 + 23 + 23 + 23 + 17 = 99. The exact shares add to \displaystyle \frac{30}{30} = 100\%: rounding took \displaystyle \frac{1}{3} of a percent off four bars and added \displaystyle \frac{1}{3} to one, a net loss of 1. A note under the graph that the percents do not add to 100 because of rounding is all it needs.
(b) Use exact counts, not rounded heights. Ludovic has 7 + 7 + 5 = 19 such songs, and \displaystyle \frac{19}{30} \approx 63.3\%. Silvan has 55\% (Example 3), which is 33 songs. Ludovic’s playlist has the larger share of long songs; Silvan’s has more of them. Both are true, because a count answers “how many” and a share answers “how common”. The comparison is fair only because the two use the same bins.
Boundaries
- Equal bin widths. A bin twice as wide collects more values just by being wide, so its bar overstates how crowded that stretch is. Histograms with unequal bins use a different scale, density, where a bar’s area rather than its height is the share; that idea leads to Density curves: area, mean and median.
- Numerical data. For categories the shares go in a bar graph, as in Relative frequency tables.
- Same bins, same scale. Two relative histograms with different bins or different vertical axes cannot be read bar against bar.
- The total is hidden. Shares alone cannot give counts, so state n. A small total also makes shares jumpy: in a group of 5, one value is 0.20 of the data.
- Nothing inside a bar. A share of a range can be read only when the range starts and ends on bin edges.
Where this goes next
The running totals of Example 2, graphed, make a Cumulative frequency graphs and percentiles, and reading one backwards for the length below which a chosen share of the data lies is Percentiles. With more data and narrower bins, a histogram scaled so its total area is 1 smooths into a density curve. Box plots compare groups of different sizes by another route (Comparing box plots), and Comparing two distributions brings the comparisons together.
Exercises
Building the bars
- Xanthe dug 25 worms from a flower bed. The bins 4 to 6, 6 to 8, 8 to 10, 10 to 12 and 12 to 14 cm held 1, 4, 10, 6 and 4 worms. Find each height as a decimal and check the total.
- Tancredi’s playlist has 80 songs: 8, 20, 28, 16 and 8 of them in the bins 2 to 3, 3 to 4, 4 to 5, 5 to 6 and 6 to 7 minutes. Find each height as a percent.
- Twenty song lengths, in minutes: 2.5, 3.0, 3.2, 3.4, 3.5, 3.8, 4.0, 4.0, 4.1, 4.3, 4.5, 4.6, 4.9, 5.0, 5.2, 5.5, 5.8, 6.0, 6.4, 7.1. Use bins 1 minute wide from 2 to 8, a value on an edge going in the bar to its right. Find the counts and the heights as decimals.
- A bucket holds 12 worms: 5 in the bin 6 to 8 cm, 5 in 8 to 10 cm and 2 in 10 to 12 cm. Find the heights as whole-number percents, add them, and explain the total.
Reading shares
- In Teodora’s garden (Example 1), what share of the worms are at least 12 cm long? What share are at least 6 but less than 12 cm?
- In Melchior’s orchard (Example 2), what share are at least 12 cm? What share are less than 10 cm?
- On Silvan’s playlist, what percent of songs last less than 5 minutes? What percent last at least 6 minutes?
- Using only the heights from Exercise 3, find the share of songs lasting at least 4 but less than 6 minutes. Then check it against the list.
Back to counts
- Using the shares, how many of Melchior’s 250 worms are at least 12 cm long?
- The five bars of a relative frequency histogram of 50 songs have heights 0.08, 0.30, 0.26, h and 0.10. Find h and the count in each bin.
- A count histogram and a relative frequency histogram of the same worms stand side by side. One bar reads 21 on the count scale and 0.15 on the share scale. How many worms are there?
- On a percent histogram of 90 songs, one bar reads 17\%, rounded to the nearest whole percent. How many songs are in that bin?
Comparing groups
- Compare Silvan’s playlist with Tancredi’s (Exercise 2). Which has the larger share of songs shorter than 4 minutes? Which has more such songs?
- A claim about Example 2: “Long worms are more common in the orchard. It has 40 worms of at least 12 cm and the garden has only 10.” Is the claim right?
Explaining
- Explain why turning a count histogram into a relative frequency histogram keeps the tallest bar the tallest, and keeps a bar twice as tall as another twice as tall.
- Explain why count histograms of groups of 40 and 250 cannot be compared bar by bar. If both groups had 40 values, would counts be enough?
- Teodora regroups her worms into the bins 4 to 8, 8 to 10 and 10 to 16 cm. Find the heights, and explain why this histogram misleads even though they add to 1.
Answers
- 0.04, 0.16, 0.40, 0.24, 0.16. Each count is divided by 25, and they add to 1.
- 10\%, 25\%, 35\%, 20\%, 10\%. Each count is divided by 80, and they add to 100\%.
- Counts 1, 5, 7, 4, 2, 1; heights 0.05, 0.25, 0.35, 0.20, 0.10, 0.05. The edge values go right: 3.0 in 3 to 4, both 4.0s in 4 to 5, 5.0 in 5 to 6, 6.0 in 6 to 7.
- 42\%, 42\%, 17\%, adding to 101\%. The exact shares 41\tfrac{2}{3}\%, 41\tfrac{2}{3}\% and 16\tfrac{2}{3}\% add to 100\%; each rounds up by \displaystyle \frac{1}{3}, an extra 1 in all.
- 0.25 and 0.70: 0.20 + 0.05, and 0.15 + 0.30 + 0.25.
- 0.16 and 0.64: 0.12 + 0.04, and 0.10 + 0.24 + 0.30.
- 75\% and 10\%: 10 + 35 + 30, and 5 + 5.
- 0.35 + 0.20 = 0.55. In the list, 11 songs run from 4.0 to 5.8, and \displaystyle \frac{11}{20} = 0.55.
- 40 worms: (0.12 + 0.04) \times 250 = 40, which matches 30 + 10.
- h = 0.26, since 1 - (0.08 + 0.30 + 0.26 + 0.10) = 0.26. Counts 4, 15, 13, 13, 5 (each height times 50), adding to 50.
- 140 worms: 0.15 \times n = 21, so \displaystyle n = \frac{21}{0.15} = 140.
- 15 songs. A height that rounds to 17\% is from 16.5\% up to 17.5\%, which of 90 songs is from 14.85 up to 15.75. The only whole number there is 15, and \displaystyle \frac{15}{90} \approx 16.7\% does round to 17\%.
- Silvan: 10\% + 35\% = 45\%, which is 27 songs. Tancredi: 10\% + 25\% = 35\%, which is 28 songs. Silvan’s has the larger share; Tancredi’s has one more such song.
- No. The counts reflect the sizes of the samples. As shares, 0.25 of the garden’s worms are at least 12 cm against 0.16 of the orchard’s, so long worms are more common in the garden.
- Every count is divided by the same total n. Counts f and 2f become \displaystyle \frac{f}{n} and \displaystyle \frac{2f}{n}, still one twice the other, and dividing by a positive number keeps the counts in the same order, so the tallest stays tallest.
- A count grows with the size of the group: with over six times as many worms, the orchard’s bars are taller everywhere even if the lengths are spread the same way, so the comparison measures size, not the distribution. With 40 in each, every share is a count divided by the same 40, so comparing counts gives the same answers as comparing shares.
- Heights 0.20, 0.30 and 0.50. The 10 to 16 bar is the tallest only because it is 6 cm wide: per centimeter it holds about 0.08 of the worms, against \displaystyle \frac{0.30}{2} = 0.15 in the 8 to 10 bin. With unequal widths, height no longer shows where the data is crowded.