โ† Back to Chapter

Measures of central tendency โ€” Coded data

Pick what youโ€™d like to study:

๐Ÿ“˜ Notes

๐Ÿ“Š Coded Data (Addition/Subtraction) โ€” Year 12/13 Notes

Coding a dataset means transforming every value by adding (or subtracting) the same constant. If the original data are \(x_1, x_2, \dots, x_n\), choose a convenient constant \(a\) and define

\[ y_i = x_i - a \quad\text{(or } y_i = x_i + c \text{ with } c=-a\text{).} \]

We often pick \(a\) close to the centre of the data (e.g. a round number near the mean) to make arithmetic simpler.


Key Properties (Addition/Subtraction only)

  • Mean: If \(\bar x\) is the mean of \(x\)โ€™s and \(\bar y\) is the mean of \(y\)โ€™s, then \[ \bar y = \bar x - a \quad\Longleftrightarrow\quad \bar x = \bar y + a. \]
  • Median & Quartiles: All shift by the same amount \(a\). \(\text{median}(y)=\text{median}(x)-a\), similarly for \(Q_1, Q_3\).
  • Spread (variance, s.d., IQR): Unchanged by adding/subtracting a constant. \[ s_y^2 = s_x^2,\qquad s_y = s_x,\qquad \text{IQR}_y=\text{IQR}_x. \]
  • Mode: Value shifts by \(a\); the frequency pattern does not change.

Why code?

  • To make mental/hand calculations faster (e.g., subtract 100 from prices around \$100).
  • To centre data around 0 for tidy sums (often \(\sum y_i = 0\) if \(a\) is the mean or a midpoint).
  • To simplify grouped-data computations (choose class midpoints minus a convenient origin).

๐Ÿ“ Examples (with โ€œShow answerโ€)

Example 1 (uncoded โ†’ coded โ†’ mean): Compute the mean of 98, 101, 103, 97, 101 by coding with \(a=100\).

Code with \(y_i=x_i-100\):

\(x:\; 98,\,101,\,103,\,97,\,101\) \(y:\; -2,\, 1,\, 3,\,-3,\, 1\)

\(\sum y = (-2)+1+3+(-3)+1 = 0 \Rightarrow \bar y = 0/5 = 0.\) Decode: \(\bar x = \bar y + 100 = \boxed{100}.\)

Note: Standard deviation is unchanged by the shift.

Example 2 (median & spread): For data \(x:\; 12, 15, 17, 19, 22\). Code with \(a=15\). Find median and IQR before/after coding.

\(y = x - 15:\; -3, 0, 2, 4, 7\).

Median(\(x\)) = 17 → Median(\(y\)) = \(17-15=2\). Quartiles shift by 15; IQR is unchanged.

Original \(Q_1=15\), \(Q_3=22\) so IQR(\(x\)) = \(7\). Coded \(Q_1=0\), \(Q_3=7\) so IQR(\(y\)) = \(7\) (same).

Example 3 (grouped data mean via coding): Classes centred near 50

Suppose midpoints \(m\): 40, 50, 60 with frequencies \(f\): 8, 14, 8. Choose origin \(a=50\), code \(y=m-a\): \(-10, 0, +10\).

\(\sum f = 30\), \(\sum fy = 8(-10) + 14(0) + 8(10) = 0\Rightarrow \bar y = 0.\) Decode: \(\bar x = \bar y + a = 50.\)

Example 4 (fast variance check): Shifting does not change s.d.

For \(x: 7, 9, 10\), take \(a=9\) so \(y=-2,0,1\). Compute \(s_y\) quickly from small numbers; then \(s_x = s_y\).


๐ŸŽฏ Workflow for coded calculations (addition/subtraction)

  1. Pick \(a\) (a convenient centre such as a round number or a class origin).
  2. Compute \(y_i = x_i - a\).
  3. Do the arithmetic with the \(y_i\) (means, frequency sums, etc.).
  4. Decode results: add \(a\) back to means/locations (not to spreads).

๐Ÿ”Ž Extension (not examined here): Multiplying / Full linear coding

More generally you can use linear coding: \[ y_i = \frac{x_i - a}{b}\qquad (b\neq 0). \]

  • Mean: \(\bar y = \dfrac{\bar x - a}{b}\;\Rightarrow\; \bar x = a + b\,\bar y.\)
  • Variance: \(s_y^2 = \dfrac{s_x^2}{b^2}\;\Rightarrow\; s_x^2 = b^2 s_y^2.\)
  • Standard deviation: \(s_y = \dfrac{s_x}{|b|}\;\Rightarrow\; s_x = |b|\, s_y.\)
  • Medians & quartiles: subtract \(a\), then divide by \(b\) (so they scale and shift accordingly).
Example (extension): \(x:\) prices near 200; take \(a=200\), \(b=5\)

Code \(y=\dfrac{x-200}{5}\) to make tiny integers. Compute \(\bar y\), \(s_y\), then decode: \(\bar x = 200 + 5\bar y,\; s_x = 5 s_y.\)


โš ๏ธ Common pitfalls

  • Donโ€™t add the coding constant to the standard deviation or varianceโ€”they do not change under addition.
  • When decoding after multiplying (extension), remember spreads scale by \(|b|\) (or \(b^2\) for variance).
  • When working with grouped data, choose a sensible origin \(a\) (e.g., a class midpoint) to make \(\sum fy\) simple.
Open Full Notes
๐Ÿ–ฅ๏ธ Presentations
โšก Practice Questions

0/6 mastered, 0 attempted

0%
โ–ถ Start Practice ๐Ÿ” Review All Questions