Skip to main content
Examonaut

Topic 2 · Lesson 2 of 4

Grouped data, histograms and coding

Grouped data and histograms

When data come in classes, you don't know the exact values, so every calculation is an estimate.

  • Mean and standard deviation: use the midpoint of each class as xx: xˉ=∑fx∑f\bar{x} = \frac{\sum fx}{\sum f} and σ2=∑fx2∑f−xˉ2\sigma^2 = \frac{\sum fx^2}{\sum f} - \bar{x}^2.
  • Median and quartiles: use linear interpolation, which assumes the values are spread evenly through each class.

In a histogram, the area of each bar represents frequency, so classes of different widths are shown fairly. The height is the frequency density:

frequency density=frequencyclass width\text{frequency density} = \frac{\text{frequency}}{\text{class width}}

The diagram shows times taken by 70 people to finish a puzzle, in classes 0–10, 10–15, 15–20, 20–30 and 30–50 minutes with frequencies 8, 14, 20, 18 and 10. The 15–20 bar has width 5 and height 4, so area 20: twenty people. Without frequency density, the wide 30–50 class would look far more important than it is.

tf.d.10203040501234area 4 × 5 = 20

A frequency polygon joins the midpoints of the tops of the bars with straight lines; it is useful for comparing two distributions on one diagram. Histograms connect to probability: if the total area is scaled to 1, the area of a bar is the probability that a value falls in that class, which leads to continuous distributions like the Normal distribution.

Worked example

Grouped dataexam standard

For the puzzle data, estimate a) the number of people who took between 12 and 25 minutes, b) the median, c) the mean and standard deviation.

Show solution
  1. a) Use areas. 12–15: width 3 at density 2.8, so 8.4. 15–20: 20. 20–25: width 5 at density 1.8, so 9. Total 37.4≈3737.4 \approx 37 people.
  2. b) The median is the 702=35\frac{70}{2} = 35th value. Cumulative frequencies are 8, 22, 42, so it is in the 15–20 class, 35−22=1335 - 22 = 13 values into a class of 20. Interpolate: 15+1320×5=18.2515 + \frac{13}{20} \times 5 = 18.25 minutes.
  3. c) Midpoints 5, 12.5, 17.5, 25, 40. ∑fx=1415\sum fx = 1415, so xˉ=141570=20.2\bar{x} = \frac{1415}{70} = 20.2 minutes.
  4. ∑fx2=35 762.5\sum fx^2 = 35\,762.5, so σ2=35762.570−20.2142=102.3\sigma^2 = \frac{35762.5}{70} - 20.214^2 = 102.3 and σ=10.1\sigma = 10.1 minutes.

For grouped data, use the n2\frac{n}{2}th value for the median (and n4\frac{n}{4}th, 3n4\frac{3n}{4}th for quartiles), because the data are treated as continuous. The same readings can be made from a cumulative frequency graph, plotting cumulative frequency at each upper class boundary, as below; here Q1=13.4Q_1 = 13.4, median 18.25 and Q3=25.8Q_3 = 25.8.

tc.f.102030405010203040506070median 18.25

Coding

Coding changes every value by a rule such as y=x−aby = \frac{x - a}{b} to make numbers easier. Think about what each step does:

  • Adding or subtracting a constant shifts every value, so it changes the mean by that constant but does not change the spread.
  • Multiplying or dividing by bb scales everything, so it scales the mean and the standard deviation by bb (the variance by b2b^2).

So if y=x−1005y = \frac{x - 100}{5}, then xˉ=5yˉ+100\bar{x} = 5\bar{y} + 100 and σx=5σy\sigma_x = 5\sigma_y. Always decode by reversing the steps.

Worked example

Codingexam standard

Masses xx grams are coded with y=x−25010y = \frac{x - 250}{10}. For 20 items, ∑y=36\sum y = 36 and ∑y2=180\sum y^2 = 180. Find the mean and standard deviation of xx.

Show solution
  1. yˉ=3620=1.8\bar{y} = \frac{36}{20} = 1.8 and σy2=18020−1.82=5.76\sigma_y^2 = \frac{180}{20} - 1.8^2 = 5.76, so σy=2.4\sigma_y = 2.4.
  2. Decode: x=10y+250x = 10y + 250, so xˉ=10(1.8)+250=268\bar{x} = 10(1.8) + 250 = 268 g.
  3. The +250+ 250 doesn't affect spread: σx=10×2.4=24\sigma_x = 10 \times 2.4 = 24 g.

Practise this topic

Both are part of Premium.