From Measurements to a Histogram
A histogram turns a list of quantitative measurements into a display of how many observations fall in successive intervals. Constructing one requires more than drawing rectangles: the intervals must cover the data without gaps or overlaps, and every measurement must be counted exactly once. When the bins have equal width, the bar heights can be the frequencies in those intervals.
The bin width is assumed to have been chosen for the data. The focus here is how to use that width consistently: select boundaries that cover all recorded values, assign each value to a bin, tally the counts, and draw and label the histogram.
Because the horizontal axis represents a quantitative scale, histogram bars for adjacent bins touch. This is different from a bar chart of categories, where the bars represent distinct groups rather than consecutive intervals on a number line. Put the bin boundaries on the horizontal axis and label that axis with the variable and its units. Label the vertical axis with frequency and make clear what is being counted.
Set Boundaries and Assign Values
Suppose the selected bin width is \(w\), and the first lower boundary is \(a\). The successive boundaries are \(a, a+w, a+2w,\ldots\). Each new boundary is the previous one plus the same width. Choose enough bins so that every observed value is covered. The first boundary should be at or below the smallest observation, and the final boundary should be at or above the largest.
A value that falls exactly on a shared boundary needs an unambiguous assignment. A standard convention is to include the lower boundary and exclude the upper boundary in each bin. Thus, bins may be written \([a,a+w)\), \([a+w,a+2w)\), and so on. If the final upper boundary is included, state or apply that convention consistently. With this rule, a value equal to a shared boundary goes into the bin to its right, not the bin to its left.
Once the bins are set, count the observations in each one. If there are \(k\) bins, write the frequency of bin \(j\) as \(f_j\), for \(j=1,\ldots,k\). The frequencies must account for the whole data set:
This is a basic but important check: every observation belongs to one bin, so adding the bin counts must recover the sample size \(n\).
Use the selected equal width and a starting point that lets the bins cover the smallest through largest observation.
Use one consistent convention at shared boundaries so each measurement is assigned once.
Count the observations in each bin and verify that the frequencies sum to \(n\).
Draw touching bars over the corresponding intervals, with height equal to frequency. Label both axes and show the bin boundaries on the quantitative axis.
Worked Example: Package Weights in Equal-Width Bins
Suppose a quality-control exercise records the following hypothetical weights for 15 packages, in grams:
498, 503, 507, 511, 516, 519, 523, 527, 532, 536, 541, 545, 549, 554, 560.
Use bins of width 15 g, starting at 495 g. The measurements range from 498 g to 560 g, so the bins \([495,510)\), \([510,525)\), \([525,540)\), \([540,555)\), and \([555,570]\) cover all the data. The first four include their lower boundary and exclude their upper boundary; the final interval includes its upper boundary.
Count the first bin. The values from 495 g up to, but not including, 510 g are 498, 503, and 507. Its frequency is \(3\).
Count the second bin. The values from 510 g up to, but not including, 525 g are 511, 516, 519, and 523. Its frequency is \(4\).
Count the third bin. The values from 525 g up to, but not including, 540 g are 527, 532, and 536. Its frequency is \(3\).
Count the fourth bin. The values from 540 g up to, but not including, 555 g are 541, 545, 549, and 554. Its frequency is \(4\).
Count the fifth bin. The only value from 555 g through 570 g is 560. Its frequency is \(1\).
| Package weight (g) | Frequency (packages) |
|---|---|
| [495, 510) | 3 |
| [510, 525) | 4 |
| [525, 540) | 3 |
| [540, 555) | 4 |
| [555, 570] | 1 |
The check is \(3+4+3+4+1=15\), which matches the 15 packages recorded. To draw the histogram, label the horizontal axis “Package weight (g)” and place the boundaries 495, 510, 525, 540, 555, and 570 on it. Label the vertical axis “Frequency (packages).” Draw five touching bars, one over each interval, with heights 3, 4, 3, 4, and 1 packages, respectively. The bar’s horizontal span identifies its weight interval; its height gives the number of packages in that interval.
Why the Frequency Check Works
The frequency total is not merely a convenient arithmetic check. It follows from the way the bins are defined. If the bins are adjacent and nonoverlapping and together cover every observation, each data value belongs to one and only one bin. Counting the values bin by bin therefore counts each observation once and only once.
More formally, for each observation \(x_i\), define \(I_{ij}=1\) if \(x_i\) belongs to bin \(j\), and \(I_{ij}=0\) otherwise. Because exactly one bin contains \(x_i\), the indicators for that observation add to 1. The frequency \(f_j\) is the sum of the indicators for bin \(j\). Rearranging the finite sums gives:
If the frequencies do not add to \(n\), then at least one observation was missed, counted more than once, or included in an incorrect tally. Checking the total can reveal an error before the graph is drawn.
Worked Example: Assigning Values on Bin Boundaries
Consider these hypothetical measurements, in minutes: 2, 4, 5, 7, 10, 10. Construct a frequency table using bins of width 5 minutes from 0 minutes to 15 minutes. Use lower-inclusive, upper-exclusive intervals, with the final upper endpoint included.
The bins are \([0,5)\), \([5,10)\), and \([10,15]\). The values 2 and 4 belong to the first bin, giving frequency \(2\). The values 5 and 7 belong to the second bin, giving frequency \(2\). Both values equal to 10 belong to the third bin because 10 is the lower boundary of that interval; the third-bin frequency is also \(2\).
| Time (minutes) | Frequency (observations) |
|---|---|
| [0, 5) | 2 |
| [5, 10) | 2 |
| [10, 15] | 2 |
The sum is \(2+2+2=6\), matching the six measurements. In the histogram, the three bars touch and each has width 5 minutes. The bar for \([5,10)\) does not include either value of 10: under the stated convention, those values go into the next bin. This illustrates why a boundary rule matters even when the bins have the correct width.
Drawing and Labeling the Display
A frequency table gives the information needed to make the histogram, but the graph should preserve the same intervals and counts. Mark the bin boundaries at equal spacing along the horizontal axis because the intervals have equal width. Draw a rectangle across each interval, with its top at the corresponding frequency on the vertical axis. Use a vertical scale that allows all the frequencies to be read clearly; the scale may start at zero and increase in equal increments.
Include the measured variable and units on the horizontal axis. For example, use “Package weight (g),” not just “Weight,” when the observations are measured in grams. On the vertical axis, state what the counts represent, such as “Frequency (packages).” A reader should be able to identify both the interval represented by a bar and the number of observations in it.
Equal bin widths are important to this construction. With equal widths, using frequency as bar height makes the displayed counts directly comparable across bins. The bars touch because the intervals represent neighboring portions of a quantitative scale, not separate named categories. No gaps should be inserted between adjacent bins.
Worked Example: Constructing a Histogram From a Tally
Suppose a laboratory exercise records these hypothetical processing times, in minutes, for nine samples: 9, 11, 12, 14, 15, 17, 18, 21, 23. Use bins of width 4 minutes from 8 minutes to 24 minutes, applying the lower-inclusive, upper-exclusive rule except that the final bin includes 24.
The bins are \([8,12)\), \([12,16)\), \([16,20)\), and \([20,24]\). Counting the values gives:
- \([8,12)\): 9 and 11, so \(f_1=2\).
- \([12,16)\): 12, 14, and 15, so \(f_2=3\).
- \([16,20)\): 17 and 18, so \(f_3=2\).
- \([20,24]\): 21 and 23, so \(f_4=2\).
The frequency check is \(2+3+2+2=9\), equal to the number of samples. To draw the histogram, label the horizontal axis “Processing time (minutes)” and mark 8, 12, 16, 20, and 24. Label the vertical axis “Frequency (samples)” and draw four touching bars with heights 2, 3, 2, and 2. The first rectangle spans 8 to 12 minutes, the second 12 to 16 minutes, and so on; each width is 4 minutes.
Common Mistakes
- Leaving a gap or overlap between bins. A student might use \([0,5)\) and \([6,11)\), thinking the labels are consecutive. But values between 5 and 6 are uncovered. Use adjacent boundaries, such as \([0,5)\) and \([5,10)\), and apply an endpoint rule.
- Counting a shared-boundary value twice. If 10 is counted in both \([5,10]\) and \([10,15]\), the bins overlap under that convention. Make one side exclude the shared endpoint so each observation goes into one bin.
- Drawing separated bars. Gaps suggest separate categories. For adjacent quantitative intervals in a histogram, the bars touch.
- Using unclear axis labels. A horizontal label such as “Value” omits the variable and units, while a vertical label such as “Count” may not say what is counted. Include both the measurement units and the observational unit where relevant.
- Skipping the frequency check. A table can look plausible while omitting a value. Add the frequencies and compare the result with \(n\).
Check Your Understanding
Answer each question using the equal-width histogram construction rules.
- For bins \([20,30)\), \([30,40)\), and \([40,50]\), which bin contains an observation equal to 40 under the stated endpoint convention?
- A data set has 18 measurements, but the bin frequencies add to 17. Give two possible explanations for the mismatch.
- Why do the bars touch in a histogram of adjacent quantitative intervals?
- A histogram has bins of width 5 seconds. What should the horizontal axis communicate, and what should the vertical axis communicate?
- List the boundaries for four adjacent bins of width 10, beginning at 35. Explain how you would check that they cover a data set with values from 38 to 72.